Skip to content

Commit 73ef2dc

Browse files
committed
Build reliability improvements
1. Don't skip tsc on install script. Previously, if `script/build.js` exists, we would skip the C++ build. 2. Fix issue with github tags if ZMQ version provided as semver. (github seems to normalize tarballed directory name by stripping leading `v` from tag) 3. Build scripts before node-gyp. Build library wrappers after.
1 parent 8fdf3cb commit 73ef2dc

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,22 @@
7979
"tsconfig.json"
8080
],
8181
"scripts": {
82-
"install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build",
83-
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
82+
"preinstall": "run-s build.script",
83+
"install": "node-gyp-build",
84+
"prepare": "run-s build.library",
85+
"clean": "shx rm -rf ./build ./lib/ ./prebuilds",
8486
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep",
8587
"build.library.compat": "shx rm -rf ./lib/ts3.7 && downlevel-dts ./lib ./lib/ts3.7 --to=3.7",
8688
"build.library": "tsc -p ./src/tsconfig.json && run-s build.library.compat",
8789
"build.script": "tsc -p ./script/tsconfig.json",
8890
"build.js": "run-p build.script build.library",
8991
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
9092
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
91-
"prebuild": "run-s build.js && node ./script/prebuild.js",
93+
"prebuild": "node ./script/prebuild.js",
9294
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",
9395
"build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
94-
"build": "run-s build.js build.native",
95-
"build.debug": "run-s build.js build.native.debug",
96+
"build": "run-s build.native",
97+
"build.debug": "run-s build.native.debug",
9698
"test.deps": "cd test && pnpm install && cd ..",
9799
"test": "run-s test.deps build && mocha --exit",
98100
"test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
@@ -104,8 +106,7 @@
104106
"lint.eslint": "pnpm run lint-test.eslint --fix",
105107
"lint": "run-p lint.eslint lint.clang-format",
106108
"lint-test": "run-s lint-test.eslint",
107-
"bench": "node --expose-gc test/bench",
108-
"prepublishOnly": "pnpm run build.js"
109+
"bench": "node --expose-gc test/bench"
109110
},
110111
"keywords": [
111112
"zeromq",

script/build.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {mkdir, cd, exec, find, mv} from "shelljs"
55
const root = dirname(__dirname)
66

77
function main() {
8-
const zmq_rev =
9-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
10-
process.env.ZMQ_VERSION || "5657b4586f24ec433930e8ece02ddba7afcf0fe0"
11-
const src_url = `https://github.com/zeromq/libzmq/archive/${zmq_rev}.tar.gz`
8+
// Revision to use. Can be a version number like "4.3.5", a branch name, or a commit hash.
9+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
10+
const zmq_rev = process.env.ZMQ_VERSION || "4.3.5"
1211

12+
// if it looks like a dot-separated version number, prepend with "v" to match repo tagging convention
13+
const gitref = zmq_rev.match(/^\d+\./) ? `v${zmq_rev}` : zmq_rev
14+
const src_url = `https://github.com/zeromq/libzmq/archive/${gitref}.tar.gz`
1315
const libzmq_build_prefix = `${root}/build/libzmq-staging`
1416
const libzmq_install_prefix = `${root}/build/libzmq`
1517

0 commit comments

Comments
 (0)