Skip to content

Commit 20ce19e

Browse files
authored
Merge pull request #424 from napi-rs/bsd-aarch64-musl
build: add FreeBSD and aarch64-linux-unknown-musl targets
2 parents c617c44 + 57010c5 commit 20ce19e

File tree

35 files changed

+1046
-676
lines changed

35 files changed

+1046
-676
lines changed

.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ linker = "aarch64-linux-gnu-gcc"
33

44
[target.armv7-unknown-linux-gnueabihf]
55
linker = "arm-linux-gnueabihf-gcc"
6+
7+
[target.aarch64-unknown-linux-musl]
8+
linker = "aarch64-linux-gnu-gcc"
9+
rustflags = ["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc"]

.github/workflows/ci.yaml

Lines changed: 133 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158

159159
build-musl:
160160
if: "!contains(github.event.head_commit.message, 'skip ci')"
161-
name: stable - linux-musl - node@10
161+
name: stable - linux-musl - node@lts
162162
runs-on: ubuntu-latest
163163

164164
steps:
@@ -168,7 +168,7 @@ jobs:
168168
run: |
169169
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
170170
env:
171-
DOCKER_REGISTRY_URL: docker.pkg.github.com
171+
DOCKER_REGISTRY_URL: ghcr.io
172172
DOCKER_USERNAME: ${{ github.actor }}
173173
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
174174

@@ -181,18 +181,18 @@ jobs:
181181
uses: actions/cache@v1
182182
with:
183183
path: ~/.cargo/registry
184-
key: stable-node-alpine-@10-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
184+
key: stable-node-alpine-@lts-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
185185

186186
- name: Cache cargo index
187187
uses: actions/cache@v1
188188
with:
189189
path: ~/.cargo/git
190-
key: stable-node-alpine-@10-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
190+
key: stable-node-alpine-@lts-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
191191

192192
- name: Pull docker image
193193
run: |
194-
docker pull docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine
195-
docker tag docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine builder
194+
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
195+
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
196196
197197
- name: 'Install dependencies'
198198
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
@@ -271,6 +271,82 @@ jobs:
271271
name: bindings-linux-aarch64
272272
path: packages/*/*.node
273273

274+
build-linux-aarch64-musl:
275+
name: stable - aarch64-unknown-linux-musl - node@14
276+
runs-on: ubuntu-latest
277+
278+
steps:
279+
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
280+
281+
- uses: actions/checkout@v2
282+
283+
- name: Setup node
284+
uses: actions/setup-node@v2-beta
285+
with:
286+
node-version: 14
287+
check-latest: true
288+
289+
- name: Install
290+
uses: actions-rs/toolchain@v1
291+
with:
292+
toolchain: stable
293+
profile: minimal
294+
override: true
295+
296+
- name: Install aarch64 toolchain
297+
run: rustup target add aarch64-unknown-linux-musl
298+
299+
- name: Generate Cargo.lock
300+
uses: actions-rs/cargo@v1
301+
with:
302+
command: generate-lockfile
303+
304+
- name: Cache cargo registry
305+
uses: actions/cache@v1
306+
with:
307+
path: ~/.cargo/registry
308+
key: stable-linux-aarch64-musl-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
309+
310+
- name: Cache cargo index
311+
uses: actions/cache@v1
312+
with:
313+
path: ~/.cargo/git
314+
key: stable-linux-aarch64-musl-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
315+
316+
- name: Cache NPM dependencies
317+
uses: actions/cache@v1
318+
with:
319+
path: node_modules
320+
key: npm-cache-linux-aarch64-musl-node@14-${{ hashFiles('yarn.lock') }}
321+
322+
- name: Install cross compile toolchain
323+
run: |
324+
sudo apt-get update
325+
sudo apt-get install gcc-aarch64-linux-gnu -y
326+
327+
- name: Install dependencies
328+
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
329+
330+
- name: Cross build aarch64
331+
run: yarn build -- -- --target aarch64-unknown-linux-musl
332+
333+
- name: Run tests
334+
uses: docker://multiarch/alpine:aarch64-latest-stable
335+
with:
336+
args: >
337+
sh -c "sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \
338+
apk add nodejs yarn && \
339+
yarn install --frozen-lockfile --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \
340+
yarn build:ts && \
341+
node ./scripts/simple-tests.js
342+
"
343+
344+
- name: Upload artifact
345+
uses: actions/upload-artifact@v2
346+
with:
347+
name: bindings-linux-aarch64-musl
348+
path: packages/*/*.node
349+
274350
build-linux-arm7:
275351
name: stable - arm7-unknown-linux-gnu - node@14
276352
runs-on: ubuntu-latest
@@ -444,6 +520,52 @@ jobs:
444520
name: bindings-android-aarch64
445521
path: packages/*/*.node
446522

523+
build-freebsd:
524+
runs-on: macos-latest
525+
name: Build FreeBSD
526+
steps:
527+
- uses: actions/checkout@v2
528+
- name: Build
529+
id: build
530+
uses: vmactions/[email protected]
531+
env:
532+
DEBUG: 'napi:*'
533+
RUSTUP_HOME: /usr/local/rustup
534+
CARGO_HOME: /usr/local/cargo
535+
RUSTUP_IO_THREADS: 1
536+
with:
537+
envs: 'DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS'
538+
usesh: true
539+
mem: 3000
540+
prepare: |
541+
pkg install -y curl node yarn npm python2
542+
curl https://sh.rustup.rs -sSf --output rustup.sh
543+
sh rustup.sh -y --profile minimal --default-toolchain stable
544+
export PATH="/usr/local/cargo/bin:$PATH"
545+
echo "~~~~ rustc --version ~~~~"
546+
rustc --version
547+
echo "~~~~ node -v ~~~~"
548+
node -v
549+
echo "~~~~ yarn --version ~~~~"
550+
yarn --version
551+
run: |
552+
export PATH="/usr/local/cargo/bin:$PATH"
553+
pwd
554+
ls -lah
555+
whoami
556+
env
557+
freebsd-version
558+
yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
559+
yarn build:ts
560+
yarn build
561+
yarn test
562+
563+
- name: Upload artifact
564+
uses: actions/upload-artifact@v2
565+
with:
566+
name: bindings-freebsd-amd64
567+
path: packages/*/*.node
568+
447569
test-binding:
448570
name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
449571
needs:
@@ -452,7 +574,7 @@ jobs:
452574
fail-fast: false
453575
matrix:
454576
os: [ubuntu-18.04, macos-latest, windows-latest]
455-
node: ['10', '12', '14', '15']
577+
node: ['12', '14', '16']
456578
runs-on: ${{ matrix.os }}
457579

458580
steps:
@@ -495,7 +617,7 @@ jobs:
495617
strategy:
496618
fail-fast: false
497619
matrix:
498-
node: ['10', '12', '14', '15']
620+
node: ['12', '14', '16']
499621
runs-on: ubuntu-latest
500622

501623
steps:
@@ -532,7 +654,7 @@ jobs:
532654
strategy:
533655
fail-fast: false
534656
matrix:
535-
node: ['10', '12', '14', '15']
657+
node: ['12', '14', '16']
536658

537659
steps:
538660
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
@@ -592,6 +714,8 @@ jobs:
592714
- build-linux-arm7
593715
- build-apple-silicon
594716
- build-windows-i686
717+
- build-linux-aarch64-musl
718+
- build-freebsd
595719
steps:
596720
- uses: actions/checkout@v2
597721

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
"bench": "lerna run bench --concurrency 1 --stream --no-prefix",
1212
"build": "lerna run build --concurrency 1 --stream --no-prefix",
1313
"build:ts": "tsc -b tsconfig.project.json -verbose",
14-
"lint": "eslint . -c ./.eslintrc.yml 'packages/**/*.{ts,js}'",
14+
"lint": "eslint . -c ./.eslintrc.yml \"packages/**/*.{ts,js}\"",
1515
"test": "ava",
1616
"format": "run-p format:md format:json format:yaml format:source",
17-
"format:md": "prettier --parser markdown --write './**/*.md'",
18-
"format:json": "prettier --parser json --write './**/*.json'",
19-
"format:source": "prettier --config ./package.json --write './**/*.{js,ts}'",
20-
"format:yaml": "prettier --parser yaml --write './**/*.{yml,yaml}'",
17+
"format:md": "prettier --parser markdown --write \"./**/*.md\"",
18+
"format:json": "prettier --parser json --write \"./**/*.json\"",
19+
"format:source": "prettier --config ./package.json --write \"./**/*.{js,ts}\"",
20+
"format:yaml": "prettier --parser yaml --write \"./**/*.{yml,yaml}\"",
2121
"typecheck": "tsc -b tsconfig.project.json -verbose",
2222
"postinstall": "husky install"
2323
},
2424
"devDependencies": {
2525
"@napi-rs/cli": "^1.0.4",
2626
"@swc-node/register": "^1.3.1",
27-
"@typescript-eslint/eslint-plugin": "^4.24.0",
28-
"@typescript-eslint/parser": "^4.24.0",
27+
"@typescript-eslint/eslint-plugin": "^4.25.0",
28+
"@typescript-eslint/parser": "^4.25.0",
2929
"ava": "^3.15.0",
3030
"benchmark": "^2.1.4",
3131
"codecov": "^3.8.2",
3232
"cross-env": "^7.0.3",
3333
"eslint": "^7.27.0",
3434
"eslint-config-prettier": "^8.3.0",
35-
"eslint-plugin-import": "^2.23.3",
35+
"eslint-plugin-import": "^2.23.4",
3636
"eslint-plugin-prettier": "^3.4.0",
3737
"eslint-plugin-sonarjs": "^0.7.0",
3838
"husky": "^6.0.0",
@@ -41,7 +41,7 @@
4141
"npm-run-all": "^4.1.5",
4242
"nyc": "^15.1.0",
4343
"prettier": "^2.3.0",
44-
"typescript": "^4.2.4"
44+
"typescript": "^4.3.2"
4545
},
4646
"ava": {
4747
"extensions": ["ts"],

packages/bcrypt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ phf = {version = "0.8", features = ["macros"]}
1616
radix64 = "0.6"
1717
rand = "0.8"
1818

19-
[target.'cfg(all(unix, not(target_env = "musl"), not(target_arch = "aarch64")))'.dependencies]
19+
[target.'cfg(all(unix, not(target_env = "musl"), not(target_os = "freebsd"), not(target_arch = "arm"), not(target_arch = "aarch64")))'.dependencies]
2020
jemallocator = {version = "0.3", features = ["disable_initial_exec_tls"]}
2121

2222
[target.'cfg(windows)'.dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@node-rs/bcrypt-freebsd-x64`
2+
3+
This is the **x86_64-unknown-freebsd** binary for `@node-rs/bcrypt`
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@node-rs/bcrypt-freebsd-x64",
3+
"version": "1.2.1",
4+
"os": ["freebsd"],
5+
"cpu": ["x64"],
6+
"main": "bcrypt.freebsd-x64.node",
7+
"files": ["bcrypt.freebsd-x64.node"],
8+
"description": "Rust bcrypt binding",
9+
"keywords": ["bcrypt", "auth", "password", "authentication", "encryption", "crypto", "N-API", "napi-rs", "node-rs"],
10+
"author": "LongYinan <[email protected]>",
11+
"homepage": "https://github.com/napi-rs/node-rs",
12+
"license": "MIT",
13+
"engines": {
14+
"node": ">= 10"
15+
},
16+
"publishConfig": {
17+
"registry": "https://registry.npmjs.org/",
18+
"access": "public"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/napi-rs/node-rs.git"
23+
},
24+
"bugs": {
25+
"url": "https://github.com/napi-rs/node-rs/issues"
26+
}
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@node-rs/bcrypt-linux-arm64-musl`
2+
3+
This is the **aarch64-unknown-linux-musl** binary for `@node-rs/bcrypt`
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@node-rs/bcrypt-linux-arm64-musl",
3+
"version": "1.2.1",
4+
"os": ["linux"],
5+
"cpu": ["arm64"],
6+
"main": "bcrypt.linux-arm64-musl.node",
7+
"files": ["bcrypt.linux-arm64-musl.node"],
8+
"description": "Rust bcrypt binding",
9+
"keywords": ["bcrypt", "auth", "password", "authentication", "encryption", "crypto", "N-API", "napi-rs", "node-rs"],
10+
"author": "LongYinan <[email protected]>",
11+
"homepage": "https://github.com/napi-rs/node-rs",
12+
"license": "MIT",
13+
"engines": {
14+
"node": ">= 10"
15+
},
16+
"publishConfig": {
17+
"registry": "https://registry.npmjs.org/",
18+
"access": "public"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/napi-rs/node-rs.git"
23+
},
24+
"bugs": {
25+
"url": "https://github.com/napi-rs/node-rs/issues"
26+
}
27+
}

packages/bcrypt/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"x86_64-unknown-linux-musl",
2020
"aarch64-unknown-linux-gnu",
2121
"aarch64-apple-darwin",
22-
"aarch64-linux-android"
22+
"aarch64-linux-android",
23+
"x86_64-unknown-freebsd",
24+
"aarch64-unknown-linux-musl"
2325
]
2426
}
2527
},

packages/bcrypt/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ mod lib_bcrypt;
2020
mod salt_task;
2121
mod verify_task;
2222

23-
#[cfg(all(unix, not(target_env = "musl"), not(target_arch = "aarch64")))]
23+
#[cfg(all(
24+
unix,
25+
not(target_env = "musl"),
26+
not(target_os = "freebsd"),
27+
not(target_arch = "arm"),
28+
not(target_arch = "aarch64")
29+
))]
2430
#[global_allocator]
2531
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
2632

0 commit comments

Comments
 (0)