diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 84b8c1d67..a85fde9e2 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -14,11 +14,72 @@ process.chdir(dir) import pkg from "../package.json" import { Script } from "@opencode-ai/script" -import { collectBinaries, collectTargets } from "./utils" +const singleFlag = process.argv.includes("--single") const skipInstall = process.argv.includes("--skip-install") -const targets = collectTargets() +const allTargets: { + os: string + arch: "arm64" | "x64" + abi?: "musl" + avx2?: false +}[] = [ + { + os: "linux", + arch: "arm64", + }, + { + os: "linux", + arch: "x64", + }, + { + os: "linux", + arch: "x64", + avx2: false, + }, + { + os: "linux", + arch: "arm64", + abi: "musl", + }, + { + os: "linux", + arch: "x64", + abi: "musl", + }, + { + os: "linux", + arch: "x64", + abi: "musl", + avx2: false, + }, + { + os: "darwin", + arch: "arm64", + }, + { + os: "darwin", + arch: "x64", + }, + { + os: "darwin", + arch: "x64", + avx2: false, + }, + { + os: "win32", + arch: "x64", + }, + { + os: "win32", + arch: "x64", + avx2: false, + }, +] + +const targets = singleFlag + ? allTargets.filter((item) => item.os === process.platform && item.arch === process.arch) + : allTargets await $`rm -rf dist` @@ -27,7 +88,17 @@ if (!skipInstall) { await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` } -for (const { item, name } of collectBinaries(targets)) { +for (const item of targets) { + const name = [ + pkg.name, + // changing to win32 flags npm for some reason + item.os === "win32" ? "windows" : item.os, + item.arch, + item.avx2 === false ? "baseline" : undefined, + item.abi === undefined ? undefined : item.abi, + ] + .filter(Boolean) + .join("-") console.log(`building ${name}`) await $`mkdir -p dist/${name}/bin` diff --git a/packages/opencode/script/utils.ts b/packages/opencode/script/utils.ts deleted file mode 100644 index d855eba69..000000000 --- a/packages/opencode/script/utils.ts +++ /dev/null @@ -1,87 +0,0 @@ -import pkg from "../package.json" - -type Target = { - os: string - arch: "arm64" | "x64" - abi?: "musl" - avx2?: false -} - -const allTargets: Target[] = [ - { - os: "linux", - arch: "arm64", - }, - { - os: "linux", - arch: "x64", - }, - { - os: "linux", - arch: "x64", - avx2: false, - }, - { - os: "linux", - arch: "arm64", - abi: "musl", - }, - { - os: "linux", - arch: "x64", - abi: "musl", - }, - { - os: "linux", - arch: "x64", - abi: "musl", - avx2: false, - }, - { - os: "darwin", - arch: "arm64", - }, - { - os: "darwin", - arch: "x64", - }, - { - os: "darwin", - arch: "x64", - avx2: false, - }, - { - os: "win32", - arch: "x64", - }, - { - os: "win32", - arch: "x64", - avx2: false, - }, -] - -const singleFlag = process.argv.includes("--single") - -export function collectTargets() { - return singleFlag - ? allTargets.filter((item) => item.os === process.platform && item.arch === process.arch) - : allTargets -} - -export function collectBinaries(targets: Target[]) { - return targets.map((item) => { - const name = [ - pkg.name, - // changing to win32 flags npm for some reason - item.os === "win32" ? "windows" : item.os, - item.arch, - item.avx2 === false ? "baseline" : undefined, - item.abi === undefined ? undefined : item.abi, - ] - .filter(Boolean) - .join("-") - - return { name, item } - }) -}