Build binaries for all supported Deno targets in `_dist.ts`

main 2022.07.27
idylls 2 years ago
parent dd9a2f4283
commit 4805016532
Signed by: idylls
GPG Key ID: 8A7167CBC2CC9F0F

@ -1,5 +1,3 @@
/// <reference lib="deno.unstable" />
import { bundle } from "./build_deps/emit.ts";
import { ensureDir } from "./build_deps/fs.ts";
import { build } from "./_build.ts";
@ -13,20 +11,29 @@ export const dist = async () => {
inlineSourceMap: true,
},
});
const exe = Deno.run({ cmd: [
"deno",
"compile",
"--output",
"dist/statue",
"backend/main.ts",
], });
const [b_, exe_] = await Promise.all([b, exe.status()]);
if (!exe_.success) {
console.error("Failed to build executable");
throw new Error(`${exe_.code}`);
}
const exes = [
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
"x86_64-apple-darwin",
"aarch64-apple-darwin",
].map(async (target) => {
const status = await Deno.run({ cmd: [
"deno",
"compile",
"-A",
`--target=${target}`,
"--output",
`dist/statue-${target}`,
"backend/main.ts",
], }).status();
if (!status.success) {
throw new Error(`Failed to compile for ${target}`);
}
});
const [b_] = await Promise.all([b, ...exes]);
await Deno.writeTextFile("dist/statue.js", b_.code);
};

Loading…
Cancel
Save