aboutsummaryrefslogtreecommitdiff
path: root/misc/opencode/files/patch-packages_cli_script_build.ts
blob: c35100bfb8a7f30dcea1d84c0df186c28b7ea379 (plain) (blame)
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
Teach OpenCode's CLI build script about FreeBSD.

Upstream's target list only covers linux, darwin and win32, and its per-target
plugins assume a native @parcel/watcher package and bytecode support, neither
of which exists on FreeBSD:

  * add the freebsd arm64/x64 targets so `OPENCODE_TARGET=freebsd-<arch>`
    resolves and `Bun.build({ compile: { target: "bun-freebsd-<arch>" } })`
    produces a FreeBSD executable;
  * keep the real watcher binding on FreeBSD, since the port builds the native
    kqueue addon and installs it next to the executable;
  * disable bytecode on FreeBSD, where bun does not emit it.

--- packages/cli/script/build.ts.orig
+++ packages/cli/script/build.ts
@@ -52,6 +52,8 @@
   { os: "win32", arch: "arm64" },
   { os: "win32", arch: "x64" },
   { os: "win32", arch: "x64", avx2: false },
+  { os: "freebsd", arch: "arm64" },
+  { os: "freebsd", arch: "x64" },
 ]
 
 const targets =
@@ -143,6 +145,7 @@
   const parcelWatcherPlugin: BunPlugin = {
     name: "parcel-watcher-binding",
     setup(build) {
+      if (item.os === "freebsd") return
       build.onLoad({ filter: /filesystem[/\\]watcher-binding\.ts$/ }, () => ({
         contents: `export default () => require(${JSON.stringify(parcelWatcherPackage)})`,
         loader: "js",
@@ -167,7 +170,7 @@
     external: ["node-gyp"],
     format: "esm",
     minify: true,
-    bytecode: true,
+    bytecode: item.os !== "freebsd",
     sourcemap: Script.channel === "dev" || Script.channel === "local" ? "inline" : "none",
     splitting: true,
     compile: {