WXGame/box1/Assets/WX-WASM-SDK-V2/Editor/Node/dump_wasm_symbol.mjs
2024-10-25 18:09:59 +08:00

23 lines
751 B
JavaScript

import binaryen from "binaryen";
import process from "process";
import fs from "fs";
if (process.argv.length < 3) {
console.error("cannot find wasmcode, Usage: node dump_wasm_symbo.mjs <your_minigame_dir>");
process.exit(-1);
}
let dir = process.argv[2];
if (!dir.endsWith("/")) {
dir += "/";
}
let bin = fs.readFileSync(dir + "webgl/Build/webgl.wasm");
binaryen.then(function(binaryenOb){
let mod = binaryenOb.readBinary(bin);
let symbols = {};
for (let i = 0; i < mod.getNumFunctions(); ++i) {
let ref = mod.getFunctionByIndex(i);
let func = binaryenOb.getFunctionInfo(ref);
symbols[i] = func.name;
}
fs.writeFileSync(dir + "minigame/webgl.wasm.symbols.unityweb", JSON.stringify(symbols));
})