Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide def file for windows import lib #17

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/sync-headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
VERSION=${COMMIT_MESSAGE##* }
echo $COMMIT_MESSAGE
npm run --silent write-symbols
npm run --silent write-win32-def
CHANGED_FILES=$(git diff --name-only)
BRANCH_NAME="update-headers/${VERSION}"
if [ -z "$CHANGED_FILES" ]; then
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
},
"scripts": {
"update-headers": "node --no-warnings scripts/update-headers.js",
"write-symbols": "node --no-warnings scripts/write-symbols.js"
"write-symbols": "node --no-warnings scripts/write-symbols.js",
"write-win32-def": "node --no-warnings scripts/write-win32-def.js"
},
"version": "0.0.4",
"support": true
}

43 changes: 43 additions & 0 deletions scripts/write-win32-def.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const { resolve: resolvePath } = require('path');
const { writeFile } = 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 nodeApiDefPath = resolvePath(__dirname, '../node_api.def');
console.log(`Writing Windows .def file to ${nodeApiDefPath}`);
await writeFile(nodeApiDefPath, getNodeApiDef());

const jsNativeApiDefPath = resolvePath(__dirname, '../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;
});