prebuild-cmake v7.4.7
prebuild
A command line tool for easily making prebuilt binaries for multiple versions of Node.js, Electron and NW.js on a specific platform.
$ npm install -g prebuildFeatures
- Builds native modules for any version of Node.js, Electron or NW.js, without having to switch between different versions to do so. This works by only downloading the correct headers and telling
node-gypto use those instead of the ones installed on your system. - Upload (
--upload) prebuilt binaries to GitHub. - Support for stripping (
--strip) debug information. Strip command defaults tostripbut can be overridden by theSTRIPenvironment variable. - Install prebuilt modules via
prebuild-install.
Building
Building is only required for targets with different ABI versions. To build for all supported ABI versions (example from leveldown):
prebuild --allSupported ABI versions may change over time without a new prebuild release.
Alternatively, to build for some specific versions you can do:
prebuild -t 0.10.42 -t 0.12.10 -t 4.3.0To build against Electron headers, do:
prebuild -t 1.4.10 -r electronTo build against NW.js headers, do:
prebuild -t 0.26.6 -r node-webkitSee allTargets for all available versions.
For more options run prebuild --help. The prebuilds created are compatible with node-pre-gyp
If you'd like to include other files with your prebuilds like additional
.node files or other native libraries, you can pass a file-matching regular
expression to --include-regex:
prebuild -t 8.0.0 --include-regex "\.(node|a)$"Note that if you include multiple .node files, you will need to use the
prebuild-install's --binary-name parameter to indicate which file should be
loaded:
prebuild-install --binary-name main-binary.nodeThe build file format is selected automatically by node-gyp, however it is possible to specify needed format explicitly with --format parameter.
This is particularly useful if unusual flavor is required, which could be specified in 'format-flavor' form
(there is no comprehensive list of formats/flavors available so one has to find possible combinations from node-gyp source code).
For example, in order to build using Makefiles but assume Android cross-compilation:
prebuild --format make-androidUploading
prebuild supports uploading prebuilds to GitHub releases. If the release doesn't exist, it will be created for you. To upload prebuilds simply add the -u <github-token> option:
$ prebuild --all -u <github-token>If you don't want to use the token on cli you can put it in ~/.prebuildrc:
upload=<github-token>Note that --upload will only upload the targets that was built and stored in ./prebuilds, so prebuild -u <github-token> -t 4.3.0 will only upload the binary for the 4.3.0 target.
You can use prebuild --upload-all to upload all files from the ./prebuilds folder.
Create GitHub Token
A GitHub token is needed for two reasons:
- Create a GitHub release (leveldown example)
- Upload the prebuilt binaries to that release
To create a token:
- Go to this page
- Click the
Generate new tokenbutton - Give the token a name and click the
Generate tokenbutton, see below

The default scopes should be fine.
Help
$ prebuild -h
prebuild [options]
--target -t version (version to build or install for)
--runtime -r runtime (Node runtime [node, electron or node-webkit] to build or install for, default is node)
--all (prebuild for all known abi versions)
--upload -u [gh-token] (upload prebuilds to github)
--upload-all -u [gh-token] (upload all files from ./prebuilds folder to github)
--preinstall -i script (run this script before prebuilding)
--precompress -c script (run this script before compression)
--path -p path (make a prebuild here)
--include-regex (regex to match files that will be distributed [default: '\.node$'])
--libc (use provided libc rather than system default)
--backend (specify build backend, default is 'node-gyp')
--strip (strip debug information)
--debug (set Debug or Release configuration)
--verbose (log verbosely)
--version (print prebuild version and exit)JavaScript API
var prebuild = require('prebuild').build(opts, version, cb)
Options:
.log(optional).preinstall(optional).gypProvide a customnode-gypinstance (optional).backendProvide a customnode-gypinstance via string. Alternatives are'node-gyp','node-ninja'and'nw-gyp'(optional, defaults to'node-gyp').argsAdditional command line arguments tonode-gyp(optional).debugPass in--debugon command line to gyp backend (optional)
Example:
prebuild.build({}, version, function (err) {
// ...
})Global options:
.debugDownload or build a debug build (default:false).archProcessor architecture (default:process.arch)
Develop prebuild
If you want to hack on prebuild you need an environment to play around with. We recommend a setup similar
to the following:
- A fork of
prebuild - A GitHub token (see above)
- A native node module
$ git clone git@github.com:<your-nick>/prebuild
$ cd prebuild && npm link && cd ..
$ git clone git@github.com:<your-nick>/some-native-moduleSince you did npm link on prebuild it will be installed globally. Now you can go ahead and try things out.
$ cd some-native-module
$ prebuild --all --strip -u <github-token>This command would:
- Build
some-native-modulefor all supported targets and store them in./prebuilds/ - Strip binaries from debug information
- Create a release on GitHub, if needed
- Upload all binaries to that release, if not already uploaded
Before you commit your changes and send us a pull request, do run npm test.
License
MIT