|
| 1 | +# cpp-linter-js |
| 2 | + |
| 3 | +This project was bootstrapped by [create-neon](https://www.npmjs.com/package/create-neon). |
| 4 | + |
| 5 | +## Building cpp-linter-js |
| 6 | + |
| 7 | +Building cpp-linter-js requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support). |
| 8 | + |
| 9 | +To run the build, run: |
| 10 | + |
| 11 | +```sh |
| 12 | +npm run build |
| 13 | +``` |
| 14 | + |
| 15 | +This command uses the [@neon-rs/cli](https://www.npmjs.com/package/@neon-rs/cli) utility to assemble the binary Node addon from the output of `cargo`. |
| 16 | + |
| 17 | +## Exploring cpp-linter-js |
| 18 | + |
| 19 | +After building cpp-linter-js: |
| 20 | + |
| 21 | +```text |
| 22 | +cd node-binding |
| 23 | +npm i |
| 24 | +npm run build |
| 25 | +``` |
| 26 | + |
| 27 | +You can explore its exports in the `node` console: |
| 28 | + |
| 29 | +```sh |
| 30 | +> cpp_linter_js = require('.') |
| 31 | +> // CLI args are passed as optional args to `run_main()` |
| 32 | +> await cpp_linter_js.run_main('--help') |
| 33 | +``` |
| 34 | + |
| 35 | +## Available Scripts |
| 36 | + |
| 37 | +In the project directory, you can run: |
| 38 | + |
| 39 | +### `npm install` |
| 40 | + |
| 41 | +Installs the project, including running `npm run build`. |
| 42 | + |
| 43 | +### `npm run build` |
| 44 | + |
| 45 | +Builds the Node addon (`index.node`) from source, generating a release build with `cargo --release`. |
| 46 | + |
| 47 | +Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to `npm run build` and similar commands. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html): |
| 48 | + |
| 49 | +```text |
| 50 | +npm run build -- --feature=beetle |
| 51 | +``` |
| 52 | + |
| 53 | +### `npm run debug` |
| 54 | + |
| 55 | +Similar to `npm run build` but generates a debug build with `cargo`. |
| 56 | + |
| 57 | +### `npm run cross` |
| 58 | + |
| 59 | +Similar to `npm run build` but uses [cross-rs](https://github.com/cross-rs/cross) to cross-compile for another platform. Use the [`CARGO_BUILD_TARGET`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) environment variable to select the build target. |
| 60 | + |
| 61 | +## Project Layout |
| 62 | + |
| 63 | +The directory structure of this project is: |
| 64 | + |
| 65 | +```text |
| 66 | +node-binding/ |
| 67 | +├── Cargo.toml |
| 68 | +├── README.md |
| 69 | +├── src/ |
| 70 | +| └── lib.rs |
| 71 | +├── index.node |
| 72 | +├── package.json |
| 73 | +└── target/ |
| 74 | +``` |
| 75 | + |
| 76 | +| Entry | Purpose | |
| 77 | +|----------------|------------------------------------------------------------------------------------------------------------------------------------------| |
| 78 | +| `Cargo.toml` | The Cargo [manifest file](https://doc.rust-lang.org/cargo/reference/manifest.html), which informs the `cargo` command. | |
| 79 | +| `README.md` | This file. | |
| 80 | +| `src/` | The directory tree containing the Rust source code for the project. | |
| 81 | +| `lib.rs` | Entry point for the Rust source code. | |
| 82 | +| `index.node` | The main module, a [Node addon](https://nodejs.org/api/addons.html) generated by the build and pointed to by `"main"` in `package.json`. | |
| 83 | +| `package.json` | The npm [manifest file](https://docs.npmjs.com/cli/v7/configuring-npm/package-json), which informs the `npm` command. | |
| 84 | +| `target/` | Binary artifacts generated by the Rust build. | |
| 85 | + |
| 86 | +## Learn More |
| 87 | + |
| 88 | +Learn more about: |
| 89 | + |
| 90 | +- [Neon](https://neon-bindings.com). |
| 91 | +- [Rust](https://www.rust-lang.org). |
| 92 | +- [Node](https://nodejs.org). |
0 commit comments