Skip to content

Template for a `nobind17` project with a Node.js C++ addon (hadron version)

License

Notifications You must be signed in to change notification settings

mmomtchev/hadron-nobind-example-project

Repository files navigation

Nobind example skeleton (hadron version)

Test codecov

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 for the node-gyp version.

Try building yourself

Build the project

git clone https://github.com/mmomtchev/hadron-nobind-example-project.git
cd hadron-nobind-example-project
npm install

Run the unit tests:

# 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 build job in Github Actions. Be sure to check the notes from the magickwand.js package which contains a xPack build for a large project with many dependencies.

To run the build manually:

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:

npm install
npx xpm run prepare --config debug
npx xpm run build

Check the CI workflow for ASAN and dual-language code coverage setups.

About

Template for a `nobind17` project with a Node.js C++ addon (hadron version)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published