-
Notifications
You must be signed in to change notification settings - Fork 23
Support building Rust addons for Electron #36
Comments
node-gyp's devdir option allows you to point to a specific location to search for node headers. This avoids the shenanigans with the fake-$HOME. Not sure how well it plays with the rest of the npm ecosystem though - it potentially breaks other things. |
@EdShaw Could you point me at an example or web page with more information on devdir? Google is not cooperating at the moment. I found this diff but I haven't found the docs yet. It looks like node-gyp takes a command-line flag, or one of Electron + Neon + Rust + a modern JS stack is a nice dev environment. I'd love to see this be easier to set up. |
Your links are what I referenced. It's a fairly recent addition (3 months); it looks like the changes haven't made it into a release yet. :( Make me wonder how I got it working... I'm trying to update node-gyp to see if it works... I see in your script that you call node-gyp directly, I suspect only --devdir will work in that case (since I don't think it picks up npm env options?). Edit: Ok, this doesn't quite work - npm calls neon build, which in turn calls cargo, which then calls npm; by this point we've dropped --devdir :( . Edit2: Ensuring both are set seems to work (since cargo will pass on npm_config_devdir to npm). Still having issues with electron-rebuild refusing to actually trigger a native build... |
Just a heads-up that we're making progress on this: you can see a simple demo at: https://github.com/dherman/neon-electron-hello It doesn't yet integrate with My next steps are to test on Windows and make sure that's working, and then also to make the tools smarter about rebuilding if someone has accidentally already built a dependency with the wrong ABI. |
https://github.com/dherman/neon-electron-hello not working
It seem that neon is not following the ABI version provided but using the ABI version of node(6.10.2, ABI version 48) that runs it? |
Still would be good to integrate with |
Thank you for building Neon! I've already got a small Rust-based addon in production at work, and it was dead simple to get up and running.
For my own amusement, I've been working on getting Neon to work an Electron app. This is trickier, both because of
node-gyp
issues, and because Neon always assumes it's building packages for the system code of Node.js. Here's how I worked around this.This is for a top-level Electron app project with a
native
subdirectory directly in the main package, and not undernode_modules
.1. Set up environment variables for
node-gyp
Save the following file as
.env.sh
in the top level of the project:2. Run the Rust build manually with a fake
$HOME
What would it take to support this reasonably in standard Neon?
The most important fixes would be something like:
neon build
#28This would allow me to replace the ugly
case
statement with a normalneon build
call, which would be a clear improvement.I'm less sure that Neon should touch any of the
node-gyp
stuff. Some of this is handled by electron-rebuild for regular Node addons, and there might be some way to tie into that system. Or not.Anyway, because everybody loves screenshots:
That shows the Neon-based addon being loaded into both the
main
andrenderer
process of Electron. It works! The full application is here.The text was updated successfully, but these errors were encountered: