Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build zeromqjs with CMake and vcpkg #665

Merged
merged 31 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1fa27ae
feat: build zeromqjs with CMake and vcpkg
aminya Nov 13, 2022
8e94fc2
ci: install ninja in CI
aminya Oct 20, 2024
640900f
build: set CMAKE_HOST_SYSTEM_PROCESSOR for windows + vcpkg deps
aminya Oct 20, 2024
aa6748d
build: target Node 12 when building
aminya Oct 20, 2024
0650fb0
fix: fix windows linker flags + use node 18 for MacOS 14
aminya Oct 20, 2024
2d1ea57
ci: fix the build paths in CI
aminya Oct 20, 2024
e609c82
build: set the 32 bit platform for Windows
aminya Oct 20, 2024
53fca4c
ci: install ninja via ninja-build on Alpine
aminya Oct 20, 2024
aa0c4b8
ci: use a named config for Windows 32 build
aminya Oct 20, 2024
6886495
fix: add postinstall script for testing addons
aminya Oct 20, 2024
b537d66
fix: check-in lib/load-addon.js
aminya Oct 20, 2024
0a79fca
ci: add ninja exe to the path on alpine
aminya Oct 20, 2024
d0b2dba
fix: enable compile-commands.json
aminya Oct 20, 2024
d0360af
fix: add clang-tidy
aminya Oct 20, 2024
207e789
build: avoid windows toolchain inclusion on windows 32 build
aminya Oct 20, 2024
ebd6ae8
fix: prefer newer abis when loading
aminya Oct 20, 2024
03b15ae
fix: use the execPath when building the native addon
aminya Oct 20, 2024
9779870
build: set the system host processor on Windows
aminya Oct 20, 2024
6c63384
ci: target node 14 for alpine
aminya Oct 20, 2024
5b0a4ef
feat: add CMake/npm options for Curve, Draft, Sodium, Websockets
aminya Oct 20, 2024
e019f28
feat: support build_from_source config in npmrc
aminya Oct 20, 2024
fc1d0cf
ci: use Node 20 as the modern target in addition to node 12
aminya Oct 20, 2024
910a82d
fix: better error messages in case failure to load
aminya Oct 20, 2024
87f6994
fix: fix resolve loading issue on windows
aminya Oct 20, 2024
f1d0438
ci: cache the staging folder instead of build
aminya Oct 20, 2024
17428f7
fix: display the error stack in load-addon
aminya Oct 21, 2024
f7f6356
fix: add windows delay hook code
aminya Oct 21, 2024
526eb88
fix: use static linking for vcpkg on Windows
aminya Oct 21, 2024
86c6bbd
ci do not cache staging dir
aminya Oct 21, 2024
9f4463b
fix: rename option to macosx_deployment_target
aminya Oct 21, 2024
a76e464
fix: fix windows x86 cross-compilation
aminya Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignAfterOpenBracket: "DontAlign"
AlignConsecutiveAssignments: "None"
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignOperands: "DontAlign"
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: "Never"
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: "AllIfsAndElse"
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: "Yes"
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: NonAssignment
Expand Down Expand Up @@ -64,6 +64,7 @@ SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
RemoveSemicolon: true

IncludeBlocks: Regroup
IncludeCategories:
Expand Down
12 changes: 12 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Checks:
"*, -abseil-*, -altera-*, -android-*, -fuchsia-*, google-*,
-google-runtime-int, -llvm*, -modernize-use-trailing-return-type, -zircon-*,
readability-else-after-return, readability-static-accessed-through-instance,
readability-avoid-const-params-in-decls,
cppcoreguidelines-non-private-member-variables-in-classes,
misc-non-private-member-variables-in-classes,
-*-non-private-member-variables-in-classes,-misc-include-cleaner"
WarningsAsErrors: ""
HeaderFilterRegex: ""
FormatStyle: none
2 changes: 0 additions & 2 deletions .clangd

This file was deleted.

89 changes: 56 additions & 33 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
os:
- ubuntu-20.04
- windows-2019
node_version:
- 18
node_arch:
- x64
cpp_arch:
Expand All @@ -28,34 +26,30 @@ jobs:

include:
- os: windows-2019
node_version: 18
node_arch: ia32
cpp_arch: amd64_x86

# - os: windows-2022
# node_version: 18
# node_arch: x64
# arch: arm64
# cpp_arch: amd64_arm64

- os: macos-13
node_version: 18
node_arch: x64
cpp_arch: x64

- os: macos-14
node_version: 18
node_arch: arm64
cpp_arch: amd64_arm64

# Alpine
- os: ubuntu-22.04
docker: node:18-alpine
docker_cmd:
apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake
musl-dev && npm i -g pnpm && pnpm install && pnpm run
build.prebuild
node_version: 18
apk add --no-cache bash build-base curl git g++ make ninja-build
pkgconfig unzip zip python3 tar cmake ninja musl-dev && cp
/usr/lib/ninja-build/bin/ninja /usr/bin/ninja && npm i -g pnpm &&
pnpm install && pnpm run build
node_arch: x64
cpp_arch: x64

Expand All @@ -73,12 +67,12 @@ jobs:
with:
path: |
./node_modules/
./build/
~/vcpkg
key:
# prettier-ignore
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch}}-ZMQ_DRAFT:${{env.npm_config_zmq_draft }}-Node:${{ matrix.node_version}}-${{hashFiles('./package.json') }}"
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch}}-ZMQ_DRAFT:${{env.npm_config_zmq_draft }}-${{hashFiles('./package.json') }}"
restore-keys: |
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ env.npm_config_zmq_draft }}-Node:${{ matrix.node_version }}-"
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ env.npm_config_zmq_draft }}-"

- name: Env map
run: |
Expand All @@ -93,21 +87,11 @@ jobs:
with:
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
python: true
vcpkg: true
architecture: ${{ matrix.cpp_arch }}

- uses: pnpm/action-setup@v4
if: ${{ !matrix.docker }}
with:
version: 9

- name: Install Node
if: ${{ !matrix.docker }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ env.setup_node_arch }}

- name: Install Mac-OS x86_64 Dependencies
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }}
run: |
Expand All @@ -121,13 +105,52 @@ jobs:
echo "PATH=$PATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV

- name: Install Dependencies and Build
- uses: pnpm/action-setup@v4
if: ${{ !matrix.docker }}
with:
version: 9

- name: Install Node 20
if: ${{ !matrix.docker }}
uses: actions/setup-node@v4
with:
node-version: 20
architecture: ${{ env.setup_node_arch }}

- name: Install Dependencies
if: ${{ !matrix.docker }}
run: pnpm install

- name: Prebuild
- name: Build JavaScript
if: ${{ !matrix.docker }}
run: pnpm run build.prebuild
run: pnpm run build.js

- name: Install Node 12
if: ${{ !matrix.docker && matrix.os != 'macos-14' }}
uses: actions/setup-node@v4
with:
node-version: 12
architecture: ${{ env.setup_node_arch }}

- name: Build Native
if:
${{ !matrix.docker && matrix.os != 'windows-2019' && matrix.node_arch
!= 'ia32' }}
run: npm run build.native

- name: Build Native Windows 32
if:
${{ !matrix.docker && matrix.os == 'windows-2019' && matrix.node_arch
== 'ia32' }}
run:
node ./node_modules/cmake-ts/build/main.js named-configs windows-x86

- name: Use Node 20
if: ${{ !matrix.docker }}
uses: actions/setup-node@v4
with:
node-version: 20
architecture: ${{ env.setup_node_arch }}

- name: Prebuild Docker
if: ${{ matrix.docker }}
Expand All @@ -140,8 +163,8 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: ./prebuilds
name: prebuilds-${{ strategy.job-index }}
path: ./build
name: build-${{ strategy.job-index }}
overwrite: true

- name: Lint
Expand Down Expand Up @@ -169,13 +192,13 @@ jobs:
pnpm install -g electron@latest
xvfb-run --auto-servernum pnpm run test.electron.main
continue-on-error: true
merge-prebuilds:
merge-build:
runs-on: ubuntu-latest
needs: Build
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: prebuilds
pattern: prebuilds-*
name: build
pattern: build-*
delete-merged: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ tsconfig.*.tsbuildinfo
/doc-unminified
.DS_Store
.idea
/staging
!/lib/load-addon.js
!/lib/load-addon.js.map

compile_commands.json
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
/node_modules
pnpm-lock.yaml
/build
/script/*.js
/script/*.mjs
10 changes: 1 addition & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
"mochaExplorer.nodeArgv": ["--expose-gc"],
"mochaExplorer.debuggerConfig": "JS-Attach",
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.cache": true,
"**/script/*.js": true,
"**/script/*.mjs": true,
"**/script/*.js.map": true,
"**/script/*.mjs.map": true,
"**/script/*.d.ts": true,
"**/script/*.d.mts": true,
"**/script/*.tsbuildinfo": true
"**/.cache": true
}
}
Loading
Loading