Matheus Sampaio Queiroga
772443cc58
Some checks failed
Test / test_cross (16.x) (push) Failing after 2m15s
Test / test_cross (18.x) (push) Failing after 2m48s
Test / test_cross (19.x) (push) Failing after 2m47s
Test / test_cross (17.x) (push) Failing after 2m51s
Test / test_cross (20.x) (push) Failing after 1m34s
Test / test_cross (21.x) (push) Failing after 1m21s
98 lines
1.8 KiB
Markdown
98 lines
1.8 KiB
Markdown
# 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`](https://ziglang.org/)
|
|
|
|
> [!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:
|
|
|
|
```yaml
|
|
name: addon
|
|
sources:
|
|
- g.c
|
|
- main.cpp
|
|
includes:
|
|
- node_modules/node-addon-api
|
|
- ./
|
|
```
|
|
|
|
```yaml
|
|
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:
|
|
|
|
```js
|
|
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();
|
|
``` |