New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prebuild and publish binaries #63
Conversation
I recommend using |
Interesting, why? For my specific case, prebuild seems better. I want to avoid having binaries for the wrong OS present, and it seems like prebuildify would always include all targets. I want to avoid that because I have a check during packaging to catch binaries for the wrong platform, which is useful to spot cases where one of my cross-installs fail somehow. It would also result in extra files in my end distributable that aren't necessary. Not huge or unfixable problems, but from my POV prebuild neatly avoids them. I can completely believe that that might not apply for everybody though. If prebuildify is a big improvement for normal cases then that makes sense, I can just continue using my fork instead. I do agree it would be nice to do NAPI-specific builds either way, although AFAICT we could do that with prebuild too. |
We (folks from the prebuild org) should write a FAQ 😃. For now read this thread: atom/node-keytar#255 |
Ok, so I'll summarize the comparison with prebuild from that thread and Level/leveldown#482, let me know if I've got the details wrong anywhere, or if there's anything missing: Upsides:
Downsides:
Is that all about right? I'll let @addaleax make the call before I update anything, but it seems like a nice improvement to me. Happy to switch to whichever works best. |
Another downside (but one that can be solved): lacks integration with tools like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pimterry Ultimately, I’m happy with either solution and just glad that somebody did the work to make this happen. :)
Dropping Node 6 is a semver-major change, yes. Assuming that you’re okay with that, I’ll publish a new major release of node-ffi-napi after merging this?
Preferably because it: - Simplifies and (probably) speeds up user installs - Doesn't require reinstalls when switching targets - Drops the install-time dependency on GitHub - Includes the built binaries in the npm package checksum
@addaleax @vweevers I've now migrated this to prebuildify. A couple of notes:
I've done a test publish as |
"ref-array-di": "^1.2.1" | ||
}, | ||
"scripts": { | ||
"install": "node-gyp-build", | ||
"prebuild": "prebuildify --napi", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add --strip
(strip symbols) to shave off a few bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d prefer not to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so? Just curious, I personally don't care about prebuild and thus package size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes debugging harder, and it’s most likely not saving a lot of space given that this isn’t a large addon to begin with. But mostly I’d like to have a decent debugging experience, because this is the kind of addon that people are bound to make crash… 😄
Excellent. I'll give that a try on an electron project |
I tried out |
I’ll update ref-napi with something along the lines of this for node-ffi-napi/ref-napi#27, then see that I get this published :) |
Published in |
Amazing, thanks! 👍 🎉 |
This PR builds binaries for Windows/OSX/Linux and publishes them to github releases, for all tagged commits. Subsequent npm installs of ffi-napi will check github releases for a tag matching the package version, and download & use a compatible prebuilt binary if present, or build from scratch like normal if not.
This fixes #32.
Prebuilt binaries are useful because they mean you can use this without having a full build environment set up locally, and (important for my case) you can easily cross-install a package, i.e.
npm install ffi-napi
on Linux, but using$npm_config_platform
to install the Windows binaries. In my case, this lets me build & package my Windows distributable on a Linux machine.This builds on top of #49, and the NYC update I mentioned in the comments there, mainly because I needed that for my use case. The commits after 'Merge branch...' here are the relevant ones for prebuilding. Once that PR is merged we can rebase and clean this up.
I'm not totally sure if you'll want this, but I needed it for myself anyway. If not I'll continue using my fork with prebuilds included, but I'd prefer to upstream it!
I've done a test publish of this as
@httptoolkit/ffi-napi
which you can test out. You can see the published binaries for that here: https://github.com/httptoolkit/node-ffi-napi/releases.Notably, this:
Doesn't completely solve the build problem, because ref-napi also requires a build step.Fixed by Prebuild and publish binaries ref-napi#27PREBUILD_GITHUB_TOKEN
to be set for Appveyor & Travis the CI builds, with a Github token that has permission to publish binaries.