From 3b7e420b7629bfa43d308e9189c558f4503cf5b8 Mon Sep 17 00:00:00 2001 From: kaj dijkstra Date: Tue, 30 Dec 2025 20:38:25 +0100 Subject: [PATCH] Readme --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..be349cb --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Node.js Native Addon Example + +This project is a minimal example of a Node.js native addon written in C++ and built with `node-gyp`, exposing a simple function to JavaScript. + +## Overview + +The addon compiles a C++ binding into a native `.node` module that can be required from Node.js and invoked like a normal JavaScript function. + +## Project Structure + +* `src/binding.cc` + Main C++ source file defining the native addon. + +* `binding.gyp` + `node-gyp` build configuration. + +* `build/` + Generated build artifacts (created by `node-gyp`). + +* `test.js` / `test-worker.js` + Simple test scripts to verify the addon. + +* `package.json` + Project metadata and dependencies. + +## Prerequisites + +* Node.js (with headers available) +* Python (required by `node-gyp`) +* C/C++ build tools + + * Linux: `build-essential` + * macOS: Xcode Command Line Tools + * Windows: Visual Studio Build Tools + +## Build Instructions + +Run the following commands in the project root: + +``` +node-gyp configure +node-gyp build +``` + +This will generate the native module under `build/Release/`. + +## Usage + +Example JavaScript usage: + +``` +const binding = require("./build/Release/binding"); + +console.log(binding.hello()); // outputs: "hello world" +``` + +## Notes + +* This repository is intended as a learning or reference project. +* The build output should not be edited manually. +* For distribution, consider ignoring `build/` in version control and rebuilding per environment. + +## License + +MIT \ No newline at end of file