-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
53 lines (44 loc) · 997 Bytes
/
build.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { $ } from "bun";
import { log } from "~/log";
interface BuildOptions {
"fileName": string;
"target": string;
"arch"?: string;
}
const targets = {
"linux": {
"label": "Linux",
"arm": true
},
"darwin": {
"label": "macOS",
"arm": true
},
"windows": {
"label": "Windows",
"arm": false
}
};
async function build({ fileName, target, arch = "x64-modern" }: BuildOptions) {
if (arch === "arm64") {
fileName += "-arm";
}
const result = await $`bun build --compile --minify --sourcemap src/index.ts --target=bun-${target}-${arch} --outfile build/${fileName}`.text();
log.debug(result);
}
for (const [target, value] of Object.entries(targets)) {
log.info(`Building for ${value.label}...`);
const options: BuildOptions = {
"fileName": `ohm-${value.label.toLowerCase()}`,
"target": target
};
await build(options);
log.info("Built x64 binary.");
if (value.arm) {
await build({
...options,
"arch": "arm64"
});
log.info("Built ARM binary.");
}
}