neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
8k stars 283 forks source link

Copying binaries when neon package is not a root package in conjunction with cross. #975

Closed nkozheninEvinced closed 1 year ago

nkozheninEvinced commented 1 year ago

Hello, I have a problem with cargo-cp-artefact. So, when the time comes to copy the artefact from target to prebuilds I stambled upon this problem:

[Error: ENOENT: no such file or directory, copyfile 'C:\target\x86_64-unknown-linux-gnu\debug\liba11y_validator_node.so' -> 'C:\Users\<username>\Desktop\work\<projectname>\<path>\<inner package>\prebuilds\linux-x64\node.napi.node']

I am using cross-rs to build Linux binary on Windows.

Any ideas how to solve that?

nkozheninEvinced commented 1 year ago

Nevermind, I added an option to pass a target location, let me know if you want a PR

kjvalencik commented 1 year ago

cargo-cp-artifact reads the location of the path directly from the emitted JSON. It shouldn't be necessary to change the path. If the Neon package isn't root in the project, it shouldn't matter because the paths that cargo emits are absolute.

Is this because cross is emitting the path from inside a docker container, but cargo-cp-artifact is running outside the container and the paths don't match?

nkozheninEvinced commented 1 year ago

Yes, that's right. cargo-cp-artifact indeed ran outside of container. In the end I even scrapped passing an option to cargo-cp-artifact and decided that writing a custom solution for copying binaries would be easier

kjvalencik commented 1 year ago

That's reasonable! The only thing cargo-cp-artifact does is copy files. The reason it exists is because there's no one place that the binary might end up and we wanted it to work out of the box for everyone.

Ideally cargo would have this functionality built in.