-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwrite-win32-def.js
More file actions
52 lines (45 loc) · 1.47 KB
/
write-win32-def.js
File metadata and controls
52 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const { resolve: resolvePath, join: joinPath } = require('path');
const { writeFile, mkdir } = require('fs/promises');
const { symbols } = require('..');
function getNodeApiDef() {
const symbolsSet = new Set();
for (const ver of Object.values(symbols)) {
for (const sym of ver.node_api_symbols) {
symbolsSet.add(sym);
}
for (const sym of ver.js_native_api_symbols) {
symbolsSet.add(sym);
}
}
return 'NAME NODE.EXE\nEXPORTS\n' + Array.from(symbolsSet).join('\n');
}
function getJsNativeApiDef() {
const symbolsSet = new Set();
for (const ver of Object.values(symbols)) {
for (const sym of ver.js_native_api_symbols) {
symbolsSet.add(sym);
}
}
return 'NAME NODE.EXE\nEXPORTS\n' + Array.from(symbolsSet).join('\n');
}
async function main() {
const def = resolvePath(__dirname, '../def');
try {
await mkdir(def)
} catch (e) {
if (e.code !== 'EEXIST') {
throw e;
}
}
const nodeApiDefPath = joinPath(def, 'node_api.def');
console.log(`Writing Windows .def file to ${nodeApiDefPath}`);
await writeFile(nodeApiDefPath, getNodeApiDef());
const jsNativeApiDefPath = joinPath(def, 'js_native_api.def');
console.log(`Writing Windows .def file to ${jsNativeApiDefPath}`);
await writeFile(jsNativeApiDefPath, getJsNativeApiDef());
}
main().catch(e => {
console.error(e);
process.exitCode = 1;
});