mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Stop swallowing errors from create_hash_table during the build If src/codegen/create_hash_table can't be run due to some reason (e.g. due to missing Math::BigInt Perl module) the build continues but fails later, during bindings compilation, because the generated files are empty. Fix it by handling the failure to run create_hash_table properly. Closes #7074 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
34 lines
913 B
TypeScript
34 lines
913 B
TypeScript
import { spawn } from "bun";
|
|
import path from "path";
|
|
import { writeIfNotChanged } from "./helpers";
|
|
|
|
const input = process.argv[2];
|
|
const output = process.argv[3];
|
|
|
|
const create_hash_table = path.join(import.meta.dir, "./create_hash_table");
|
|
|
|
const proc = spawn({
|
|
cmd: [create_hash_table, input],
|
|
stdout: "pipe",
|
|
stderr: "inherit",
|
|
});
|
|
await proc.exited;
|
|
if (proc.exitCode !== 0) {
|
|
console.log(
|
|
"Failed to generate " +
|
|
output +
|
|
", create_hash_table exited with " +
|
|
(proc.exitCode || "") +
|
|
(proc.signalCode || ""),
|
|
);
|
|
process.exit(1);
|
|
}
|
|
let str = await new Response(proc.stdout).text();
|
|
str = str.replaceAll(/^\/\/.*$/gm, "");
|
|
str = str.replaceAll(/^#include.*$/gm, "");
|
|
str = str.replaceAll(`namespace JSC {`, "");
|
|
str = str.replaceAll(`} // namespace JSC`, "");
|
|
str = "// File generated via `static-hash-table.ts`\n" + str.trim() + "\n";
|
|
|
|
writeIfNotChanged(output, str);
|