https://github.com/mmomtchev/hadron-nobind-example-project
Template for a `nobind17` project with a Node.js C++ addon (hadron version)
https://github.com/mmomtchev/hadron-nobind-example-project
Last synced: 8 months ago
JSON representation
Template for a `nobind17` project with a Node.js C++ addon (hadron version)
- Host: GitHub
- URL: https://github.com/mmomtchev/hadron-nobind-example-project
- Owner: mmomtchev
- License: isc
- Created: 2024-07-17T20:48:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-10T13:49:18.000Z (8 months ago)
- Last Synced: 2025-02-10T14:47:21.507Z (8 months ago)
- Language: C++
- Size: 1020 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nobind example skeleton (`hadron` version)
[](https://github.com/mmomtchev/hadron-nobind-example-project/actions/workflows/run.yml)
[](https://codecov.io/gh/mmomtchev/hadron-nobind-example-project)This is an example skeleton for a C++ project that uses Nobind using the new `hadron` build system. `hadron` is far less mature than `node-gyp` but if offers a number of advantages, including interoperability with other build systems, seamless integration with `conan` and the use `xPack` packages which allow to have a fully self-contained build that does not need any tools from the user host.
It includes some non-trivial examples such as C buffers, vectors of objects and maps.
You can check [`nobind-example-project`](https://github.com/mmomtchev/nobind-example-project) for the `node-gyp` version.
# Try building yourself
## Build the project
```shell
git clone https://github.com/mmomtchev/hadron-nobind-example-project.git
cd hadron-nobind-example-project
npm install
```Run the unit tests:
```shell
# Run all unit tests
npm test
```## Self-contained `xPack` build (building on the end-user target host without expecting a C++ environment)
The `hadron` system includes support for building from source on the end-user target host without requiring anything but a working Node.js installation. Currently this feature is to be considered experimental and it is included in this template mostly for demonstration purposes. It will work out of the box for a simple project, but as you start ramping up advanced features and additional dependencies, you will probably have to fix problems. The build is implemented in the [`xpack`](https://github.com/mmomtchev/hadron-nobind-example-project/blob/main/.github/workflows/run.yml) build job in Github Actions. Be sure to check the notes from the [magickwand.js](https://github.com/mmomtchev/magickwand.js/blob/main/README.xPacks.md) package which contains a `xPack` build for a large project with many dependencies.
To run the build manually:
```shell
npm install
npx xpm install --config xpack
npx xpm run prepare --config xpack
npx xpm run build --config xpack
```## Code instrumentation
For a debug build:
```shell
npm install
npx xpm run prepare --config debug
npx xpm run build
```Check the [CI workflow](https://github.com/mmomtchev/hadron-nobind-example-project/blob/main/.github/workflows/run.yml) for ASAN and dual-language code coverage setups.