koffi 2.16.1 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +8 -8
- package/build/koffi/darwin_arm64/koffi.node +0 -0
- package/build/koffi/darwin_x64/koffi.node +0 -0
- package/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/build/koffi/freebsd_x64/koffi.node +0 -0
- package/build/koffi/linux_arm64/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_arm64/koffi.node +0 -0
- package/build/koffi/musl_x64/koffi.node +0 -0
- package/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/build/koffi/openbsd_x64/koffi.node +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/benchmarks.md +33 -33
- package/doc/benchmarks.xlsx +0 -0
- package/doc/contribute.md +37 -25
- package/doc/index.md +8 -8
- package/doc/variables.md +1 -1
- package/index.d.ts +11 -9
- package/index.js +1 -634
- package/indirect.js +1 -533
- package/lib/native/base/base.cc +63 -85
- package/lib/native/base/base.hh +178 -151
- package/package.json +3 -4
- package/src/build.js +1178 -0
- package/src/koffi/CMakeLists.txt +97 -34
- package/src/koffi/index.js +359 -0
- package/src/koffi/indirect.js +216 -0
- package/src/koffi/src/{abi_arm32.cc → abi/arm32.cc} +279 -275
- package/src/koffi/src/{abi_arm32_asm.S → abi/arm32_asm.S} +2 -5
- package/src/koffi/src/abi/arm64.cc +1511 -0
- package/src/koffi/src/{abi_arm64_asm.S → abi/arm64_asm.S} +44 -23
- package/src/koffi/src/{abi_arm64_asm.asm → abi/arm64_asm.asm} +32 -25
- package/src/koffi/src/{abi_loong64_asm.S → abi/loong64_asm.S} +1 -5
- package/src/koffi/src/{abi_riscv64.cc → abi/riscv64.cc} +279 -273
- package/src/koffi/src/{abi_riscv64_asm.S → abi/riscv64_asm.S} +1 -4
- package/src/koffi/src/abi/x64sysv.cc +1456 -0
- package/src/koffi/src/{abi_x64_sysv_asm.S → abi/x64sysv_asm.S} +30 -33
- package/src/koffi/src/abi/x64win.cc +1121 -0
- package/src/koffi/src/{abi_x64_win_asm.S → abi/x64win_asm.S} +8 -12
- package/src/koffi/src/{abi_x64_win_asm.asm → abi/x64win_asm.asm} +11 -14
- package/src/koffi/src/abi/x86.cc +1233 -0
- package/src/koffi/src/{abi_x86_asm.S → abi/x86_asm.S} +49 -25
- package/src/koffi/src/{abi_x86_asm.asm → abi/x86_asm.asm} +11 -14
- package/src/koffi/src/call.cc +458 -598
- package/src/koffi/src/call.hh +61 -82
- package/src/koffi/src/ffi.cc +595 -309
- package/src/koffi/src/ffi.hh +103 -89
- package/src/koffi/src/parser.cc +0 -4
- package/src/koffi/src/primitives.inc +39 -0
- package/src/koffi/{tools/write_trampolines.js → src/trampolines.js} +1 -1
- package/src/koffi/src/util.cc +503 -446
- package/src/koffi/src/util.hh +269 -57
- package/src/koffi/src/uv.cc +2 -2
- package/src/koffi/src/uv.def +3 -0
- package/src/koffi/src/win32.hh +30 -1
- package/vendor/node-addon-api/napi-inl.h +4 -0
- package/vendor/node-addon-api/napi.h +1 -0
- package/build/koffi/linux_armhf/koffi.node +0 -0
- package/build/koffi/linux_loong64/koffi.node +0 -0
- package/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/build/koffi/win32_arm64/koffi.exp +0 -0
- package/build/koffi/win32_arm64/koffi.lib +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/doc/platforms.md +0 -36
- package/src/cnoke/LICENSE.txt +0 -22
- package/src/cnoke/README.md +0 -99
- package/src/cnoke/assets/FindCNoke.cmake +0 -127
- package/src/cnoke/assets/toolchains.json +0 -126
- package/src/cnoke/assets/win_delay_hook.c +0 -36
- package/src/cnoke/cnoke.js +0 -170
- package/src/cnoke/package.json +0 -24
- package/src/cnoke/src/builder.js +0 -511
- package/src/cnoke/src/index.js +0 -10
- package/src/cnoke/src/tools.js +0 -407
- package/src/koffi/src/abi_arm64.cc +0 -1295
- package/src/koffi/src/abi_x64_sysv.cc +0 -939
- package/src/koffi/src/abi_x64_win.cc +0 -715
- package/src/koffi/src/abi_x86.cc +0 -860
- package/src/koffi/src/init.js +0 -105
- /package/src/koffi/src/{abi_loong64.cc → abi/loong64.cc} +0 -0
package/src/cnoke/README.md
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# Table of contents
|
|
2
|
-
|
|
3
|
-
- [Introduction](#introduction)
|
|
4
|
-
- [Get started](#get-started)
|
|
5
|
-
- [Command usage](#command-usage)
|
|
6
|
-
|
|
7
|
-
# Introduction
|
|
8
|
-
|
|
9
|
-
CNoke is a simpler alternative to CMake.js, without any dependency, designed to build
|
|
10
|
-
native Node addons based on CMake.
|
|
11
|
-
|
|
12
|
-
Install it like this:
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
npm install cnoke
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
It obviously requires [CMake](http://www.cmake.org/download/) and a proper C/C++ toolchain:
|
|
19
|
-
|
|
20
|
-
* Windows: Visual C++ Build Tools or a recent version of Visual C++ will do (the free Community version works well)
|
|
21
|
-
* POSIX (Linux, macOS, etc.): Clang or GCC, and Make (Ninja is preferred if available)
|
|
22
|
-
|
|
23
|
-
# Get started
|
|
24
|
-
|
|
25
|
-
In order to build a native Node.js addon with CNoke, you can use the following CMakeLists.txt
|
|
26
|
-
template to get started:
|
|
27
|
-
|
|
28
|
-
```cmake
|
|
29
|
-
cmake_minimum_required(VERSION 3.11)
|
|
30
|
-
project(hello C CXX)
|
|
31
|
-
|
|
32
|
-
find_package(CNoke)
|
|
33
|
-
|
|
34
|
-
add_node_addon(NAME hello SOURCES hello.cc)
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
You can also do it manually (without the module) if you prefer:
|
|
38
|
-
|
|
39
|
-
```cmake
|
|
40
|
-
cmake_minimum_required(VERSION 3.11)
|
|
41
|
-
project(hello C CXX)
|
|
42
|
-
|
|
43
|
-
add_library(hello SHARED hello.cc ${NODE_JS_SOURCES})
|
|
44
|
-
set_target_properties(hello PROPERTIES PREFIX "" SUFFIX ".node")
|
|
45
|
-
target_include_directories(hello PRIVATE ${NODE_JS_INCLUDE_DIRS})
|
|
46
|
-
target_link_libraries(hello PRIVATE ${NODE_JS_LIBRARIES})
|
|
47
|
-
target_compile_options(hello PRIVATE ${NODE_JS_COMPILE_FLAGS})
|
|
48
|
-
target_link_options(hello PRIVATE ${NODE_JS_LINK_FLAGS})
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
In order for this to run when `npm install` runs (directly or when someone else installs
|
|
52
|
-
your dependency), add the following script to package.json:
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
"scripts": {
|
|
56
|
-
"install": "cnoke"
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
# Command usage
|
|
61
|
-
|
|
62
|
-
You can find the same help text by running `cnoke --help`:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
Usage: cnoke [command] [options...] [targets...]
|
|
66
|
-
|
|
67
|
-
Commands:
|
|
68
|
-
|
|
69
|
-
configure Configure CMake build
|
|
70
|
-
build Build project (configure if needed)
|
|
71
|
-
clean Clean build files
|
|
72
|
-
|
|
73
|
-
Options:
|
|
74
|
-
|
|
75
|
-
-d, --directory <DIR> Change project directory
|
|
76
|
-
(default: current working directory)
|
|
77
|
-
|
|
78
|
-
-B, --config <CONFIG> Change build type: RelWithDebInfo, Debug, Release
|
|
79
|
-
(default: RelWithDebInfo)
|
|
80
|
-
-D, --debug Shortcut for --config Debug
|
|
81
|
-
|
|
82
|
-
--prebuild <URL> Set URL template to download prebuilt binaries
|
|
83
|
-
--require <PATH> Require specified module, drop prebuild if it fails
|
|
84
|
-
|
|
85
|
-
-a, --arch <ARCH> Change architecture and ABI
|
|
86
|
-
(default: x64)
|
|
87
|
-
-v, --runtime-version <VERSION> Change node version
|
|
88
|
-
(default: v16.14.0)
|
|
89
|
-
-t, --toolset <TOOLSET> Change default CMake toolset
|
|
90
|
-
-C, --prefer-clang Use Clang instead of default CMake compiler
|
|
91
|
-
|
|
92
|
-
--verbose Show build commands while building
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The ARCH value is similar to process.arch, with the following differences:
|
|
96
|
-
|
|
97
|
-
- arm is changed to arm32hf or arm32sf depending on the floating-point ABI used (hard-float, soft-float)
|
|
98
|
-
- riscv32 is changed to riscv32sf, riscv32hf32, riscv32hf64 or riscv32hf128 depending on the floating-point ABI
|
|
99
|
-
- riscv64 is changed to riscv64sf, riscv64hf32, riscv64hf64 or riscv64hf128 depending on the floating-point ABI
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: MIT
|
|
2
|
-
# SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
3
|
-
|
|
4
|
-
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR
|
|
5
|
-
CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
6
|
-
set(USE_UNITY_BUILDS ON CACHE BOOL "Use single-TU builds (aka. Unity builds)")
|
|
7
|
-
else()
|
|
8
|
-
set(USE_UNITY_BUILDS OFF CACHE BOOL "Use single-TU builds (aka. Unity builds)")
|
|
9
|
-
endif()
|
|
10
|
-
|
|
11
|
-
function(add_node_addon)
|
|
12
|
-
cmake_parse_arguments(ARG "" "NAME" "SOURCES" ${ARGN})
|
|
13
|
-
add_library(${ARG_NAME} SHARED ${ARG_SOURCES} ${NODE_JS_SOURCES})
|
|
14
|
-
target_link_node(${ARG_NAME})
|
|
15
|
-
set_target_properties(${ARG_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
16
|
-
endfunction()
|
|
17
|
-
|
|
18
|
-
function(target_link_node TARGET)
|
|
19
|
-
target_include_directories(${TARGET} PRIVATE ${NODE_JS_INCLUDE_DIRS})
|
|
20
|
-
if(NODE_JS_LINK_DEF)
|
|
21
|
-
target_sources(${TARGET} PRIVATE node.lib)
|
|
22
|
-
endif()
|
|
23
|
-
if(NODE_JS_LINK_LIB)
|
|
24
|
-
target_link_libraries(${TARGET} PRIVATE ${NODE_JS_LINK_LIB})
|
|
25
|
-
endif()
|
|
26
|
-
target_compile_options(${TARGET} PRIVATE ${NODE_JS_COMPILE_FLAGS})
|
|
27
|
-
if(NODE_JS_LINK_FLAGS)
|
|
28
|
-
target_link_options(${TARGET} PRIVATE ${NODE_JS_LINK_FLAGS})
|
|
29
|
-
endif()
|
|
30
|
-
endfunction()
|
|
31
|
-
|
|
32
|
-
if(WIN32)
|
|
33
|
-
function(create_import_lib OUTPUT SRC)
|
|
34
|
-
if (MSVC)
|
|
35
|
-
add_custom_command(OUTPUT ${OUTPUT}
|
|
36
|
-
COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS}
|
|
37
|
-
/def:${SRC} /out:"${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}"
|
|
38
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
39
|
-
MAIN_DEPENDENCY ${SRC})
|
|
40
|
-
elseif(DEFINED NODE_JS_DLLTOOL_MACHINE)
|
|
41
|
-
add_custom_command(OUTPUT ${OUTPUT}
|
|
42
|
-
COMMAND ${CMAKE_DLLTOOL} -d ${SRC} -l "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}" -m ${NODE_JS_DLLTOOL_MACHINE}
|
|
43
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
44
|
-
MAIN_DEPENDENCY ${SRC})
|
|
45
|
-
else()
|
|
46
|
-
add_custom_command(OUTPUT ${OUTPUT}
|
|
47
|
-
COMMAND ${CMAKE_DLLTOOL} -d ${SRC} -l "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}"
|
|
48
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
49
|
-
MAIN_DEPENDENCY ${SRC})
|
|
50
|
-
endif()
|
|
51
|
-
endfunction()
|
|
52
|
-
endif()
|
|
53
|
-
|
|
54
|
-
if(NODE_JS_LINK_DEF)
|
|
55
|
-
create_import_lib(node.lib ${NODE_JS_LINK_DEF})
|
|
56
|
-
set(NODE_JS_LINK_LIB "${CMAKE_CURRENT_BINARY_DIR}/node.lib")
|
|
57
|
-
endif()
|
|
58
|
-
|
|
59
|
-
if(USE_UNITY_BUILDS)
|
|
60
|
-
function(enable_unity_build TARGET)
|
|
61
|
-
cmake_parse_arguments(ARG "" "" "EXCLUDE" ${ARGN})
|
|
62
|
-
|
|
63
|
-
get_target_property(sources ${TARGET} SOURCES)
|
|
64
|
-
string(GENEX_STRIP "${sources}" sources)
|
|
65
|
-
|
|
66
|
-
set(unity_file_c "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_unity.c")
|
|
67
|
-
set(unity_file_cpp "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_unity.cpp")
|
|
68
|
-
file(REMOVE ${unity_file_c} ${unity_file_cpp})
|
|
69
|
-
|
|
70
|
-
set(c_definitions "")
|
|
71
|
-
set(cpp_definitions "")
|
|
72
|
-
|
|
73
|
-
foreach(src ${sources})
|
|
74
|
-
if (src IN_LIST ARG_EXCLUDE)
|
|
75
|
-
continue()
|
|
76
|
-
endif()
|
|
77
|
-
|
|
78
|
-
get_source_file_property(language ${src} LANGUAGE)
|
|
79
|
-
get_property(definitions SOURCE ${src} PROPERTY COMPILE_DEFINITIONS)
|
|
80
|
-
if(IS_ABSOLUTE ${src})
|
|
81
|
-
set(src_full ${src})
|
|
82
|
-
else()
|
|
83
|
-
set(src_full "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
|
84
|
-
endif()
|
|
85
|
-
if(language STREQUAL "C")
|
|
86
|
-
set_source_files_properties(${src} PROPERTIES HEADER_FILE_ONLY 1)
|
|
87
|
-
file(APPEND ${unity_file_c} "#include \"${src_full}\"\n")
|
|
88
|
-
if (definitions)
|
|
89
|
-
set(c_definitions "${c_definitions} ${definitions}")
|
|
90
|
-
endif()
|
|
91
|
-
elseif(language STREQUAL "CXX")
|
|
92
|
-
set_source_files_properties(${src} PROPERTIES HEADER_FILE_ONLY 1)
|
|
93
|
-
file(APPEND ${unity_file_cpp} "#include \"${src_full}\"\n")
|
|
94
|
-
if (definitions)
|
|
95
|
-
set(cpp_definitions "${cpp_definitions} ${definitions}")
|
|
96
|
-
endif()
|
|
97
|
-
endif()
|
|
98
|
-
endforeach()
|
|
99
|
-
|
|
100
|
-
if(EXISTS ${unity_file_c})
|
|
101
|
-
target_sources(${TARGET} PRIVATE ${unity_file_c})
|
|
102
|
-
if(c_definitions)
|
|
103
|
-
set_source_files_properties(${unity_file_c} PROPERTIES COMPILE_DEFINITIONS ${c_definitions})
|
|
104
|
-
endif()
|
|
105
|
-
endif()
|
|
106
|
-
if(EXISTS ${unity_file_cpp})
|
|
107
|
-
target_sources(${TARGET} PRIVATE ${unity_file_cpp})
|
|
108
|
-
if(cpp_definitions)
|
|
109
|
-
set_source_files_properties(${unity_file_cpp} PROPERTIES COMPILE_DEFINITIONS ${cpp_definitions})
|
|
110
|
-
endif()
|
|
111
|
-
endif()
|
|
112
|
-
|
|
113
|
-
target_compile_definitions(${TARGET} PRIVATE -DUNITY_BUILD=1)
|
|
114
|
-
endfunction()
|
|
115
|
-
else()
|
|
116
|
-
function(enable_unity_build TARGET)
|
|
117
|
-
endfunction()
|
|
118
|
-
endif()
|
|
119
|
-
|
|
120
|
-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
121
|
-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)")
|
|
122
|
-
foreach(lang C CXX)
|
|
123
|
-
set(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} -mpopcnt -msse4.1 -msse4.2 -mssse3 -mcx16")
|
|
124
|
-
set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO "${CMAKE_${lang}_FLAGS_RELWITHDEBINFO} -mpopcnt -msse4.1 -msse4.2 -mssse3 -mcx16")
|
|
125
|
-
endforeach()
|
|
126
|
-
endif()
|
|
127
|
-
endif()
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"linux_ia32": {
|
|
3
|
-
"system": "Linux",
|
|
4
|
-
"processor": "i386",
|
|
5
|
-
"triplet": "i686-linux-gnu",
|
|
6
|
-
"sysroot": "../../tools/cross/sysroots/debian_i386"
|
|
7
|
-
},
|
|
8
|
-
"linux_x64": {
|
|
9
|
-
"system": "Linux",
|
|
10
|
-
"processor": "x86_64",
|
|
11
|
-
"triplet": "x86_64-linux-gnu",
|
|
12
|
-
"sysroot": "../../tools/cross/sysroots/debian_x64"
|
|
13
|
-
},
|
|
14
|
-
"linux_armhf": {
|
|
15
|
-
"system": "Linux",
|
|
16
|
-
"processor": "arm",
|
|
17
|
-
"triplet": "arm-linux-gnueabihf",
|
|
18
|
-
"sysroot": "../../tools/cross/sysroots/debian_arm32"
|
|
19
|
-
},
|
|
20
|
-
"linux_arm64": {
|
|
21
|
-
"system": "Linux",
|
|
22
|
-
"processor": "aarch64",
|
|
23
|
-
"triplet": "aarch64-linux-gnu",
|
|
24
|
-
"sysroot": "../../tools/cross/sysroots/debian_arm64"
|
|
25
|
-
},
|
|
26
|
-
"linux_riscv64d": {
|
|
27
|
-
"system": "Linux",
|
|
28
|
-
"processor": "riscv64",
|
|
29
|
-
"triplet": "riscv64-linux-gnu",
|
|
30
|
-
"sysroot": "../../tools/cross/sysroots/debian_riscv64"
|
|
31
|
-
},
|
|
32
|
-
"linux_loong64": {
|
|
33
|
-
"system": "Linux",
|
|
34
|
-
"processor": "loongarch64",
|
|
35
|
-
"triplet": "loongarch64-linux-gnu",
|
|
36
|
-
"sysroot": "../../tools/cross/sysroots/debian_loong64"
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
"win32_ia32": {
|
|
40
|
-
"system": "Windows",
|
|
41
|
-
"processor": "X86",
|
|
42
|
-
"lib": "win-x86",
|
|
43
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe;/SAFESEH:NO", "-A", "Win32"],
|
|
44
|
-
|
|
45
|
-
"triplet": "i386-pc-windows-msvc",
|
|
46
|
-
"linux": {
|
|
47
|
-
"sysroot": "../../tools/cross/sysroots/windows_i386",
|
|
48
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=-Wl,/DELAYLOAD:node.exe,/SAFESEH:NO", "-DNODE_JS_DLLTOOL_MACHINE=i386"],
|
|
49
|
-
"variables": {
|
|
50
|
-
"CMAKE_DLLTOOL": "llvm-dlltool",
|
|
51
|
-
"CMAKE_RC_COMPILER": "llvm-rc",
|
|
52
|
-
"CMAKE_C_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
53
|
-
"CMAKE_CXX_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
54
|
-
"CMAKE_EXE_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp",
|
|
55
|
-
"CMAKE_STATIC_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp",
|
|
56
|
-
"CMAKE_SHARED_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"win32_x64": {
|
|
61
|
-
"system": "Windows",
|
|
62
|
-
"processor": "AMD64",
|
|
63
|
-
"lib": "win-x64",
|
|
64
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe"],
|
|
65
|
-
|
|
66
|
-
"triplet": "x86_64-pc-windows-msvc",
|
|
67
|
-
"linux": {
|
|
68
|
-
"sysroot": "../../tools/cross/sysroots/windows_x64",
|
|
69
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=-Wl,/DELAYLOAD:node.exe", "-DNODE_JS_DLLTOOL_MACHINE=i386:x86-64"],
|
|
70
|
-
"variables": {
|
|
71
|
-
"CMAKE_DLLTOOL": "llvm-dlltool",
|
|
72
|
-
"CMAKE_RC_COMPILER": "llvm-rc",
|
|
73
|
-
"CMAKE_C_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
74
|
-
"CMAKE_CXX_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
75
|
-
"CMAKE_EXE_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp",
|
|
76
|
-
"CMAKE_STATIC_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp",
|
|
77
|
-
"CMAKE_SHARED_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/x86_64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/x86_64 -ldelayimp"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"win32_arm64": {
|
|
82
|
-
"system": "Windows",
|
|
83
|
-
"processor": "ARM64",
|
|
84
|
-
"lib": "win-arm64",
|
|
85
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe;/SAFESEH:NO", "-A", "ARM64"],
|
|
86
|
-
|
|
87
|
-
"triplet": "aarch64-pc-windows-msvc",
|
|
88
|
-
"linux": {
|
|
89
|
-
"sysroot": "../../tools/cross/sysroots/windows_arm64",
|
|
90
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=-Wl,/DELAYLOAD:node.exe,/SAFESEH:NO", "-DNODE_JS_DLLTOOL_MACHINE=arm64"],
|
|
91
|
-
"variables": {
|
|
92
|
-
"CMAKE_DLLTOOL": "llvm-dlltool",
|
|
93
|
-
"CMAKE_RC_COMPILER": "llvm-rc",
|
|
94
|
-
"CMAKE_C_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
95
|
-
"CMAKE_CXX_FLAGS": "-Xmicrosoft-windows-sys-root {{ sysroot }}",
|
|
96
|
-
"CMAKE_EXE_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/aarch64 -ldelayimp",
|
|
97
|
-
"CMAKE_STATIC_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/aarch64 -ldelayimp",
|
|
98
|
-
"CMAKE_SHARED_LINKER_FLAGS": "-Wl,-libpath:{{ sysroot }}/VC/Tools/MSVC/Current/lib/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/ucrt/aarch64,-libpath:{{ sysroot }}/Kits/10/Lib/Current/um/aarch64 -ldelayimp"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
"darwin_x64": {
|
|
104
|
-
"system": "Darwin",
|
|
105
|
-
"processor": "x86_64",
|
|
106
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=-undefined;dynamic_lookup", "-DCMAKE_OSX_ARCHITECTURES=x86_64"]
|
|
107
|
-
},
|
|
108
|
-
"darwin_arm64": {
|
|
109
|
-
"system": "Darwin",
|
|
110
|
-
"processor": "arm64",
|
|
111
|
-
"flags": ["-DNODE_JS_LINK_FLAGS=-undefined;dynamic_lookup", "-DCMAKE_OSX_ARCHITECTURES=arm64"]
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
"freebsd_x64": {
|
|
115
|
-
"system": "FreeBSD",
|
|
116
|
-
"processor": "amd64",
|
|
117
|
-
"triplet": "x86_64-unknown-freebsd",
|
|
118
|
-
"sysroot": "../../tools/cross/sysroots/freebsd_x64"
|
|
119
|
-
},
|
|
120
|
-
"freebsd_arm64": {
|
|
121
|
-
"system": "FreeBSD",
|
|
122
|
-
"processor": "arm64",
|
|
123
|
-
"triplet": "aarch64-unknown-freebsd",
|
|
124
|
-
"sysroot": "../../tools/cross/sysroots/freebsd_arm64"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
3
|
-
|
|
4
|
-
#include <stdlib.h>
|
|
5
|
-
#if !defined(NOMINMAX)
|
|
6
|
-
#define NOMINMAX
|
|
7
|
-
#endif
|
|
8
|
-
#if !defined(WIN32_LEAN_AND_MEAN)
|
|
9
|
-
#define WIN32_LEAN_AND_MEAN
|
|
10
|
-
#endif
|
|
11
|
-
#include <windows.h>
|
|
12
|
-
#include <delayimp.h>
|
|
13
|
-
|
|
14
|
-
static HMODULE node_dll;
|
|
15
|
-
|
|
16
|
-
static FARPROC WINAPI self_exe_hook(unsigned int event, DelayLoadInfo *info)
|
|
17
|
-
{
|
|
18
|
-
if (event == dliStartProcessing) {
|
|
19
|
-
node_dll = GetModuleHandleA("node.dll");
|
|
20
|
-
if (!node_dll) {
|
|
21
|
-
node_dll = GetModuleHandle(NULL);
|
|
22
|
-
}
|
|
23
|
-
return NULL;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (event == dliNotePreLoadLibrary && !stricmp(info->szDll, "node.exe"))
|
|
27
|
-
return (FARPROC)node_dll;
|
|
28
|
-
|
|
29
|
-
return NULL;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#if defined(__MINGW32__)
|
|
33
|
-
PfnDliHook __pfnDliNotifyHook2 = self_exe_hook;
|
|
34
|
-
#else
|
|
35
|
-
const PfnDliHook __pfnDliNotifyHook2 = self_exe_hook;
|
|
36
|
-
#endif
|
package/src/cnoke/cnoke.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
4
|
-
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const cnoke = require('./src/index.js');
|
|
9
|
-
|
|
10
|
-
const VALID_COMMANDS = ['build', 'configure', 'clean'];
|
|
11
|
-
|
|
12
|
-
main();
|
|
13
|
-
|
|
14
|
-
async function main() {
|
|
15
|
-
let config = {};
|
|
16
|
-
let command = 'build';
|
|
17
|
-
|
|
18
|
-
// Parse options
|
|
19
|
-
{
|
|
20
|
-
let i = 2;
|
|
21
|
-
|
|
22
|
-
if (process.argv.length >= 3 && process.argv[2][0] != '-') {
|
|
23
|
-
let cmd = process.argv[2];
|
|
24
|
-
|
|
25
|
-
if (VALID_COMMANDS.includes(cmd)) {
|
|
26
|
-
command = cmd;
|
|
27
|
-
i++;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for (; i < process.argv.length; i++) {
|
|
32
|
-
let arg = process.argv[i];
|
|
33
|
-
let value = null;
|
|
34
|
-
|
|
35
|
-
if (arg[0] == '-') {
|
|
36
|
-
if (arg.length > 2 && arg[1] != '-') {
|
|
37
|
-
value = arg.substr(2);
|
|
38
|
-
arg = arg.substr(0, 2);
|
|
39
|
-
} else if (arg[1] == '-') {
|
|
40
|
-
let offset = arg.indexOf('=');
|
|
41
|
-
|
|
42
|
-
if (offset > 2 && arg.length > offset + 1) {
|
|
43
|
-
value = arg.substr(offset + 1);
|
|
44
|
-
arg = arg.substr(0, offset);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (value == null && process.argv[i + 1] != null && process.argv[i + 1][0] != '-') {
|
|
48
|
-
value = process.argv[i + 1];
|
|
49
|
-
i++; // Skip this value next iteration
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (arg == '--help') {
|
|
54
|
-
print_usage();
|
|
55
|
-
return;
|
|
56
|
-
} else if (arg == '-D' || arg == '--directory') {
|
|
57
|
-
if (value == null)
|
|
58
|
-
throw new Error(`Missing value for ${arg}`);
|
|
59
|
-
|
|
60
|
-
config.project_dir = fs.realpathSync(value);
|
|
61
|
-
} else if (arg == '-P' || arg == '--package') {
|
|
62
|
-
if (value == null)
|
|
63
|
-
throw new Error(`Missing value for ${arg}`);
|
|
64
|
-
|
|
65
|
-
config.package_dir = fs.realpathSync(value);
|
|
66
|
-
} else if (arg == '-O' || arg == '--output') {
|
|
67
|
-
if (value == null)
|
|
68
|
-
throw new Error(`Missing value for ${arg}`);
|
|
69
|
-
|
|
70
|
-
config.output_directory = value;
|
|
71
|
-
} else if ((command == 'build' || command == 'configure') && arg == '--runtime') {
|
|
72
|
-
if (value == null)
|
|
73
|
-
throw new Error(`Missing value for ${arg}`);
|
|
74
|
-
if (!value.match(/^[0-9]+\.[0-9]+\.[0-9]+$/))
|
|
75
|
-
throw new Error(`Malformed runtime version '${value}'`);
|
|
76
|
-
|
|
77
|
-
config.runtime_version = value;
|
|
78
|
-
} else if ((command == 'build' || command == 'configure') && arg == '--clang') {
|
|
79
|
-
config.prefer_clang = true;
|
|
80
|
-
} else if ((command == 'build' || command == 'configure') && (arg == '-t' || arg == '--toolchain')) {
|
|
81
|
-
if (value == null)
|
|
82
|
-
throw new Error(`Missing value for ${arg}`);
|
|
83
|
-
|
|
84
|
-
config.toolchain = value;
|
|
85
|
-
} else if ((command == 'build' || command == 'configure') && (arg == '-c' || arg == '--config')) {
|
|
86
|
-
if (value == null)
|
|
87
|
-
throw new Error(`Missing value for ${arg}`);
|
|
88
|
-
|
|
89
|
-
switch (value.toLowerCase()) {
|
|
90
|
-
case 'relwithdebinfo': { config.mode = 'RelWithDebInfo'; } break;
|
|
91
|
-
case 'debug': { config.mode = 'Debug'; } break;
|
|
92
|
-
case 'release': { config.mode = 'Release'; } break;
|
|
93
|
-
|
|
94
|
-
default: {
|
|
95
|
-
throw new Error(`Unknown value '${value}' for ${arg}`);
|
|
96
|
-
} break;
|
|
97
|
-
}
|
|
98
|
-
} else if ((command == 'build' || command == 'configure') && arg == '--debug') {
|
|
99
|
-
config.mode = 'Debug';
|
|
100
|
-
} else if ((command == 'build' || command == 'configure') && arg == '--release') {
|
|
101
|
-
config.mode = 'Release';
|
|
102
|
-
} else if (command == 'build' && arg == '--prebuild') {
|
|
103
|
-
config.prebuild = true;
|
|
104
|
-
} else if (command == 'build' && arg == '--target') {
|
|
105
|
-
if (value == null)
|
|
106
|
-
throw new Error(`Missing value for ${arg}`);
|
|
107
|
-
|
|
108
|
-
config.targets = [value];
|
|
109
|
-
} else if (command == 'build' && (arg == '-v' || arg == '--verbose')) {
|
|
110
|
-
config.verbose = true;
|
|
111
|
-
} else {
|
|
112
|
-
if (arg[0] == '-') {
|
|
113
|
-
throw new Error(`Unexpected argument '${arg}'`);
|
|
114
|
-
} else {
|
|
115
|
-
throw new Error(`Unexpected value '${arg}'`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
let builder = new cnoke.Builder(config);
|
|
123
|
-
await builder[command]();
|
|
124
|
-
} catch (err) {
|
|
125
|
-
console.error(err);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function print_usage() {
|
|
131
|
-
let help = `Usage: cnoke [command] [options...]
|
|
132
|
-
|
|
133
|
-
Commands:
|
|
134
|
-
|
|
135
|
-
configure Configure CMake build
|
|
136
|
-
build Build project (configure if needed)
|
|
137
|
-
clean Clean build files
|
|
138
|
-
|
|
139
|
-
Options:
|
|
140
|
-
|
|
141
|
-
-D, --directory <DIR> Change source directory
|
|
142
|
-
(default: current working directory)
|
|
143
|
-
-P, --package <DIR> Change package directory
|
|
144
|
-
(default: current working directory)
|
|
145
|
-
-O, --output <DIR> Set explicit output directory
|
|
146
|
-
(default: ./build)
|
|
147
|
-
|
|
148
|
-
-c, --config <CONFIG> Change build type: RelWithDebInfo, Debug, Release
|
|
149
|
-
(default: ${cnoke.DefaultOptions.mode})
|
|
150
|
-
--debug Shortcut for --config Debug
|
|
151
|
-
--release Shortcut for --config Release
|
|
152
|
-
|
|
153
|
-
-t, --toolchain <TOOLCHAIN> Cross-compile for specific platform
|
|
154
|
-
--runtime <VERSION> Change node version
|
|
155
|
-
(default: ${process.version})
|
|
156
|
-
--clang Use Clang instead of default CMake compiler
|
|
157
|
-
|
|
158
|
-
--prebuild Use prebuilt binary if available
|
|
159
|
-
--target <TARGET> Only build the specified target
|
|
160
|
-
|
|
161
|
-
-v, --verbose Show build commands while building
|
|
162
|
-
|
|
163
|
-
The ARCH value is similar to process.arch, with the following differences:
|
|
164
|
-
|
|
165
|
-
- arm is changed to arm32hf or arm32sf depending on the floating-point ABI used (hard-float, soft-float)
|
|
166
|
-
- riscv32 is changed to riscv32sf, riscv32hf32, riscv32hf64 or riscv32hf128 depending on the floating-point ABI
|
|
167
|
-
- riscv64 is changed to riscv64sf, riscv64hf32, riscv64hf64 or riscv64hf128 depending on the floating-point ABI`;
|
|
168
|
-
|
|
169
|
-
console.log(help);
|
|
170
|
-
}
|
package/src/cnoke/package.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cnoke",
|
|
3
|
-
"version": "4.0.3",
|
|
4
|
-
"description": "Build native Node addons based on CMake, without extra dependency",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"native",
|
|
7
|
-
"addon",
|
|
8
|
-
"cmake",
|
|
9
|
-
"c",
|
|
10
|
-
"c++"
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://codeberg.org/Koromix/rygel.git"
|
|
15
|
-
},
|
|
16
|
-
"author": {
|
|
17
|
-
"name": "Niels Martignène",
|
|
18
|
-
"email": "niels.martignene@protonmail.com",
|
|
19
|
-
"url": "https://koromix.dev/"
|
|
20
|
-
},
|
|
21
|
-
"index": "src/index.js",
|
|
22
|
-
"bin": "cnoke.js",
|
|
23
|
-
"license": "MIT"
|
|
24
|
-
}
|