Skip to content

Commit

Permalink
Update scanner build scripts for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed May 6, 2024
1 parent 8d16227 commit 64510e3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 47 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Expand Up @@ -37,10 +37,10 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: "npm"
- name: Cache Node modules
uses: actions/cache@v3
Expand Down Expand Up @@ -90,10 +90,10 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: "npm"
- name: Cache Node modules
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@master
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@master
with:
version: 18
version: 20
cache: npm
- name: Install dependencies
run: npm ci
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Expand Up @@ -12,10 +12,10 @@ jobs:
- name: get-npm-version
id: package-version
uses: pchynoweth/action-get-npm-version@1.1.1
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@master
with:
version: 18
version: 20
cache: npm
- run: npm ci
- run: npm run build:linux
Expand Down Expand Up @@ -65,10 +65,10 @@ jobs:
- name: get-npm-version
id: package-version
uses: pchynoweth/action-get-npm-version@1.1.1
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@master
with:
version: 18
version: 20
cache: npm
- run: npm ci
- run: npm run build:macos
Expand Down Expand Up @@ -97,10 +97,10 @@ jobs:
- name: get-npm-version
id: package-version
uses: pchynoweth/action-get-npm-version@1.1.1
- name: Use Node.js 18
- name: Use Node.js 20
uses: actions/setup-node@master
with:
version: 18
version: 20
cache: npm
- name: add git binaries to PATH
run: |
Expand Down
40 changes: 9 additions & 31 deletions packages/scanner/README.md
Expand Up @@ -2,65 +2,43 @@

This project was bootstrapped by [create-neon](https://www.npmjs.com/package/create-neon).

## Installing scanner

Installing scanner requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support).

You can install the project with npm. In the project directory, run:

```sh
$ npm install
```

This fully installs the project, including installing any dependencies and running the build.

## Building scanner

If you have already installed the project and only want to run the build, run:
If you only want to run the build, run:

```sh
$ npm run build
```

This command uses the [cargo-cp-artifact](https://github.com/neon-bindings/cargo-cp-artifact) utility to run the Rust build and copy the built library into `./index.node`.

## Exploring scanner

After building scanner, you can explore its exports at the Node REPL:

```sh
$ npm install
$ node
> require('.').hello()
"hello node"
```

## Available Scripts

In the project directory, you can run:

### `npm install`

Installs the project, including running `npm run build`.

### `npm build`
### `npm run build`

Builds the Node addon (`index.node`) from source.

Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to `npm build` and `npm build-*` commands. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html):
Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to the `npm build` command. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html):

```
npm run build -- --feature=beetle
```

#### `npm build-debug`
#### `npm run build-debug`

Alias for `npm build`.

#### `npm build-release`
#### `npm run build-release`

Same as [`npm build`](#npm-build) but, builds the module with the [`release`](https://doc.rust-lang.org/cargo/reference/profiles.html#release) profile. Release builds will compile slower, but run faster.

#### `npm run build-macos` and `npm run build-macos-arm64`

Builds the module for macOS. The `build-macos` script builds for the x86_64 architecture, while `build-macos-arm64` builds for the Apple Silicon architecture.

### `npm test`

Runs the unit tests by calling `cargo test`. You can learn more about [adding tests to your Rust code](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) from the [Rust book](https://doc.rust-lang.org/book/).
Expand Down
8 changes: 4 additions & 4 deletions packages/scanner/package.json
Expand Up @@ -5,13 +5,13 @@
"main": "index.node",
"types": "index.d.ts",
"scripts": {
"build": "if [ \"$npm_config_target_arch\" == \"arm64\" ]; then npm run build-macos-arm64; elif [ \"$npm_config_target_arch\" == \"x64\" ]; then npm run build-macos; else npm run build-linux-windows; fi",
"build-profiling": "npm run build -- --features profiling --release",
"build-debug": "npm run build --",
"build-release": "npm run build -- --release",
"build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics",
"build-release": "if [ \"$npm_config_target_arch\" == \"arm64\" ]; then npm run build-macos-arm64; elif [ \"$npm_config_target_arch\" == \"x64\" ]; then npm run build-macos; else npm run build-linux-windows; fi",
"build-linux-windows": "cargo-cp-artifact -nc index.node -- cargo build --release --message-format=json-render-diagnostics",
"build-macos": "cargo-cp-artifact -nc index.node -- cargo build --target x86_64-apple-darwin --release --message-format=json-render-diagnostics",
"build-macos-arm64": "cargo-cp-artifact -nc index.node -- cargo build --target aarch64-apple-darwin --release --message-format=json-render-diagnostics",
"build-profiling": "npm run build -- --features profiling --release",
"build-debug": "npm run build -- --debug",
"install": "npm run build-release",
"test": "cargo test"
},
Expand Down

0 comments on commit 64510e3

Please sign in to comment.