mirror of
https://github.com/Z3Prover/z3
synced 2025-06-08 07:03:23 +00:00
Update emscripten (#7473)
* fixes for newer emscripten thread handling behavior * fix return type for async wrapper functions * update prettier * update typescript and fix errors * update emscripten version in CI * update js readme about tests
This commit is contained in:
parent
4fbf54afd0
commit
e5f8327483
17 changed files with 275 additions and 108 deletions
|
@ -10,7 +10,7 @@ assert(process.argv.length === 4, `Usage: ${process.argv[0]} ${process.argv[1]}
|
|||
const wrapperFilePath = process.argv[2];
|
||||
const typesFilePath = process.argv[3];
|
||||
|
||||
function makeTsWrapper() {
|
||||
async function makeTsWrapper() {
|
||||
const subtypes = {
|
||||
__proto__: null,
|
||||
Z3_sort: 'Z3_ast',
|
||||
|
@ -339,8 +339,10 @@ function makeTsWrapper() {
|
|||
`.trim();
|
||||
}
|
||||
|
||||
// async functions are invocations of the wrapper from make-ts-wrapper.ts
|
||||
// the wrapper spawns a thread and returns void, so we need to use void as the return type here
|
||||
// prettier-ignore
|
||||
let invocation = `Mod.ccall('${isAsync ? "async_" : ""}${fn.name}', '${cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(", ")}])`;
|
||||
let invocation = `Mod.ccall('${isAsync ? "async_" : ""}${fn.name}', '${isAsync ? 'void' : cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(", ")}])`;
|
||||
|
||||
if (isAsync) {
|
||||
invocation = `await Mod.async_call(() => ${invocation})`;
|
||||
|
@ -462,13 +464,18 @@ export async function init(initModule: any) {
|
|||
`;
|
||||
|
||||
return {
|
||||
wrapperDocument: prettier.format(wrapperDocument, { singleQuote: true, parser: 'typescript' }),
|
||||
typesDocument: prettier.format(typesDocument, { singleQuote: true, parser: 'typescript' }),
|
||||
wrapperDocument: await prettier.format(wrapperDocument, { singleQuote: true, parser: 'typescript' }),
|
||||
typesDocument: await prettier.format(typesDocument, { singleQuote: true, parser: 'typescript' }),
|
||||
};
|
||||
}
|
||||
|
||||
const { wrapperDocument, typesDocument } = makeTsWrapper();
|
||||
fs.mkdirSync(path.dirname(wrapperFilePath), { recursive: true });
|
||||
fs.writeFileSync(wrapperFilePath, wrapperDocument);
|
||||
fs.mkdirSync(path.dirname(typesFilePath), { recursive: true });
|
||||
fs.writeFileSync(typesFilePath, typesDocument);
|
||||
(async () => {
|
||||
const { wrapperDocument, typesDocument } = await makeTsWrapper();
|
||||
fs.mkdirSync(path.dirname(wrapperFilePath), { recursive: true });
|
||||
fs.writeFileSync(wrapperFilePath, wrapperDocument);
|
||||
fs.mkdirSync(path.dirname(typesFilePath), { recursive: true });
|
||||
fs.writeFileSync(typesFilePath, typesDocument);
|
||||
})().catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue