Closed dherman closed 3 years ago
Has there been any progress made on cross-compilation or a manual workaround? Currently looking to build for iOS and Android toolchains from Linux.
The rust side of this is actually pretty easy and works today. Since neon-cli
passes on environment variables, cargo
will respect the TARGET
variable.
Unfortunately, the complexity of cross compiling node-gyp
is where this becomes problematic (required by neon-runtime
). Due to that complexity, I believe that this is blocked by N-API support which will eliminate node-gyp.
There is no timeline for N-API.
https://github.com/neon-bindings/neon/issues/202 https://github.com/neon-bindings/neon/pull/440
http://www.janeasystems.com/blog/support-native-modules-node-js-mobile-apps/ They have a modified node-gyp
Hello,
What is the current status of this feature? Does it exist any workaround as of today, and if not, is there anything we can do to help?
@ShinySaana It's not being worked on. The legacy backend requires node-gyp
which does not easily handle cross compiling.
The good news is that the N-API backend does support cross compiling and only uses cargo
to build.
Try npm init neon my-project
to create a new N-API project.
As my neon project already used N-API, it was a breeze to migrate to the new backend. I just tested it and it worked wonders. Thank you very much for saving me a lot of headaches !
I'm a little confused between the information on the wiki and here. If I create a project today with npm init neon my-project
, can I compile for windows, mac, etc. on linux and how?
@JRedOW Additional arguments to cargo
can be passed after the npm command. npm run build -- --target ...
.
Cross compiling documentation for Rust applies equally to Neon. (At the end it's just a Rust shared library)
@JRedOW Additional arguments to
cargo
can be passed after the npm command.npm run build -- --target ...
.Cross compiling documentation for Rust applies equally to Neon. (At the end it's just a Rust shared library)
Thanks!
@JRedOW if you're looking for an example of cross compilation from macs of a neon project you can check out the Temporal Node.js SDK:
https://github.com/temporalio/sdk-node/blob/main/docs/building.md https://github.com/temporalio/sdk-node/blob/main/.github/workflows/ci.yml#L73
We need an RFC for cross-compilation flags. The design should try to mirror the UX of Cargo as much as possible.