karlwestin / node-gumbo-parser

Parsing HTML in node using google's gumbo parser
MIT License
154 stars 12 forks source link

compilation fail on snow leopard #7

Closed alexjeffburke closed 10 years ago

alexjeffburke commented 11 years ago

Hey,

When I try to npm install gumbo-parser it seems to get to the point of compiling the parser itself in C, but blows up with the following:

CC(target) Release/obj.target/gumbo/deps/gumbo-parser/src/attribute.o ../deps/gumbo-parser/src/attribute.c: In function ‘gumbo_get_attribute’: ../deps/gumbo-parser/src/attribute.c:30: error: ‘for’ loop initial declaration used outside C99 mode ../deps/gumbo-parser/src/attribute.c:30: warning: comparison between signed and unsigned make: *\ [Release/obj.target/gumbo/deps/gumbo-parser/src/attribute.o] Error 1

I'm sure this is something to do with the GYP build script for the parser, but after trying for quite a while and to no avail to patch it I think it's about time to ask. My guess is the gnu99 requirement being enforced isn't correct, but even if I'm on the right track I can't figure out how to relax that requirement.

Any suggestion would be most welcome.

Thanks, Alex J Burke.

karlwestin commented 11 years ago

hey, thanks for reporting this

can you see if this makes any difference at all: try cloning this repo and check out the branch fix-7:

git checkout fix-7
node-gyp rebuild
#and if this works
node test/test.js

And see if this makes any difference at all

alexjeffburke commented 11 years ago

Appreciate you're looking into this.. and I think it's worked out!

With your fix branch checked out, node-gyp rebuild successfully completed and running node test/test.js produced: Running: normal roots an object Parses html tag Parses head as a child of html Parses attributes ...done! Running: stopOnFirstError stopped on error when option is passed didn't stop on error by default ...done! Running: legacy doctypes added systemIdentifier and publicIdentifier ...done! Running: unicode Handles non-ascii characters ...done! Running: custom tags Handles custom tags ...done!

Looks to me like the binding is now working here, but hopefully the output above is enough to properly verify that.

karlwestin commented 11 years ago

Thanks for checking this out! I've merged the fix and ill push it npm later today!

ChrisGitIt commented 10 years ago

Hi, the "-std=gnu99" or "-std=c99" cflags seems to be required on every OS that does not use c99 or c++ as default. I think every BSD Version like in my case FreeBSD 9.2 will need this flag for compiling. Might be a good idea to include it as default ...

karlwestin commented 10 years ago

thanks for the heads up, downloading freebsd now to try in a VM

karlwestin commented 10 years ago

Please try to build from master again, re open if it doesnt work :)

Ill push to npm later tonight!