Skip to content

Commit

Permalink
Merge pull request #525 from zeromq/absolute-paths [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Nov 16, 2022
2 parents 55dc6d7 + cc7fd97 commit a1353ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
16 changes: 8 additions & 8 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
["zmq_shared == 'false'", {
'actions': [{
'action_name': 'build_libzmq',
'inputs': ['package.json', './script/build.ts'],
'inputs': ['<(module_root_dir)/package.json', '<(module_root_dir)/script/build.ts'],
'conditions': [
['OS != "win"', {
'outputs': ['build/libzmq/lib/libzmq.a', 'build/libzmq/include/zmq.h', 'build/libzmq/include/zmq_utils.h'],
'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.a', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
}],
['OS == "win"', {
'outputs': ['build/libzmq/lib/libzmq.lib', 'build/libzmq/include/zmq.h', 'build/libzmq/include/zmq_utils.h'],
'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.lib', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
}],
],
'action': ['ts-node', '<(PRODUCT_DIR)/../../script/build.ts'],
'action': ['ts-node', '<(module_root_dir)/script/build.ts'],
}],
}],
],
Expand All @@ -46,7 +46,7 @@

'include_dirs': [
"vendor",
'<(PRODUCT_DIR)/../libzmq/include',
'<(module_root_dir)/build/libzmq/include',
"<!@(node -p \"require('node-addon-api').include\")"
],

Expand Down Expand Up @@ -76,20 +76,20 @@
'conditions': [
['OS != "win"', {
'libraries': [
'<(PRODUCT_DIR)/../libzmq/lib/libzmq.a',
'<(module_root_dir)/build/libzmq/lib/libzmq.a',
],
}],

['OS == "mac"', {
'libraries': [
'<(PRODUCT_DIR)/../libzmq/lib/libzmq.a',
'<(module_root_dir)/build/libzmq/lib/libzmq.a',
'-lsodium',
],
}],

['OS == "win"', {
'libraries': [
'<(PRODUCT_DIR)/../libzmq/lib/libzmq',
'<(module_root_dir)/build/libzmq/lib/libzmq',
'ws2_32.lib',
'iphlpapi',
],
Expand Down
19 changes: 11 additions & 8 deletions script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function main() {
const libzmq_build_prefix = `${root}/build/libzmq-staging`
const libzmq_install_prefix = `${root}/build/libzmq`

const artifact = `${libzmq_build_prefix}/lib/libzmq.${
const installed_artifact = `${libzmq_install_prefix}/lib/libzmq${
process.platform === "win32" ? ".lib" : ".a"
}`

Expand Down Expand Up @@ -44,23 +44,26 @@ function main() {
mkdir("-p", libzmq_build_prefix)
cd(libzmq_build_prefix)

if (existsSync(artifact)) {
console.log("Found previously built libzmq; skipping rebuild...")
if (existsSync(installed_artifact)) {
console.log(
`Skipping rebuild, found previously built libzmq at ${installed_artifact}`,
)
return
}

const execOptions = {fatal: true}

if (existsSync(tarball)) {
console.log("Found libzmq source; skipping download...")
} else {
console.log(`Downloading libzmq source from ${src_url}`)
exec(`curl "${src_url}" -fsSL -o "${tarball}"`)
exec(`curl "${src_url}" -fsSL -o "${tarball}"`, execOptions)
}

if (!existsSync(src_dir)) {
exec(`tar xzf "${tarball}"`)
exec(`tar xzf "${tarball}"`, execOptions)
}

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
if (process.env.ZMQ_DRAFT === "true") {
console.log("Enabling draft support")
build_options += " -DENABLE_DRAFTS=ON"
Expand All @@ -76,11 +79,11 @@ function main() {

const cmake_configure = `cmake -S "${src_dir}" -B ./build ${build_options} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX="${libzmq_install_prefix}" -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_STATIC=ON -DBUILD_TESTS=OFF -DBUILD_SHARED=OFF -DWITH_DOCS=OFF`
console.log(cmake_configure)
exec(cmake_configure)
exec(cmake_configure, execOptions)

const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install`
console.log(cmake_build)
exec(cmake_build)
exec(cmake_build, execOptions)

if (process.platform === "win32") {
// rename libzmq-v143-mt-s-4_3_4.lib to libzmq.lib
Expand Down

0 comments on commit a1353ea

Please sign in to comment.