Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Update to N-API #5

Open
strophy opened this issue Jul 21, 2021 · 0 comments
Open

Update to N-API #5

strophy opened this issue Jul 21, 2021 · 0 comments

Comments

@strophy
Copy link

strophy commented Jul 21, 2021

I am trying to build bindings from this repo for arm64 architecture. The current native directory uses Neon syntax prior to their implementation of N-API. This means C components are also required, adding a dependency on node-gyp and (for convenience) node-gyp-cache. node-gyp-cache conceals some necessary output required by neon-sys, resulting in the following error during a normal build:

error: failed to run custom build command for `neon-sys v0.8.3`

Caused by:
  process didn't exit successfully: `/home/ubuntu/node-merk/native/target/debug/build/neon-sys-c14806bb7b8207f1/build-script-build` (exit status: 101)
  --- stdout
  Skipping node-gyp installation as part of npm install.
  added 98 packages from 73 contributors and audited 98 packages in 2.395s

  3 packages are looking for funding
    run `npm fund` for details

  found 0 vulnerabilities


  --- stderr
  thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/neon-sys-0.8.3/build.rs:99:65
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
neon ERR! cargo build failed

Building is still possible without node-gyp-cache, but is painfully slow (particularly in an emulator). Updating to N-API removes the dependency on C components, meaning ARM builds can work successfully again. It also has the additional benefit of no longer requiring separate prebuilds for each supported version of Node, further reducing the size of the package. Documentation on how to migrate to N-API is here: https://github.com/neon-bindings/neon/blob/main/MIGRATION_GUIDE.md

If this is a simple change, I am happy to give it a try and maybe learn some Rust in the process, but I would need a few pointers to get started...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant