From 2efbf2650fbd74458730c17a0a3760fc6232a8fc Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Tue, 27 Jan 2026 09:28:42 +0900 Subject: [PATCH] fix(cli): add baseline builds for non-AVX2 CPUs (#1154) --- packages/darwin-x64-baseline/package.json | 22 ++++++ packages/linux-x64-baseline/package.json | 25 ++++++ packages/linux-x64-musl-baseline/package.json | 25 ++++++ packages/windows-x64-baseline/package.json | 22 ++++++ script/build-binaries.test.ts | 79 +++++++++++++++++++ script/build-binaries.ts | 6 +- 6 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 packages/darwin-x64-baseline/package.json create mode 100644 packages/linux-x64-baseline/package.json create mode 100644 packages/linux-x64-musl-baseline/package.json create mode 100644 packages/windows-x64-baseline/package.json create mode 100644 script/build-binaries.test.ts diff --git a/packages/darwin-x64-baseline/package.json b/packages/darwin-x64-baseline/package.json new file mode 100644 index 000000000..027db722d --- /dev/null +++ b/packages/darwin-x64-baseline/package.json @@ -0,0 +1,22 @@ +{ + "name": "oh-my-opencode-darwin-x64-baseline", + "version": "3.1.1", + "description": "Platform-specific binary for oh-my-opencode (darwin-x64-baseline, no AVX2)", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-yeongyu/oh-my-opencode" + }, + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin" + ], + "bin": { + "oh-my-opencode": "./bin/oh-my-opencode" + } +} diff --git a/packages/linux-x64-baseline/package.json b/packages/linux-x64-baseline/package.json new file mode 100644 index 000000000..13d1448b6 --- /dev/null +++ b/packages/linux-x64-baseline/package.json @@ -0,0 +1,25 @@ +{ + "name": "oh-my-opencode-linux-x64-baseline", + "version": "3.1.1", + "description": "Platform-specific binary for oh-my-opencode (linux-x64-baseline, no AVX2)", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-yeongyu/oh-my-opencode" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "files": [ + "bin" + ], + "bin": { + "oh-my-opencode": "./bin/oh-my-opencode" + } +} diff --git a/packages/linux-x64-musl-baseline/package.json b/packages/linux-x64-musl-baseline/package.json new file mode 100644 index 000000000..4ae51a0eb --- /dev/null +++ b/packages/linux-x64-musl-baseline/package.json @@ -0,0 +1,25 @@ +{ + "name": "oh-my-opencode-linux-x64-musl-baseline", + "version": "3.1.1", + "description": "Platform-specific binary for oh-my-opencode (linux-x64-musl-baseline, no AVX2)", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-yeongyu/oh-my-opencode" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "files": [ + "bin" + ], + "bin": { + "oh-my-opencode": "./bin/oh-my-opencode" + } +} diff --git a/packages/windows-x64-baseline/package.json b/packages/windows-x64-baseline/package.json new file mode 100644 index 000000000..f711918b8 --- /dev/null +++ b/packages/windows-x64-baseline/package.json @@ -0,0 +1,22 @@ +{ + "name": "oh-my-opencode-windows-x64-baseline", + "version": "3.1.1", + "description": "Platform-specific binary for oh-my-opencode (windows-x64-baseline, no AVX2)", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/code-yeongyu/oh-my-opencode" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin" + ], + "bin": { + "oh-my-opencode": "./bin/oh-my-opencode.exe" + } +} diff --git a/script/build-binaries.test.ts b/script/build-binaries.test.ts new file mode 100644 index 000000000..a90797b32 --- /dev/null +++ b/script/build-binaries.test.ts @@ -0,0 +1,79 @@ +// script/build-binaries.test.ts +// Tests for platform binary build configuration + +import { describe, expect, it } from "bun:test"; + +// Import PLATFORMS from build-binaries.ts +// We need to export it first, but for now we'll test the expected structure +const EXPECTED_BASELINE_TARGETS = [ + "bun-linux-x64-baseline", + "bun-linux-x64-musl-baseline", + "bun-darwin-x64-baseline", + "bun-windows-x64-baseline", +]; + +describe("build-binaries", () => { + describe("PLATFORMS array", () => { + it("includes baseline variants for non-AVX2 CPU support", async () => { + // given + const module = await import("./build-binaries.ts"); + const platforms = (module as { PLATFORMS: { target: string }[] }).PLATFORMS; + const targets = platforms.map((p) => p.target); + + // when + const hasAllBaselineTargets = EXPECTED_BASELINE_TARGETS.every((baseline) => + targets.includes(baseline) + ); + + // then + expect(hasAllBaselineTargets).toBe(true); + for (const baseline of EXPECTED_BASELINE_TARGETS) { + expect(targets).toContain(baseline); + } + }); + + it("has correct directory names for baseline platforms", async () => { + // given + const module = await import("./build-binaries.ts"); + const platforms = (module as { PLATFORMS: { dir: string; target: string }[] }).PLATFORMS; + + // when + const baselinePlatforms = platforms.filter((p) => p.target.includes("baseline")); + + // then + expect(baselinePlatforms.length).toBe(4); + expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-baseline"); + expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-musl-baseline"); + expect(baselinePlatforms.map((p) => p.dir)).toContain("darwin-x64-baseline"); + expect(baselinePlatforms.map((p) => p.dir)).toContain("windows-x64-baseline"); + }); + + it("has correct binary names for baseline platforms", async () => { + // given + const module = await import("./build-binaries.ts"); + const platforms = (module as { PLATFORMS: { dir: string; target: string; binary: string }[] }).PLATFORMS; + + // when + const windowsBaseline = platforms.find((p) => p.target === "bun-windows-x64-baseline"); + const linuxBaseline = platforms.find((p) => p.target === "bun-linux-x64-baseline"); + + // then + expect(windowsBaseline?.binary).toBe("oh-my-opencode.exe"); + expect(linuxBaseline?.binary).toBe("oh-my-opencode"); + }); + + it("has descriptions mentioning no AVX2 for baseline platforms", async () => { + // given + const module = await import("./build-binaries.ts"); + const platforms = (module as { PLATFORMS: { target: string; description: string }[] }).PLATFORMS; + + // when + const baselinePlatforms = platforms.filter((p) => p.target.includes("baseline")); + + // then + for (const platform of baselinePlatforms) { + expect(platform.description).toContain("no AVX2"); + } + }); + }); +}); diff --git a/script/build-binaries.ts b/script/build-binaries.ts index a03899429..cfc65c685 100644 --- a/script/build-binaries.ts +++ b/script/build-binaries.ts @@ -13,14 +13,18 @@ interface PlatformTarget { description: string; } -const PLATFORMS: PlatformTarget[] = [ +export const PLATFORMS: PlatformTarget[] = [ { dir: "darwin-arm64", target: "bun-darwin-arm64", binary: "oh-my-opencode", description: "macOS ARM64" }, { dir: "darwin-x64", target: "bun-darwin-x64", binary: "oh-my-opencode", description: "macOS x64" }, + { dir: "darwin-x64-baseline", target: "bun-darwin-x64-baseline", binary: "oh-my-opencode", description: "macOS x64 (no AVX2)" }, { dir: "linux-x64", target: "bun-linux-x64", binary: "oh-my-opencode", description: "Linux x64 (glibc)" }, + { dir: "linux-x64-baseline", target: "bun-linux-x64-baseline", binary: "oh-my-opencode", description: "Linux x64 (glibc, no AVX2)" }, { dir: "linux-arm64", target: "bun-linux-arm64", binary: "oh-my-opencode", description: "Linux ARM64 (glibc)" }, { dir: "linux-x64-musl", target: "bun-linux-x64-musl", binary: "oh-my-opencode", description: "Linux x64 (musl)" }, + { dir: "linux-x64-musl-baseline", target: "bun-linux-x64-musl-baseline", binary: "oh-my-opencode", description: "Linux x64 (musl, no AVX2)" }, { dir: "linux-arm64-musl", target: "bun-linux-arm64-musl", binary: "oh-my-opencode", description: "Linux ARM64 (musl)" }, { dir: "windows-x64", target: "bun-windows-x64", binary: "oh-my-opencode.exe", description: "Windows x64" }, + { dir: "windows-x64-baseline", target: "bun-windows-x64-baseline", binary: "oh-my-opencode.exe", description: "Windows x64 (no AVX2)" }, ]; const ENTRY_POINT = "src/cli/index.ts";