Make node add-ons easy, than one file, many builds and targets.
This repository has been archived on 2024-07-06. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Matheus Sampaio Queiroga 950c1c6c18
Add test
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2024-03-25 20:46:07 -03:00
.devcontainer init test to electron 2024-03-17 22:54:11 -03:00
.github Update targets 2024-03-20 12:04:03 -03:00
.vscode Update node headers path and Builder 2024-02-24 17:59:43 -03:00
src Add test 2024-03-25 20:46:07 -03:00
test Update to targets 2024-03-19 23:46:16 -03:00
.dockerignore Rename .dockerignore 2024-03-18 14:07:45 -03:00
.gitignore Update node headers path and Builder 2024-02-24 17:59:43 -03:00
.npmignore Update node headers path and Builder 2024-02-24 17:59:43 -03:00
compose.yaml Update targets 2024-03-20 12:04:03 -03:00
LICENSE Initial commit 2024-02-09 07:53:09 -03:00
package.json v0.2.10 2024-03-20 23:30:24 -03:00
README.md Update node headers path and Builder 2024-02-24 17:59:43 -03:00
test.Dockerfile add targets 2024-03-23 21:44:33 -03:00
tsconfig.json Init config support 2024-02-13 12:37:52 -03:00

Rebory

Making Node addons dynamic and more eficiente config to build.

Note

To do cross-compiler check if the compiler for the architecture exists, if not we will try to use zig

Warning

CC and CCX env dont includes ANY arguments, only command, for includes more argurments in compiler, set in config file!

Static Config

command find in workdir one of this files:

  • binding.yaml
  • binding.yml

or set with -c / --config argument.

config file is YAML with configs to addon:

name: addon
sources:
  - g.c
  - main.cpp
includes:
  - node_modules/node-addon-api
  - ./
name: addon
sources:
  - g.c
  - main.cpp
---
name: addon2
sources:
  - g.c
  - main.cpp
includes:
  - node_modules/node-addon-api
  - ./
target:
  linux:
    flags:
      - -fPIC
  macos:
    flags:
      - -fPIC
  x86_64-linux-gnu:
    release: true
  aarch64-linux-gnu:
    release: true
  x86_64-macos:
    release: true
  aarch64-macos:
    release: true
  x86_64-windows:
    release: true
  aarch64-windows:
    release: true

Dynamic build

Example:

import builderClass from "rebory";
const builder = new Builder({name: "addon"});
builder.sources.push("./test.cpp");

if (process.platform === "win32") {
  builder.sources.push("./test-win32.cpp");
  builder.librarys.push(
    "bcrypt.lib",
    "crypt32.lib",
    "iphlpapi.lib",
    "kernel32.lib",
    "ntdll.lib",
    "ws2_32.lib",
    "setupapi.lib"
  );
} else if (process.platform === "linux" || process.platform === "android") {
  builder.sources.push("./test-linux.cpp");
  builder.defines.push("LINUX_ENABLED=1");
  if (process.arch === "x64") builder.defines.push("LINUX_KERNEL_X64");
  else if (process.arch === "arm64") builder.defines.push("LINUX_KERNEL_AARCH64");
} else {
  builder.sources.push("./test-dummy.cpp");
}

await builder.run();