koffi 2.3.1 → 2.3.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 +13 -0
- package/doc/misc.md +6 -0
- package/package.json +3 -16
- package/src/cnoke/LICENSE.txt +165 -0
- package/src/cnoke/README.md +97 -0
- package/src/cnoke/assets/FindCNoke.cmake +71 -0
- package/src/cnoke/assets/win_delay_hook.c +34 -0
- package/src/cnoke/cnoke.js +968 -0
- package/src/cnoke/package.json +25 -0
- package/src/koffi/build/2.3.2/koffi_darwin_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_darwin_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_freebsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_linux_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_linux_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_linux_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_openbsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_win32_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_win32_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.2/koffi_win32_x64.tar.gz +0 -0
- package/src/koffi/src/call.cc +0 -4
- package/src/koffi/src/ffi.cc +89 -87
- package/src/koffi/src/ffi.hh +13 -7
- package/src/koffi/src/index.d.ts +10 -1
- package/src/koffi/src/parser.cc +12 -10
- package/src/koffi/src/util.cc +80 -35
- package/src/koffi/src/util.hh +1 -1
- package/src/koffi/build/2.3.1/koffi_darwin_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_darwin_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_freebsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_linux_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_linux_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_linux_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_openbsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_win32_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_win32_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.1/koffi_win32_x64.tar.gz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.3
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.3.2
|
|
8
|
+
|
|
9
|
+
**Main changes:**
|
|
10
|
+
|
|
11
|
+
- Fix type parser issues (such as ignoring some [disposable qualifiers](calls.md#heap-allocated-values))
|
|
12
|
+
- Fix crash when using disposable types in output parameters
|
|
13
|
+
- Add basic [koffi.stats()](misc.md#usage-statistics) interface
|
|
14
|
+
|
|
15
|
+
**Other changes:**
|
|
16
|
+
|
|
17
|
+
- Avoid CNoke dependencies
|
|
18
|
+
- Clear out development dependencies from package.json
|
|
19
|
+
|
|
7
20
|
#### Koffi 2.3.1
|
|
8
21
|
|
|
9
22
|
**Main changes:**
|
package/doc/misc.md
CHANGED
|
@@ -95,3 +95,9 @@ async_heap_size | 512 kiB | Heap size for asynchronous calls
|
|
|
95
95
|
resident_async_pools | 2 | Number of resident pools for asynchronous calls
|
|
96
96
|
max_async_calls | 64 | Maximum number of ongoing asynchronous calls
|
|
97
97
|
max_type_size | 64 MiB | Maximum size of Koffi types (for arrays and structs)
|
|
98
|
+
|
|
99
|
+
## Usage statistics
|
|
100
|
+
|
|
101
|
+
*New in Koffi 2.3.2*
|
|
102
|
+
|
|
103
|
+
You can use `koffi.stats()` to get a few statistics related to Koffi.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koffi",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"stable": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
|
+
"stable": "2.3.2",
|
|
5
5
|
"description": "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"foreign",
|
|
@@ -21,22 +21,9 @@
|
|
|
21
21
|
"main": "src/koffi/src/index.js",
|
|
22
22
|
"types": "src/koffi/src/index.d.ts",
|
|
23
23
|
"scripts": {
|
|
24
|
-
"install": "cnoke --prebuild -d src/koffi"
|
|
24
|
+
"install": "./src/cnoke/cnoke.js --prebuild -d src/koffi"
|
|
25
25
|
},
|
|
26
26
|
"license": "LGPL-3.0",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"cnoke": "^3.2.2"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"chalk": "^4.1.2",
|
|
32
|
-
"ffi-napi": "^4.0.3",
|
|
33
|
-
"minimatch": "^5.0.1",
|
|
34
|
-
"node-ssh": "^12.0.3",
|
|
35
|
-
"raylib": "^0.9.2",
|
|
36
|
-
"ref-napi": "^3.0.3",
|
|
37
|
-
"ref-struct-di": "^1.1.1",
|
|
38
|
-
"tar": "^6.1.11"
|
|
39
|
-
},
|
|
40
27
|
"cnoke": {
|
|
41
28
|
"prebuild": "src/koffi/build/{{version}}/koffi_{{platform}}_{{arch}}.tar.gz",
|
|
42
29
|
"require": "./src/koffi/build/koffi.node",
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
configure Configure CMake build
|
|
69
|
+
build Build project (configure if needed)
|
|
70
|
+
clean Clean build files
|
|
71
|
+
|
|
72
|
+
Options:
|
|
73
|
+
-d, --directory <DIR> Change project directory
|
|
74
|
+
(default: current working directory)
|
|
75
|
+
|
|
76
|
+
-B, --config <CONFIG> Change build type: RelWithDebInfo, Debug, Release
|
|
77
|
+
(default: RelWithDebInfo)
|
|
78
|
+
-D, --debug Shortcut for --config Debug
|
|
79
|
+
|
|
80
|
+
--prebuild <URL> Set URL template to download prebuilt binaries
|
|
81
|
+
--require <PATH> Require specified module, drop prebuild if it fails
|
|
82
|
+
|
|
83
|
+
-a, --arch <ARCH> Change architecture and ABI
|
|
84
|
+
(default: x64)
|
|
85
|
+
-v, --runtime-version <VERSION> Change node version
|
|
86
|
+
(default: v16.14.0)
|
|
87
|
+
-t, --toolset <TOOLSET> Change default CMake toolset
|
|
88
|
+
-C, --prefer-clang Use Clang instead of default CMake compiler
|
|
89
|
+
|
|
90
|
+
--verbose Show build commands while building
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The ARCH value is similar to process.arch, with the following differences:
|
|
94
|
+
|
|
95
|
+
- arm is changed to arm32hf or arm32sf depending on the floating-point ABI used (hard-float, soft-float)
|
|
96
|
+
- riscv32 is changed to riscv32sf, riscv32hf32, riscv32hf64 or riscv32hf128 depending on the floating-point ABI
|
|
97
|
+
- riscv64 is changed to riscv64sf, riscv64hf32, riscv64hf64 or riscv64hf128 depending on the floating-point ABI
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# This program is free software: you can redistribute it and/or modify
|
|
2
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
3
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
4
|
+
# (at your option) any later version.
|
|
5
|
+
#
|
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9
|
+
# GNU Lesser General Public License for more details.
|
|
10
|
+
#
|
|
11
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
12
|
+
# along with this program. If not, see https://www.gnu.org/licenses/.
|
|
13
|
+
|
|
14
|
+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR
|
|
15
|
+
CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|
16
|
+
set(USE_UNITY_BUILDS ON CACHE BOOL "Use single-TU builds (aka. Unity builds)")
|
|
17
|
+
else()
|
|
18
|
+
set(USE_UNITY_BUILDS OFF CACHE BOOL "Use single-TU builds (aka. Unity builds)")
|
|
19
|
+
endif()
|
|
20
|
+
|
|
21
|
+
function(add_node_addon)
|
|
22
|
+
cmake_parse_arguments(ARG "" "NAME" "SOURCES" ${ARGN})
|
|
23
|
+
|
|
24
|
+
add_library(${ARG_NAME} SHARED ${ARG_SOURCES} ${NODE_JS_SOURCES})
|
|
25
|
+
set_target_properties(${ARG_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
26
|
+
target_include_directories(${ARG_NAME} PRIVATE ${NODE_JS_INCLUDE_DIRS})
|
|
27
|
+
target_link_libraries(${ARG_NAME} PRIVATE ${NODE_JS_LIBRARIES})
|
|
28
|
+
target_compile_options(${ARG_NAME} PRIVATE ${NODE_JS_COMPILE_FLAGS})
|
|
29
|
+
if (NODE_JS_LINK_FLAGS)
|
|
30
|
+
target_link_options(${ARG_NAME} PRIVATE ${NODE_JS_LINK_FLAGS})
|
|
31
|
+
endif()
|
|
32
|
+
endfunction()
|
|
33
|
+
|
|
34
|
+
if(USE_UNITY_BUILDS)
|
|
35
|
+
function(enable_unity_build TARGET)
|
|
36
|
+
get_target_property(sources ${TARGET} SOURCES)
|
|
37
|
+
string(GENEX_STRIP "${sources}" sources)
|
|
38
|
+
|
|
39
|
+
set(unity_file_c "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_unity.c")
|
|
40
|
+
set(unity_file_cpp "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_unity.cpp")
|
|
41
|
+
file(REMOVE ${unity_file_c} ${unity_file_cpp})
|
|
42
|
+
|
|
43
|
+
foreach(src ${sources})
|
|
44
|
+
get_source_file_property(language ${src} LANGUAGE)
|
|
45
|
+
if(IS_ABSOLUTE ${src})
|
|
46
|
+
set(src_full ${src})
|
|
47
|
+
else()
|
|
48
|
+
set(src_full "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
|
49
|
+
endif()
|
|
50
|
+
if(language STREQUAL "C")
|
|
51
|
+
set_source_files_properties(${src} PROPERTIES HEADER_FILE_ONLY 1)
|
|
52
|
+
file(APPEND ${unity_file_c} "#include \"${src_full}\"\n")
|
|
53
|
+
elseif(language STREQUAL "CXX")
|
|
54
|
+
set_source_files_properties(${src} PROPERTIES HEADER_FILE_ONLY 1)
|
|
55
|
+
file(APPEND ${unity_file_cpp} "#include \"${src_full}\"\n")
|
|
56
|
+
endif()
|
|
57
|
+
endforeach()
|
|
58
|
+
|
|
59
|
+
if(EXISTS ${unity_file_c})
|
|
60
|
+
target_sources(${TARGET} PRIVATE ${unity_file_c})
|
|
61
|
+
endif()
|
|
62
|
+
if(EXISTS ${unity_file_cpp})
|
|
63
|
+
target_sources(${TARGET} PRIVATE ${unity_file_cpp})
|
|
64
|
+
endif()
|
|
65
|
+
|
|
66
|
+
target_compile_definitions(${TARGET} PRIVATE -DUNITY_BUILD=1)
|
|
67
|
+
endfunction()
|
|
68
|
+
else()
|
|
69
|
+
function(enable_unity_build TARGET)
|
|
70
|
+
endfunction()
|
|
71
|
+
endif()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// This program is free software: you can redistribute it and/or modify
|
|
2
|
+
// it under the terms of the GNU Lesser General Public License as published by
|
|
3
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
4
|
+
// (at your option) any later version.
|
|
5
|
+
//
|
|
6
|
+
// This program is distributed in the hope that it will be useful,
|
|
7
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9
|
+
// GNU Lesser General Public License for more details.
|
|
10
|
+
//
|
|
11
|
+
// You should have received a copy of the GNU Lesser General Public License
|
|
12
|
+
// along with this program. If not, see https://www.gnu.org/licenses/.
|
|
13
|
+
|
|
14
|
+
#include <stdlib.h>
|
|
15
|
+
#ifndef NOMINMAX
|
|
16
|
+
#define NOMINMAX
|
|
17
|
+
#endif
|
|
18
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
19
|
+
#define WIN32_LEAN_AND_MEAN
|
|
20
|
+
#endif
|
|
21
|
+
#include <windows.h>
|
|
22
|
+
#include <delayimp.h>
|
|
23
|
+
|
|
24
|
+
static FARPROC WINAPI self_exe_hook(unsigned int event, DelayLoadInfo *info)
|
|
25
|
+
{
|
|
26
|
+
if (event == dliNotePreLoadLibrary && !stricmp(info->szDll, "node.exe")) {
|
|
27
|
+
HMODULE h = GetModuleHandle(NULL);
|
|
28
|
+
return (FARPROC)h;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return NULL;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PfnDliHook __pfnDliNotifyHook2 = self_exe_hook;
|