Skip to content

Commit

Permalink
Fix the darn build!
Browse files Browse the repository at this point in the history
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.
4. Remove questionable npmrc
5. Switch to standard node-gyp-build. Modified version tends to hang on failure instead of crash.
  • Loading branch information
rotu committed Jun 14, 2024
1 parent e0c9853 commit 5559b19
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
6 changes: 0 additions & 6 deletions .npmrc

This file was deleted.

1 change: 1 addition & 0 deletions .prototools
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm = "~8"
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
},
"homepage": "http://zeromq.github.io/zeromq.js/",
"dependencies": {
"@aminya/node-gyp-build": "4.5.0-aminya.5",
"cross-env": "^7.0.3",
"node-addon-api": "^7.0.0",
"node-gyp-build": "^4.5.0",
"shelljs": "^0.8.5",
"shx": "^0.3.4"
},
Expand Down Expand Up @@ -79,7 +79,9 @@
"tsconfig.json"
],
"scripts": {
"install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build",
"preinstall": "run-s build.script",
"install": "node-gyp-build",
"prepare": "run-s build.library",
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep",
"build.library.compat": "shx rm -rf ./lib/ts3.7 && downlevel-dts ./lib ./lib/ts3.7 --to=3.7",
Expand All @@ -88,11 +90,11 @@
"build.js": "run-p build.script build.library",
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
"prebuild": "run-s build.js && node ./script/prebuild.js",
"prebuild": "node ./script/prebuild.js",
"build.native": "node-gyp configure --release && node-gyp build --release",
"build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
"build": "run-s build.js build.native",
"build.debug": "run-s build.js build.native.debug",
"build": "run-s build.native",
"build.debug": "run-s build.native.debug",
"test": "run-s build && mocha --exit",
"test.skip_gc_tests": "run-s build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
"test.electron.main": "run-s build && electron-mocha",
Expand All @@ -102,8 +104,7 @@
"lint.eslint": "pnpm run lint-test.eslint --fix",
"lint": "run-p lint.eslint lint.clang-format",
"lint-test": "run-s lint-test.eslint",
"bench": "node --expose-gc test/bench",
"prepublishOnly": "pnpm run build.js"
"bench": "node --expose-gc test/bench"
},
"keywords": [
"zeromq",
Expand Down
15 changes: 6 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const root = dirname(__dirname)
function main() {
const zmq_rev =
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
process.env.ZMQ_VERSION || "20de92ac0a2b2b9a1869782a429df68f93c3625e"
const src_url = `https://github.com/zeromq/libzmq/archive/${zmq_rev}.tar.gz`
process.env.ZMQ_VERSION || "4.3.5"

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

Expand Down
2 changes: 1 addition & 1 deletion src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* Declare all native C++ classes and methods in this file. */
const path = require("path")
module.exports = require("@aminya/node-gyp-build")(path.join(__dirname, ".."))
module.exports = require("node-gyp-build")(path.join(__dirname, ".."))

/**
* The version of the ØMQ library the bindings were built with. Formatted as
Expand Down

0 comments on commit 5559b19

Please sign in to comment.