Skip to content

Commit 73e6ad0

Browse files
authored
Merge pull request #633 from zeromq/opts
2 parents ea5f35c + 01e4fe9 commit 73e6ad0

19 files changed

+240
-123
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"script/*.js",
2020
"script/*.d.ts",
2121
"docs/",
22-
"docs-raw/",
22+
"doc-unminified/",
2323
"test/unit/compat/",
2424
"test/bench/"
2525
]

.github/workflows/CI.yml

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ jobs:
2222
- x64
2323
cpp_arch:
2424
- x64
25-
ARCH:
26-
- x64
27-
zmq_draft:
28-
- false
2925
docker:
3026
- ""
3127
docker_cmd:
@@ -34,31 +30,24 @@ jobs:
3430
include:
3531
- os: windows-2022
3632
node_version: 18
37-
node_arch: x86
38-
ARCH: x86
33+
node_arch: ia32
3934
cpp_arch: amd64_x86
40-
zmq_draft: false
4135

4236
# - os: windows-2022
4337
# node_version: 18
4438
# node_arch: x64
45-
# ARCH: arm64
39+
# arch: arm64
4640
# cpp_arch: amd64_arm64
47-
# zmq_draft: false
4841

4942
- os: macos-13
5043
node_version: 18
5144
node_arch: x64
52-
ARCH: x86_64
5345
cpp_arch: x64
54-
zmq_draft: false
5546

5647
- os: macos-14
5748
node_version: 18
5849
node_arch: arm64
59-
ARCH: arm64
6050
cpp_arch: amd64_arm64
61-
zmq_draft: false
6251

6352
# Alpine
6453
- os: ubuntu-22.04
@@ -69,14 +58,14 @@ jobs:
6958
build.prebuild
7059
node_version: 18
7160
node_arch: x64
72-
ARCH: x64
7361
cpp_arch: x64
74-
zmq_draft: false
7562

7663
env:
77-
ZMQ_DRAFT: ${{ matrix.zmq_draft }}
78-
ZMQ_SHARED: false
79-
ARCH: ${{ matrix.ARCH }}
64+
npm_config_zmq_draft: false
65+
npm_config_zmq_shared: false
66+
npm_config_arch: ${{ matrix.node_arch }}
67+
npm_config_target_arch: ${{ matrix.node_arch }}
68+
setup_node_arch: ${{ matrix.node_arch }}
8069
steps:
8170
- uses: actions/checkout@v4
8271

@@ -87,11 +76,17 @@ jobs:
8776
./node_modules/
8877
./build/
8978
key:
90-
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch
91-
}}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version
92-
}}-${{ hashFiles('./package.json') }}"
79+
# prettier-ignore
80+
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch}}-ZMQ_DRAFT:${{env.npm_config_zmq_draft }}-Node:${{ matrix.node_version}}-${{hashFiles('./package.json') }}"
9381
restore-keys: |
94-
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-"
82+
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ env.npm_config_zmq_draft }}-Node:${{ matrix.node_version }}-"
83+
84+
- name: Env map
85+
run: |
86+
if [ "${{ matrix.node_arch }}" = "ia32" ]; then
87+
echo "setup_node_arch=x86" > $GITHUB_ENV
88+
fi
89+
shell: bash
9590

9691
- name: Setup Cpp
9792
if: ${{ !matrix.docker }}
@@ -112,21 +107,20 @@ jobs:
112107
uses: actions/setup-node@v4
113108
with:
114109
node-version: ${{ matrix.node_version }}
115-
architecture: ${{ matrix.node_arch }}
110+
architecture: ${{ env.setup_node_arch }}
116111

117112
- name: Install Mac-OS x86_64 Dependencies
118-
if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'x86_64' }}
113+
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }}
119114
run: |
120115
brew install libsodium gnutls
121116
122117
- name: Install Mac-OS arm64 Dependencies
123-
if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'arm64' }}
118+
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'arm64' }}
124119
run: |
125120
brew uninstall libsodium --force --ignore-dependencies
126121
source ./script/macos-arm-deps.sh
127122
echo "PATH=$PATH" >> $GITHUB_ENV
128123
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
129-
echo "npm_config_target_arch=$npm_config_target_arch" >> $GITHUB_ENV
130124
131125
- name: Install Dependencies and Build
132126
if: ${{ !matrix.docker }}
@@ -155,7 +149,7 @@ jobs:
155149
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
156150
run: pnpm run lint-test
157151

158-
- name: Test (Debug)
152+
- name: Test
159153
if: ${{ !matrix.docker }}
160154
uses: nick-fields/retry@v3
161155
with:

.gitignore

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ build-tmp-napi-v*
1313
test.js
1414
.cache/
1515
test/typings-compatibility/
16-
/script/*.js
17-
/script/*.mjs
16+
/script/*js
1817
/script/*.d.ts
19-
/script/*.d.mts
20-
/script/*.js.map
21-
/script/*.mjs.map
22-
/script/*/*.js
23-
/script/*/*.mjs
24-
/script/*/*.d.ts
25-
/script/*/*.js.map
18+
/script/*.d.*ts
19+
/script/*js.map
2620
tsconfig.tsbuildinfo
27-
tsconfig.esm.tsbuildinfo
28-
/docs-raw
21+
tsconfig.*.tsbuildinfo
22+
/doc-unminified
2923
.DS_Store
3024
.idea

.idea/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.npmrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
public-hoist-pattern[]=*
2-
package-lock=false
3-
lockfile=true
4-
prefer-frozen-lockfile=false
5-
strict-peer-dependencies=false
1+
# Zmq settings
62
build-from-source=true

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/docs/
2-
/docs-raw
2+
/doc-unminified
33
/lib
44
/prebuilds
55
/node_modules

.vscode/settings.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,18 @@
44
"mochaExplorer.nodeArgv": [
55
"--expose-gc"
66
],
7-
"mochaExplorer.debuggerConfig": "JS-Attach"
7+
"mochaExplorer.debuggerConfig": "JS-Attach",
8+
"files.exclude": {
9+
"**/.git": true,
10+
"**/.DS_Store": true,
11+
"**/Thumbs.db": true,
12+
"**/.cache": true,
13+
"**/script/*.js": true,
14+
"**/script/*.mjs": true,
15+
"**/script/*.js.map": true,
16+
"**/script/*.mjs.map": true,
17+
"**/script/*.d.ts": true,
18+
"**/script/*.d.mts": true,
19+
"**/script/*.tsbuildinfo": true,
20+
}
821
}

README.md

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,88 @@ source:
8181
- CMake 2.8+
8282
- curl
8383

84-
To install from source:
84+
To install from source, specify `build_from_source=true` in a `.npmrc` file
8585

86-
```sh
87-
npm install [email protected] --build-from-source
86+
```
87+
build_from_source=true
8888
```
8989

90-
If you want to link against a shared ZeroMQ library, you can build skip
91-
downloading `libzmq` and link with the installed library instead as follows:
90+
When building from source, you can also specify additional build options in a
91+
`.npmrc` file in your project:
9292

93-
```sh
94-
npm install [email protected] --zmq-shared
93+
### Available Build Options
94+
95+
<details>
96+
<summary>👉🏻 Options</summary>
97+
98+
#### Draft support
99+
100+
By default `libzmq` is built with support for `Draft` patterns (e.g.
101+
`server-client`, `radio-dish`, `scatter-gather`). If you want to build `libzmq`
102+
without support for `Draft`, you can specify the following in `.npmrc`:
103+
104+
```ini
105+
zmq_draft=false
95106
```
96107

97-
If you wish to use any DRAFT sockets then it is also necessary to compile the
98-
library from source:
108+
#### Not Synchronous Resolve
99109

100-
```sh
101-
npm install [email protected] --zmq-draft
110+
If you want to send/receive on the socket immediately, you can specify the
111+
following in `.npmrc`:
112+
113+
```ini
114+
zmq_no_sync_resolve="true"
115+
```
116+
117+
#### Shared library support
118+
119+
If you want to link against a shared ZeroMQ library installed on your system,
120+
you can build skip downloading `libzmq` and link with the installed library
121+
instead by specifying the following in `.npmrc`:
122+
123+
```ini
124+
zmq_shared=true
125+
```
126+
127+
#### Alternative libzmq version
128+
129+
You can specify an alternative version or Git revision of `libzmq` to build
130+
against by specifying the following in `.npmrc`:
131+
132+
```ini
133+
zmq_version="4.3.5"
134+
```
135+
136+
#### Debug build of libzmq
137+
138+
If you want to build `libzmq` with debug symbols, you can specify the following
139+
in `.npmrc`:
140+
141+
```ini
142+
zmq_build_type="Debug"
102143
```
103144

145+
#### Cross-compilation for different architectures
146+
147+
If you want to cross-compile for a different architecture, you can specify the
148+
following in `.npmrc`:
149+
150+
```ini
151+
arch="arm64"
152+
target_arch="arm64"
153+
```
154+
155+
#### MacOS Deployment Target
156+
157+
If you want to specify the MacOS deployment target, you can specify the
158+
following in `.npmrc`:
159+
160+
```ini
161+
macos_deployment_target="10.15"
162+
```
163+
164+
</details>
165+
104166
## Examples
105167

106168
**Note:** These examples assume the reader is familiar with ZeroMQ. If you are

binding.gyp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,19 @@
1212
{
1313
'target_name': 'libzmq',
1414
'type': 'none',
15-
16-
'conditions': [
17-
["zmq_shared == 'false'", {
18-
'actions': [{
19-
'action_name': 'build_libzmq',
20-
'inputs': [],
21-
'conditions': [
22-
['OS != "win"', {
23-
'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'],
24-
}],
25-
['OS == "win"', {
26-
'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'],
27-
}],
28-
],
29-
'action': ['node', '<(module_root_dir)/script/build.js'],
15+
'actions': [{
16+
'action_name': 'build_libzmq',
17+
'inputs': [],
18+
'conditions': [
19+
['OS != "win"', {
20+
'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'],
3021
}],
31-
}],
32-
],
22+
['OS == "win"', {
23+
'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'],
24+
}],
25+
],
26+
'action': ['node', '<(module_root_dir)/script/build.js'],
27+
}],
3328
},
3429

3530
{

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
],
8484
"scripts": {
8585
"install": "(npm run build.js || echo ok) && aminya-node-gyp-build --build-from-source",
86-
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
86+
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.mjs ./script/*.js.map ./script/*.mjs.map ./script/*.d.ts ./script/*.d.mts ./script/*.cjs ./scripts/*.cjs.map ./scripts/*.d.cts ./script/*.tsbuildinfo",
8787
"clean.release": "shx rm -rf ./build/Release",
8888
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp",
8989
"build.library": "tsc -p ./src/tsconfig.json",
90-
"build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json",
90+
"build.script": "tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json",
9191
"build.js": "run-p build.script build.library",
92-
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
92+
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-unminified -d docs --jsCompressor terser && shx rm -rf docs-unminified",
9393
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
9494
"build.prebuild": "run-s build.js && node ./script/prebuild.mjs",
9595
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",

0 commit comments

Comments
 (0)