-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from zeromq/postinstall [skip ci]
- Loading branch information
Showing
5 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { execaCommandSync } from "execa"; | ||
import * as buildUtils from "./utils.js"; | ||
const { toString } = buildUtils; | ||
function parserOptions() { | ||
return { | ||
arch: toString(process.env.npm_config_arch) ?? process.arch, | ||
}; | ||
} | ||
async function main() { | ||
const opts = parserOptions(); | ||
console.log("Building distribution binary with options ", opts); | ||
const prebuildArch = getNodearch(opts); | ||
process.env.ARCH = prebuildArch; | ||
process.env.npm_config_arch = prebuildArch; | ||
process.env.npm_config_target_arch = prebuildArch; | ||
process.env.PREBUILD_arch = prebuildArch; | ||
// TODO test the triple feature | ||
if (typeof process.env.TRIPLE === "string") { | ||
const TRIPLE = process.env.TRIPLE; | ||
const GCC = process.env.GCC; | ||
process.env.CC = `${TRIPLE}-gcc-${GCC}`; | ||
process.env.CXX = `${TRIPLE}-g++-${GCC}`; | ||
const STRIP = `${TRIPLE}-strip`; | ||
process.env.PREBUILD_STRIP_BIN = STRIP; | ||
process.env.ZMQ_BUILD_OPTIONS = `--host=${TRIPLE}`; | ||
} | ||
// use the current node version to build the prebuild | ||
// If the distribution for that particular architecture is not available, updated your Node: | ||
// https://nodejs.org/dist/ | ||
const nodeVersion = process.version.replace("v", ""); | ||
let prebuildScript = `prebuildify --napi --arch=${prebuildArch} --strip --tag-libc -t ${nodeVersion}`; | ||
if (typeof process.env.ALPINE_CHROOT === "string") { | ||
prebuildScript = `/alpine/enter-chroot ${prebuildScript}`; | ||
} | ||
execaCommandSync(prebuildScript, { | ||
env: process.env, | ||
shell: true, | ||
windowsHide: true, | ||
stdio: "inherit", | ||
encoding: "utf8", | ||
}); | ||
} | ||
main().catch(e => { | ||
throw e; | ||
}); | ||
function getNodearch(opts) { | ||
switch (opts.arch) { | ||
case "x86": { | ||
return "ia32"; | ||
} | ||
case "x86_64": { | ||
return "x64"; | ||
} | ||
default: { | ||
return opts.arch; | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=prebuild.mjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.