In order to try to help match up the interest with the work, I'm going
to start occasionally making requests for help in specific areas where
I think improvements need to be made. In the past, these kinds of
calls have been very productive.
You don't need permission. Just play around with the problem, and if
you make some headway, share it with the rest of the group. If you
find it's something you really can get excited about, then maybe it
can be your thing :)
A very problematic area right now is binary module compilation across
platforms, especially on Windows.
In the past, we've deployed a node-waf program, which is a
lightly-customized fork of the "waf" build tool. This program has
worked ok, but it is fundamentally non-portable, and my hope is that
it will not have to be in 0.8.
In the node source tree is a file called tools/gyp_addon. You can use
this to generate either a Makefile, or the appropriate MS Visual C
stuff to build an addon. There are some examples in test/addons/, but
the whole process is not very well documented, and requires a lot of
manual tweaking.
To make matters even more hairy, there are a bunch of node programs
floating around in the wild that are using node-waf. We need to make
it as easy as possible to port these to a better future.
The goal:
There should be a standalone `npm install addon-gyp-toolchain -g` or
something (probably ought to pick a better name) that sets up some
scripts. If you have this toolchain installed, we'll assume that you
also have "make" on unix, and Visual Studio on Windows. If you then
run the appropriate command in a project directory, it'll build an
addon using whichever method is appropriate for the current system.
Once such a thing is in place, and it works reliably on Windows and
Unix, and is pretty easy and generalized, start making pull requests
to everybody to replace their wscripts with a gyp file.
The most important thing is that it makes the process easier than it
is today. There's probably more API design, debugging, and picking
through bits, than actually writing new code.
And, of course, it could be that my vision of this is way off. Your
task should be to make it easier to compile a bunch of C code into a
.node addon file in a way that works on Windows and Unix, and doesn't
completely suck. Don't be afraid to get creative.
Why not just deploy gyp_addon with node? Because that would be
recreating the node-waf experience, which is terrible. This is a step
towards binary deployments (at least for operating systems and
platforms that can do such things reliably). It would not be terrible
to install it when node is configured with --debug or something, but
by default the msi and pkg installers should never include gyp. Users
who *want* install-time compilation will always be able to do this by
installing the toolchain and then opting out of binary builds.
Thanks for your help.
Problem 1 is indeed a problem, but it can be solved in 2 ways.
1. If you have the toolchain installed, you'll be able to build at
install time, just like you do today with node-waf, so there's a
fallback.
2. We'll build some cloudy buildbot CI stuff to compile all the things.
Node-bindings could definitely be handy.
> So that leaves problem #1. I like the "addon-gyp-toolchain" module idea. I
> hadn't considered that before, and that should help, though I'm not exactly
> sure how it would work (currently Windows addons require the node source
> tree, so that would need to be fixed I guess).
Any addon build would require the node source tree, or at least the headers.
Like I said, lots of fiddly little bits to get all in a row, probably
some core changes, etc. But, this should happen mostly independent of
any changes in node itself.
> I'm still envisioning some kind of Travis-CI-like cloud-based build system,
> that would receive a git-hook and recompile your module on the various
> platforms/archs and commit them back to your repo (or something), whenever a
> change happened in the `src` dir. If that was done right, it would make it
> painless for both the devs and the uses of the module.
Yes, but it should be based on publishes, and attach the tarball to
the package in the registry tagged with the appropriate platform
indicators.
I've written a small module that attempts to solve #2 and #3, called node-bindings: https://github.com/TooTallNate/node-bindings
There is no stable C++ ABI, so you will also have to add the compiler version as another argument to that list of targets. Some compilers do try to do versioning with mapfiles, but it is rarely used. The worst thing that can happen is having a version of node built with one version of a compiler and an addon with another.
"I already wrote a little binding C++ thing for node, and now I want
to compile a .node file." Start with the example in node's
test/addons/hello-world.
Right now, that is unnecessarily difficult, and I believe it's a good
sized problem to tackle. How would you make it trivial to do that?
On Thu, Feb 2, 2012 at 00:58, Nathan Rajlich <nat...@tootallnate.net> wrote:
> The compiler used *may* be another paramater to consider, but I haven't ran
> into any problems in use with node-bindings yet. One issue getting the
> compiler name is that it's not available in node anywhere, so getting that
> value at runtime would be hard/impossible.
>
>
> On Wed, Feb 1, 2012 at 6:38 PM, Robert Mustacchi <r...@fingolfin.org> wrote:
>>
>> On 02/01/2012 04:52 PM, Isaac Schlueter wrote:
>>>
>>> On Wed, Feb 1, 2012 at 16:15, Nathan Rajlich<nat...@tootallnate.net>
>>> wrote:
>>>>
>>>> Devs have to now compile for each supported platform and architecture
>>>> before
>>>> publishing
>>>
>>>
>>> Problem 1 is indeed a problem, but it can be solved in 2 ways.
>>>
>>> 1. If you have the toolchain installed, you'll be able to build at
>>> install time, just like you do today with node-waf, so there's a
>>> fallback.
>>> 2. We'll build some cloudy buildbot CI stuff to compile all the things.
>>>
>>> Node-bindings could definitely be handy.
>>
>>
>> There is no stable C++ ABI, so you will also have to add the compiler
>> version as another argument to that list of targets. Some compilers do try
>> to do versioning with mapfiles, but it is rarely used. The worst thing that
>> can happen is having a version of node built with one version of a compiler
>> and an addon with another.
>>
>> Robert
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
I'm not sure what else it would need off the top of my head. Thoughts?
As has been mentioned, the module build system needs the node headers. (That much seems unavoidable for native modules.). But which *version* of the headers? I would not expect the build system to figure this out, but I would like to be able to specify which version(s) of node to build against, limited only by the module metadata specifying which node version a module promises to support.
Currently we have several modules that have to be built and coexist as available for use from the same directory from multiple Node versions (daemon and node-fork). Right now we have a install script and runtime detection handling this, but it would be nice if package.json or NODE_PATH were a little cleaner and allowed us to specify what to pull at specific versions in instead of sharing the same compiled module filename for multiple ABIs and forcing runtime detection.
--
The readme doesn't mentioning actually creating a gyp file. You still
have to do that, right? It'd be nice to document what it should look
like.
Wow, that looks really cool.
The readme doesn't mentioning actually creating a gyp file. You still
have to do that, right? It'd be nice to document what it should look
like.
--
I think you guys are reinventing the wheel here with respect to building addons. Gyp and CMake were create specifically so you don't need to roll your own system. Maybe it is just me but I liked the fact that node-waf came bundled with the node install. This meant that I didn't have to go fetch any additional packages or items to build the addon.
I will also add that I am against shipping binary addons. The number of "parameters" you could be pivoting on is too great imho. If someone has a system in place to deploy binaries (deb, rpm, etc) I would think they should use that. Otherwise compiling these small addons for deployment is not that big a deal is it? I would be hesitant on a binary solution until someone can prove to me anyone would actually care to use it in a meaningful way. Right now, I just always build when I deploy and that works fine. The benefit here is that build time failure is much preferred to run time failure.
That's a good idea regardless, actually. Commit the node_modules
folder, and list all the deps as bundledDependencies.
node-gyp is a command line tool, not something you'd expect to
require(). Like npm itself, it should be a single thing that works
out of the box.
On Fri, Feb 10, 2012 at 12:35 PM, Roman Shtylman <shty...@gmail.com> wrote:I think you guys are reinventing the wheel here with respect to building addons. Gyp and CMake were create specifically so you don't need to roll your own system. Maybe it is just me but I liked the fact that node-waf came bundled with the node install. This meant that I didn't have to go fetch any additional packages or items to build the addon.I don't really see your concern here. We're attempting to do the same thing with gyp as we did with waf, by providing a light wrapper around its basic usage to help simplify the necessary gyp file module devs need to create (same as the wscript file before). The only difference so far is that instead of being bundled with node, you have to `npm install -g node-gyp` to get it. As isaacs said at the beginning of this thread, we only want more advanced/comfortable users compiling, so once new users are ready, they can install node-gyp. While they're still new, they can rely on precompiled binaries (same situation with the precompiled binaries officially offered for node: I don't use them since I'm "advanced", but they're wonderful for new user adoption).
I will also add that I am against shipping binary addons. The number of "parameters" you could be pivoting on is too great imho. If someone has a system in place to deploy binaries (deb, rpm, etc) I would think they should use that. Otherwise compiling these small addons for deployment is not that big a deal is it? I would be hesitant on a binary solution until someone can prove to me anyone would actually care to use it in a meaningful way. Right now, I just always build when I deploy and that works fine. The benefit here is that build time failure is much preferred to run time failure.The way I see it, nobody is forcing you to use any precompiled binaries. There is always still the source code and installing node-gyp is a one-line command, so just like node itself, more advanced users are probably going to stick with compiling their native addons themselves, which is perfectly fine in my opinion. npm could even offer a flag where it would compile locally on the 'install' phase instead of downloading a precompiled binary, much like the node-waf situation now.As said in the last paragraph, these precompiled binaries will mostly be for the benefit of new users (especially Windows users) where they may not even have a compilation toolchain installed (also especially true for OS X users who rely on the installer, and don't have XCode installed). But for a more advanced user like yourself, the only change in your workflow will probably be invoking node-gyp instead of node-waf at build-time.