mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Throw error when target executable cannot be found (#764)
This commit is contained in:
parent
7f156b6ef9
commit
e5915821be
2 changed files with 7 additions and 1 deletions
BIN
gen/standalone.c
BIN
gen/standalone.c
Binary file not shown.
|
@ -48,7 +48,13 @@ export function compileStandalone(inFile, outFile, targetExe) {
|
||||||
const bytecode = new Uint8Array(bjson.write(code, JS_WRITE_OBJ_BYTECODE | JS_WRITE_OBJ_REFERENCE | JS_WRITE_OBJ_STRIP_SOURCE));
|
const bytecode = new Uint8Array(bjson.write(code, JS_WRITE_OBJ_BYTECODE | JS_WRITE_OBJ_REFERENCE | JS_WRITE_OBJ_STRIP_SOURCE));
|
||||||
|
|
||||||
// Step 2: copy the bytecode to the end of the executable and add a marker.
|
// Step 2: copy the bytecode to the end of the executable and add a marker.
|
||||||
const exe = std.loadFile(targetExe ?? globalThis.argv0, { binary: true });
|
const exeFileName = targetExe ?? globalThis.argv0;
|
||||||
|
const exe = std.loadFile(exeFileName, { binary: true });
|
||||||
|
|
||||||
|
if (!exe) {
|
||||||
|
throw new Error(`failed to open executable: ${exeFileName}`);
|
||||||
|
}
|
||||||
|
|
||||||
const exeSize = exe.length;
|
const exeSize = exe.length;
|
||||||
const newBuffer = exe.buffer.transfer(exeSize + bytecode.length + Trailer.Size);
|
const newBuffer = exe.buffer.transfer(exeSize + bytecode.length + Trailer.Size);
|
||||||
const newExe = new Uint8Array(newBuffer);
|
const newExe = new Uint8Array(newBuffer);
|
||||||
|
|
Loading…
Reference in a new issue