-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
define easy, cross-platform way of building addons #2136
Comments
I started work on a .gyp file for building an addon. One issue is the convention for the name of the shared library. With various toolchains it's not possible to conform to the ".node" extension; and even if it's possible in the platform toolchain, it's not possible to get gyp to emit the necessary configuration in the build file. Obviously we could get the project file to emit a library whose name satisfies the usual platform convention - eg libhello.dylib instead of hello.node - and then symlink or copy the file as part of an install phase. But it would be nicer if we didn't have to do that, and could instead get node to recognise a library whose name aligns with the platform default. I know that simply adding a new extension to module.js will increase the size of the search space for modules - which is already excessively big based on the number of paths and extensions to be searched - so we would have to selectively add just the one extension appropriate to the platform (and perhaps not look for .node at all). Any thoughts from the core team? |
https://github.com/mapnik/node-mapnik/blob/gyp/build.gyp has a sample gyp file created by @springmeyer |
Could #2337 offer the desired solution? |
I wonder if you could output a .json or even a .js file which specifies the specific path of the module relative to itself? This would eliminate the need to check for additional file extensions (the node docs say it already is looking for a .json file extension) but would add a bit of process to the .json file handling (to specify the path to the native module). For json it might have a key like "native_modules" with a key for each platform that was compiled tell node where the final binary to load is. If a .js file were output, that file could use require('') or some other method to specify the full path to the correct binary, and it may also use the process.arch and process.platform to figure out the best file to load. The just re-export everything that was export by the binary module as its own. Or possibly say "exports = require('./modulename.dylib') ? |
Also it would be good if you can put pre-build binaries for multiple architectures into the same folder / search path. See #2414 My suggest solution in the previous comment might help with that at the same time. |
Curious to hear about the roadmap for addon building - I've tried to compile the helloworld addon example using Any insights? |
Also, I've noticed that |
@arturadib : can you try this patch: paddybyers@e27fd0f ? The addon.gypi on the mac should work with the make generator, but the above patch should also make it work with the xcode generator. |
gyp_addon will never be a part of the default Please go follow https://github.com/TooTallNate/node-gyp for more exciting updates on this. @TooTallNate Can you please post some relevant details on this issue, and the others linking to it? Thanks. |
@isaacs Thanks for the introduction! So
As @isaacs already said, this module won't be included with node distributions, and instead the module devs and more advanced users are the ones expected to compile the modules, ideally offering precompiled modules for the new users to benefit from. The goal there is lowering the bar needed to start getting into node.js, while ideally not affecting current/advanced users too much (I mean, we were already compiling modules ourselves, so nothing changes there...). But overall, let's get your modules converted over! I have started the process of "driving adoption" by sending pull requests to some of the common native modules, so let's continue the trend! |
P.S. if anybody would like help converting their native module to gyp just give a shout out and I'll give you priority! I'm still trying to prioritize which modules I am attempting to convert; @isaacs a list of the most depended on native node modules would be nice :) |
I am actually trying to convert one. ajaxorg/o3 to be exact |
@gero3 Sure thing. Which one? |
https://github.com/gero3/o3 is what I have for now. latest commit |
@gero3 What you have seems alright to me (not sure about the final
So it seems to me like the module is missing some stuff as-is. Also >40mb download for the repo! Holy moly! |
Ah first, you need to run node tools/node_modules_build which builds the glue files.(even it if fails on node-waf). Sorry about that. PS: I found the verbose option so I'look where the differences in node-waf and node-gyp PS2: https://gist.github.com/1764377 is the output generated from the build |
@TooTallNate Can we close this issue? It seems like the node-gyp stuff is moving along on its own now. |
@isaacs I think that would be appropriate :) |
@TooTallNate ooh look at you all powerful and stuff :) (needless to say, superb work with node-gyp -- it's a keeper) |
No description provided.
The text was updated successfully, but these errors were encountered: