Files
oh-my-pi/scripts/ci-build-native.ts
T
can1357 52719d1a7c refactor: restructured monorepo TypeScript config and build tasks for unified setup
- Migrated all package tsconfig files to extend tsconfig.workspace.json for unified TypeScript configuration across monorepo.
- Consolidated build and check scripts across 10+ packages to use biome for linting/formatting with separate type checking via tsgo.
- Renamed build scripts from build:native and build:binary to build for simplified command naming across packages/natives and packages/coding-agent.
- Refactored CI workflow to invoke bun tasks instead of inline shell scripts, reducing workflow complexity by 40+ lines.
- Removed sync-exports.ts and repro-stuck.ts scripts; deleted path aliases from tsconfig.base.json in favor of workspace-based configuration.
- Updated turbo.json with new task definitions (check:types, lint, fmt, fix) and removed build:native/embed:native tasks.
2026-04-08 17:05:20 +02:00

69 lines
1.8 KiB
TypeScript

#!/usr/bin/env bun
import * as path from "node:path";
import { $ } from "bun";
interface NativeBuildVariant {
name: "baseline" | "modern";
rustflags: string;
}
const repoRoot = path.join(import.meta.dir, "..");
const isDryRun = process.argv.includes("--dry-run");
const variantConfigs: Record<NativeBuildVariant["name"], NativeBuildVariant> = {
baseline: {
name: "baseline",
rustflags: "-C target-cpu=x86-64-v2",
},
modern: {
name: "modern",
rustflags: "-C target-cpu=x86-64-v3",
},
};
function parseTargetVariants(): NativeBuildVariant[] {
const rawVariants = (Bun.env.TARGET_VARIANTS ?? "").trim();
if (!rawVariants) return [];
return rawVariants.split(/\s+/).map((rawVariant) => {
const variant = variantConfigs[rawVariant as keyof typeof variantConfigs];
if (!variant) {
throw new Error(`Unsupported TARGET_VARIANTS entry: ${rawVariant}. Expected baseline or modern.`);
}
return variant;
});
}
async function runNativeBuild(env: Record<string, string | undefined>, label: string): Promise<void> {
if (isDryRun) {
const variant = env.TARGET_VARIANT ? ` TARGET_VARIANT=${env.TARGET_VARIANT}` : "";
const rustflags = env.RUSTFLAGS ? ` RUSTFLAGS=${JSON.stringify(env.RUSTFLAGS)}` : "";
console.log(`DRY RUN bun --cwd=packages/natives run build [${label}]${variant}${rustflags}`);
return;
}
console.log(`Building natives [${label}]...`);
await $`bun --cwd=packages/natives run build`.cwd(repoRoot).env(env);
}
async function main(): Promise<void> {
const variants = parseTargetVariants();
if (variants.length === 0) {
await runNativeBuild(Bun.env, "default");
return;
}
for (const variant of variants) {
await runNativeBuild(
{
...Bun.env,
RUSTFLAGS: variant.rustflags,
TARGET_VARIANT: variant.name,
},
variant.name,
);
}
}
await main();