neon-bindings / rfcs

RFCs for changes to Neon
Apache License 2.0
14 stars 9 forks source link

`neon build --target` #16

Closed dherman closed 3 years ago

dherman commented 6 years ago

We need an RFC for cross-compilation flags. The design should try to mirror the UX of Cargo as much as possible.

cgdusek commented 5 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.

kjvalencik commented 5 years ago

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

cgdusek commented 5 years ago

http://www.janeasystems.com/blog/support-native-modules-node-js-mobile-apps/ They have a modified node-gyp

ShinySaana commented 3 years ago

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?

kjvalencik commented 3 years ago

@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.

ShinySaana commented 3 years ago

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 !

JRedOW commented 3 years ago

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?

kjvalencik commented 3 years ago

@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 commented 3 years ago

@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!

bergundy commented 3 years ago

@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