vitest-pool-assemblyscript 0.2.0
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/BINARYEN_VERSION +1 -0
- package/LICENSE +53 -0
- package/README.md +607 -0
- package/assembly/compare.ts +219 -0
- package/assembly/describe.ts +104 -0
- package/assembly/expect.ts +335 -0
- package/assembly/index.ts +14 -0
- package/assembly/options.ts +198 -0
- package/assembly/test.ts +147 -0
- package/assembly/tsconfig.json +6 -0
- package/binding.gyp +62 -0
- package/dist/ast-visitor-DC3SuTzs.mjs +310 -0
- package/dist/ast-visitor-DC3SuTzs.mjs.map +1 -0
- package/dist/compile-runner-8h0dBwG2.mjs +80 -0
- package/dist/compile-runner-8h0dBwG2.mjs.map +1 -0
- package/dist/compiler/transforms/strip-inline.d.mts +18 -0
- package/dist/compiler/transforms/strip-inline.d.mts.map +1 -0
- package/dist/compiler/transforms/strip-inline.mjs +38 -0
- package/dist/compiler/transforms/strip-inline.mjs.map +1 -0
- package/dist/compiler-CN6BRK_N.mjs +295 -0
- package/dist/compiler-CN6BRK_N.mjs.map +1 -0
- package/dist/config/index-v3.d.mts +111 -0
- package/dist/config/index-v3.d.mts.map +1 -0
- package/dist/config/index-v3.mjs +11 -0
- package/dist/config/index-v3.mjs.map +1 -0
- package/dist/config/index.d.mts +4 -0
- package/dist/config/index.mjs +8 -0
- package/dist/constants-CA50WBdr.mjs +130 -0
- package/dist/constants-CA50WBdr.mjs.map +1 -0
- package/dist/coverage-merge-0WqdC-dq.mjs +22 -0
- package/dist/coverage-merge-0WqdC-dq.mjs.map +1 -0
- package/dist/coverage-provider/index.d.mts +15 -0
- package/dist/coverage-provider/index.d.mts.map +1 -0
- package/dist/coverage-provider/index.mjs +535 -0
- package/dist/coverage-provider/index.mjs.map +1 -0
- package/dist/custom-provider-options-CF5C1kXb.d.mts +26 -0
- package/dist/custom-provider-options-CF5C1kXb.d.mts.map +1 -0
- package/dist/debug-IeEHsxy0.mjs +195 -0
- package/dist/debug-IeEHsxy0.mjs.map +1 -0
- package/dist/index-internal.d.mts +23 -0
- package/dist/index-internal.d.mts.map +1 -0
- package/dist/index-internal.mjs +4 -0
- package/dist/index-v3.d.mts +7 -0
- package/dist/index-v3.d.mts.map +1 -0
- package/dist/index-v3.mjs +206 -0
- package/dist/index-v3.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +8 -0
- package/dist/load-user-imports-J9eaAW0_.mjs +801 -0
- package/dist/load-user-imports-J9eaAW0_.mjs.map +1 -0
- package/dist/pool-runner-init-CEwLyNI3.d.mts +8 -0
- package/dist/pool-runner-init-CEwLyNI3.d.mts.map +1 -0
- package/dist/pool-runner-init-d5qScS41.mjs +400 -0
- package/dist/pool-runner-init-d5qScS41.mjs.map +1 -0
- package/dist/pool-thread/compile-worker-thread.d.mts +7 -0
- package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -0
- package/dist/pool-thread/compile-worker-thread.mjs +42 -0
- package/dist/pool-thread/compile-worker-thread.mjs.map +1 -0
- package/dist/pool-thread/test-worker-thread.d.mts +7 -0
- package/dist/pool-thread/test-worker-thread.d.mts.map +1 -0
- package/dist/pool-thread/test-worker-thread.mjs +39 -0
- package/dist/pool-thread/test-worker-thread.mjs.map +1 -0
- package/dist/pool-thread/v3-tinypool-thread.d.mts +7 -0
- package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -0
- package/dist/pool-thread/v3-tinypool-thread.mjs +57 -0
- package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -0
- package/dist/resolve-config-as1w-Qyz.mjs +65 -0
- package/dist/resolve-config-as1w-Qyz.mjs.map +1 -0
- package/dist/test-runner-B2BpyPNK.mjs +142 -0
- package/dist/test-runner-B2BpyPNK.mjs.map +1 -0
- package/dist/types-8KKo9Hbf.d.mts +228 -0
- package/dist/types-8KKo9Hbf.d.mts.map +1 -0
- package/dist/vitest-file-tasks-BUwzh375.mjs +61 -0
- package/dist/vitest-file-tasks-BUwzh375.mjs.map +1 -0
- package/dist/vitest-tasks-BKS7689f.mjs +319 -0
- package/dist/vitest-tasks-BKS7689f.mjs.map +1 -0
- package/dist/worker-rpc-channel-lbhK7Qz8.mjs +25 -0
- package/dist/worker-rpc-channel-lbhK7Qz8.mjs.map +1 -0
- package/package.json +112 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/scripts/install.js +91 -0
- package/scripts/setup-binaryen.js +179 -0
- package/src/native-instrumentation/addon.cpp +788 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export const TEST_OPTION_UNDEFINED: i32 = -1;
|
|
2
|
+
export const TEST_OPTION_FALSE: i32 = 0;
|
|
3
|
+
export const TEST_OPTION_TRUE: i32 = 1;
|
|
4
|
+
|
|
5
|
+
@final
|
|
6
|
+
export class TestOptions {
|
|
7
|
+
_valueOfTimeout: i32;
|
|
8
|
+
_valueOfRetry: i32;
|
|
9
|
+
_valueOfSkip: i32;
|
|
10
|
+
_valueOfOnly: i32;
|
|
11
|
+
_valueOfFails: i32;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a new TestOptions instance.
|
|
15
|
+
*
|
|
16
|
+
* Defaults are all explicitly undefined in AssemblyScript.
|
|
17
|
+
* They are merged with the vitest config (timeout, retry, allowOnly) and
|
|
18
|
+
* also with any suite-level options externally in pool functions.
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
timeout: i32 = TEST_OPTION_UNDEFINED,
|
|
22
|
+
retry: i32 = TEST_OPTION_UNDEFINED,
|
|
23
|
+
skip: i32 = TEST_OPTION_UNDEFINED,
|
|
24
|
+
only: i32 = TEST_OPTION_UNDEFINED,
|
|
25
|
+
fails: i32 = TEST_OPTION_UNDEFINED,
|
|
26
|
+
) {
|
|
27
|
+
this._valueOfTimeout = timeout;
|
|
28
|
+
this._valueOfRetry = retry;
|
|
29
|
+
this._valueOfSkip = skip;
|
|
30
|
+
this._valueOfOnly = only;
|
|
31
|
+
this._valueOfFails = fails;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Define the timeout threshold (in ms) for a specific test. Other options will be undefined. */
|
|
35
|
+
static timeout(timeoutMs: i32): TestOptions {
|
|
36
|
+
return new TestOptions(
|
|
37
|
+
timeoutMs,
|
|
38
|
+
TEST_OPTION_UNDEFINED,
|
|
39
|
+
TEST_OPTION_UNDEFINED,
|
|
40
|
+
TEST_OPTION_UNDEFINED,
|
|
41
|
+
TEST_OPTION_UNDEFINED
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
/** Set the timeout threshold (in ms) for a specific test. Other options remain unchanged. */
|
|
45
|
+
timeout(timeoutMs: i32): this {
|
|
46
|
+
this._valueOfTimeout = timeoutMs;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Define the number of retry attempts that will be made after the initial run
|
|
52
|
+
* when a specific test fails. Other options will be undefined.
|
|
53
|
+
*/
|
|
54
|
+
static retry(retryCount: i32): TestOptions {
|
|
55
|
+
return new TestOptions(
|
|
56
|
+
TEST_OPTION_UNDEFINED,
|
|
57
|
+
retryCount,
|
|
58
|
+
TEST_OPTION_UNDEFINED,
|
|
59
|
+
TEST_OPTION_UNDEFINED,
|
|
60
|
+
TEST_OPTION_UNDEFINED
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set the number of retry attempts that will be made after the initial run
|
|
65
|
+
* when a specific test fails. Other options remain unchanged.
|
|
66
|
+
*/
|
|
67
|
+
retry(retryCount: i32): this {
|
|
68
|
+
this._valueOfRetry = retryCount;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Define `skip` option for a specific test so that when true, it will still be registered
|
|
74
|
+
* but will not execute. Other options will be undefined.
|
|
75
|
+
*
|
|
76
|
+
* Setting to false has no additional effect (compared to not defining) when creating new TestOptions.
|
|
77
|
+
*/
|
|
78
|
+
static skip(isSkipped: bool = true): TestOptions {
|
|
79
|
+
return new TestOptions(
|
|
80
|
+
TEST_OPTION_UNDEFINED,
|
|
81
|
+
TEST_OPTION_UNDEFINED,
|
|
82
|
+
isSkipped ? TEST_OPTION_TRUE : TEST_OPTION_FALSE,
|
|
83
|
+
TEST_OPTION_UNDEFINED,
|
|
84
|
+
TEST_OPTION_UNDEFINED
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Set `skip` option for a specific test so that when true, it will still be registered
|
|
89
|
+
* but will not execute. Other options remain unchanged.
|
|
90
|
+
*/
|
|
91
|
+
skip(isSkipped: bool = true): this {
|
|
92
|
+
this._valueOfSkip = isSkipped ? TEST_OPTION_TRUE : TEST_OPTION_FALSE;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Define `only` option for a specific test so that when true (and allowOnly is globally true),
|
|
98
|
+
* it will execute exclusively while others NOT marked `only` will be skipped.
|
|
99
|
+
* Other options will be undefined.
|
|
100
|
+
*
|
|
101
|
+
* Setting to false has no additional effect (compared to not defining) when creating new TestOptions.
|
|
102
|
+
*/
|
|
103
|
+
static only(isOnly: bool = true): TestOptions {
|
|
104
|
+
return new TestOptions(
|
|
105
|
+
TEST_OPTION_UNDEFINED,
|
|
106
|
+
TEST_OPTION_UNDEFINED,
|
|
107
|
+
TEST_OPTION_UNDEFINED,
|
|
108
|
+
isOnly ? TEST_OPTION_TRUE : TEST_OPTION_FALSE,
|
|
109
|
+
TEST_OPTION_UNDEFINED
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Set `only` option for a specific test so that when true (and allowOnly is globally true),
|
|
114
|
+
* it will execute exclusively while others NOT marked `only` will be skipped.
|
|
115
|
+
* Other options remain unchanged.
|
|
116
|
+
*/
|
|
117
|
+
only(isOnly: bool = true): this {
|
|
118
|
+
this._valueOfOnly = isOnly ? TEST_OPTION_TRUE : TEST_OPTION_FALSE;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Define `fails` option for a specific test so that when true, it will only pass with at least
|
|
124
|
+
* one failing assertion. Other options will be undefined.
|
|
125
|
+
*
|
|
126
|
+
* Setting to false has no additional effect (compared to not defining) when creating new TestOptions.
|
|
127
|
+
*/
|
|
128
|
+
static fails(expectFailure: bool = true): TestOptions {
|
|
129
|
+
return new TestOptions(
|
|
130
|
+
TEST_OPTION_UNDEFINED,
|
|
131
|
+
TEST_OPTION_UNDEFINED,
|
|
132
|
+
TEST_OPTION_UNDEFINED,
|
|
133
|
+
TEST_OPTION_UNDEFINED,
|
|
134
|
+
expectFailure ? TEST_OPTION_TRUE : TEST_OPTION_FALSE
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Set `fails` option for a specific test so that when true, it will only pass with at least
|
|
139
|
+
* one failing assertion. Other options remain unchanged.
|
|
140
|
+
*/
|
|
141
|
+
fails(expectFailure: bool = true): this {
|
|
142
|
+
this._valueOfFails = expectFailure ? TEST_OPTION_TRUE : TEST_OPTION_FALSE;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private static mergeNullableInt(a: i32, b: i32, smallestWins: bool = false): i32 {
|
|
147
|
+
if (a < 0 && b < 0) {
|
|
148
|
+
return TEST_OPTION_UNDEFINED;
|
|
149
|
+
} else if (a >= 0 && b < 0) {
|
|
150
|
+
return a;
|
|
151
|
+
} else if (a < 0 && b >= 0) {
|
|
152
|
+
return b;
|
|
153
|
+
} else {
|
|
154
|
+
if (smallestWins) {
|
|
155
|
+
return a < b ? a : b;
|
|
156
|
+
} else {
|
|
157
|
+
return a < b ? b : a;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static __merge(left: TestOptions | null, right: TestOptions | null): TestOptions {
|
|
163
|
+
const leftDefined: bool = left !== null;
|
|
164
|
+
const rightDefined: bool = right !== null;
|
|
165
|
+
|
|
166
|
+
if ( !leftDefined && !rightDefined ) {
|
|
167
|
+
return new TestOptions();
|
|
168
|
+
} else if ( leftDefined && !rightDefined ) {
|
|
169
|
+
return left!;
|
|
170
|
+
} else if ( !leftDefined && rightDefined ) {
|
|
171
|
+
return right!;
|
|
172
|
+
} else {
|
|
173
|
+
return new TestOptions(
|
|
174
|
+
TestOptions.mergeNullableInt(left!._valueOfTimeout, right!._valueOfTimeout, true), // smallest timeout
|
|
175
|
+
TestOptions.mergeNullableInt(left!._valueOfRetry, right!._valueOfRetry), // largest retry count
|
|
176
|
+
TestOptions.mergeNullableInt(left!._valueOfSkip, right!._valueOfSkip), // true if either is true
|
|
177
|
+
TestOptions.mergeNullableInt(left!._valueOfOnly, right!._valueOfOnly), // true if either is true
|
|
178
|
+
TestOptions.mergeNullableInt(left!._valueOfFails, right!._valueOfFails), // true if either is true
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@operator.binary("&")
|
|
184
|
+
static __bitwiseAnd(left: TestOptions | null, right: TestOptions | null): TestOptions {
|
|
185
|
+
return TestOptions.__merge(left, right);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
__merge(other: TestOptions): TestOptions {
|
|
189
|
+
return TestOptions.__merge(this, other);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Defaults are all explicitly undefined in AssemblyScript.
|
|
195
|
+
* They are merged with the vitest config (timeout, retry, allowOnly) and
|
|
196
|
+
* also with any suite-level options externally in pool functions.
|
|
197
|
+
*/
|
|
198
|
+
export const DEFAULT_TEST_OPTIONS = new TestOptions();
|
package/assembly/test.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { TestOptions, DEFAULT_TEST_OPTIONS } from './options';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* @external functions are imported to the
|
|
5
|
+
* WASM execution environment from pool executor
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// @ts-ignore: top level decorators are supported in AssemblyScript
|
|
9
|
+
@external("__as_pool_env__", "__register_test")
|
|
10
|
+
declare function __register_test(
|
|
11
|
+
name: string,
|
|
12
|
+
fnIndex: u32,
|
|
13
|
+
timeout: i32,
|
|
14
|
+
retry: i32,
|
|
15
|
+
skip: i32,
|
|
16
|
+
only: i32,
|
|
17
|
+
fails: i32
|
|
18
|
+
): void;
|
|
19
|
+
|
|
20
|
+
export type TestCallback = () => void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Register a test (called during top-level code execution in _start())
|
|
24
|
+
*
|
|
25
|
+
* Notifies the Pool via __register_test callback with the test name and function index.
|
|
26
|
+
*/
|
|
27
|
+
export function test<T = TestCallback, U = TestOptions>(
|
|
28
|
+
name: string,
|
|
29
|
+
optionsOrFn: T,
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS // defaults all undefined here, merged with config & suite in JS
|
|
32
|
+
): void {
|
|
33
|
+
let fn: TestCallback;
|
|
34
|
+
let options: TestOptions;
|
|
35
|
+
|
|
36
|
+
if (isFunction(optionsOrFn) && fnOrOptions instanceof TestOptions) {
|
|
37
|
+
fn = optionsOrFn;
|
|
38
|
+
options = fnOrOptions;
|
|
39
|
+
} else if (optionsOrFn instanceof TestOptions && isFunction(fnOrOptions)) {
|
|
40
|
+
fn = fnOrOptions;
|
|
41
|
+
options = optionsOrFn;
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error("Invalid test() arguments");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
__register_test(
|
|
47
|
+
name,
|
|
48
|
+
fn.index,
|
|
49
|
+
options._valueOfTimeout,
|
|
50
|
+
options._valueOfRetry,
|
|
51
|
+
options._valueOfSkip,
|
|
52
|
+
options._valueOfOnly,
|
|
53
|
+
options._valueOfFails
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function testWithMergedOption<T = TestCallback, U = TestOptions>(
|
|
58
|
+
name: string,
|
|
59
|
+
optionToMerge: TestOptions,
|
|
60
|
+
optionsOrFn: T,
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
63
|
+
): void {
|
|
64
|
+
let fn: TestCallback;
|
|
65
|
+
let options: TestOptions;
|
|
66
|
+
|
|
67
|
+
if (isFunction(optionsOrFn) && fnOrOptions instanceof TestOptions) {
|
|
68
|
+
fn = optionsOrFn;
|
|
69
|
+
options = fnOrOptions;
|
|
70
|
+
} else if (optionsOrFn instanceof TestOptions && isFunction(fnOrOptions)) {
|
|
71
|
+
fn = fnOrOptions;
|
|
72
|
+
options = optionsOrFn;
|
|
73
|
+
} else {
|
|
74
|
+
throw new Error("Invalid test() arguments");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const merged = options.__merge(optionToMerge);
|
|
78
|
+
|
|
79
|
+
return test(name, merged, fn);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export namespace test {
|
|
83
|
+
export function skip<T = TestCallback, U = TestOptions>(
|
|
84
|
+
name: string,
|
|
85
|
+
optionsOrFn: T,
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
88
|
+
): void {
|
|
89
|
+
return testWithMergedOption(name, TestOptions.skip(), optionsOrFn, fnOrOptions);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function only<T = TestCallback, U = TestOptions>(
|
|
93
|
+
name: string,
|
|
94
|
+
optionsOrFn: T,
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
97
|
+
): void {
|
|
98
|
+
return testWithMergedOption(name, TestOptions.only(), optionsOrFn, fnOrOptions);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function fails<T = TestCallback, U = TestOptions>(
|
|
102
|
+
name: string,
|
|
103
|
+
optionsOrFn: T,
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
106
|
+
): void {
|
|
107
|
+
return testWithMergedOption(name, TestOptions.fails(), optionsOrFn, fnOrOptions);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function it<T = TestCallback, U = TestOptions>(
|
|
112
|
+
name: string,
|
|
113
|
+
optionsOrFn: T,
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
116
|
+
): void {
|
|
117
|
+
return test(name, optionsOrFn, fnOrOptions);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export namespace it {
|
|
121
|
+
export function skip<T = TestCallback, U = TestOptions>(
|
|
122
|
+
name: string,
|
|
123
|
+
optionsOrFn: T,
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
126
|
+
): void {
|
|
127
|
+
return testWithMergedOption(name, TestOptions.skip(), optionsOrFn, fnOrOptions);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function only<T = TestCallback, U = TestOptions>(
|
|
131
|
+
name: string,
|
|
132
|
+
optionsOrFn: T,
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
135
|
+
): void {
|
|
136
|
+
return testWithMergedOption(name, TestOptions.only(), optionsOrFn, fnOrOptions);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function fails<T = TestCallback, U = TestOptions>(
|
|
140
|
+
name: string,
|
|
141
|
+
optionsOrFn: T,
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
fnOrOptions: U = DEFAULT_TEST_OPTIONS
|
|
144
|
+
): void {
|
|
145
|
+
return testWithMergedOption(name, TestOptions.fails(), optionsOrFn, fnOrOptions);
|
|
146
|
+
}
|
|
147
|
+
}
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "wasm_binaryen_debug",
|
|
5
|
+
"sources": [
|
|
6
|
+
"src/native-instrumentation/addon.cpp"
|
|
7
|
+
],
|
|
8
|
+
"include_dirs": [
|
|
9
|
+
# node-addon-api C++ headers (N-API wrapper)
|
|
10
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
11
|
+
# Binaryen C++ API headers (downloaded by setup-binaryen.js)
|
|
12
|
+
"third_party/binaryen/src"
|
|
13
|
+
],
|
|
14
|
+
"defines": [
|
|
15
|
+
# Use N-API error handling instead of C++ exceptions for addon API calls.
|
|
16
|
+
# Our code still uses C++ exceptions internally (enabled per-platform below)
|
|
17
|
+
# for Binaryen operations — those are caught and converted to N-API errors.
|
|
18
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS",
|
|
19
|
+
# Disable C++ assert() in release builds (Binaryen headers use these)
|
|
20
|
+
"NDEBUG"
|
|
21
|
+
],
|
|
22
|
+
"conditions": [
|
|
23
|
+
["OS=='linux'", {
|
|
24
|
+
"libraries": [
|
|
25
|
+
"<(module_root_dir)/third_party/binaryen/lib/libbinaryen.a",
|
|
26
|
+
# Required for std::thread usage in Binaryen
|
|
27
|
+
"-lpthread"
|
|
28
|
+
],
|
|
29
|
+
# Enable C++ exceptions (node-gyp disables them by default)
|
|
30
|
+
"cflags_cc": ["-std=c++17", "-fexceptions", "-O3"],
|
|
31
|
+
"cflags!": ["-fno-exceptions"],
|
|
32
|
+
"cflags_cc!": ["-fno-exceptions"]
|
|
33
|
+
}],
|
|
34
|
+
["OS=='mac'", {
|
|
35
|
+
"libraries": [
|
|
36
|
+
"<(module_root_dir)/third_party/binaryen/lib/libbinaryen.a"
|
|
37
|
+
],
|
|
38
|
+
"xcode_settings": {
|
|
39
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
40
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
41
|
+
# Minimum macOS deployment target for C++17 support
|
|
42
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15",
|
|
43
|
+
"OTHER_CPLUSPLUSFLAGS": ["-std=c++17", "-fexceptions", "-O3"]
|
|
44
|
+
}
|
|
45
|
+
}],
|
|
46
|
+
["OS=='win'", {
|
|
47
|
+
# Windows uses .lib static library format
|
|
48
|
+
"libraries": [
|
|
49
|
+
"<(module_root_dir)/third_party/binaryen/lib/binaryen.lib"
|
|
50
|
+
],
|
|
51
|
+
"msvs_settings": {
|
|
52
|
+
"VCCLCompilerTool": {
|
|
53
|
+
# Enable C++ exception handling (/EHsc)
|
|
54
|
+
"ExceptionHandling": 1,
|
|
55
|
+
"AdditionalOptions": ["/std:c++17"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}]
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|