src/bin/build-llvm: add utility to build llvm project

This commit is contained in:
2025-01-04 16:18:13 +08:00
parent 4c4769cf78
commit 6d7fa4aa09
2 changed files with 46 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,2 @@
out
node_modules
# Some executable folder that are intended to be invoked on-the-fly.
/src/bin

46
src/bin/build-llvm.ts Normal file
View File

@@ -0,0 +1,46 @@
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { llvmPackages } from '../build/llvmPackages.js';
import path from 'path';
import { buildPackage } from '../build/build.js';
import { randomUUID } from 'crypto';
import { arch } from 'os';
const args = await yargs(hideBin(process.argv))
.version("0.0.0")
.option("src", {
describe: "Source directory to llvm-project",
demandOption: true,
type: "string",
})
.option("build", {
describe: "Build directory",
type: "string",
})
.option("prefix", {
describe: "Install prefix",
type: "string",
})
.help()
.parse();
const src = path.resolve(args.src);
const build = args.build ?? path.resolve(src, "build");
const prefix = args.prefix ?? path.resolve(src, "install", randomUUID());
const packages = llvmPackages({
src: args.src,
buildDir(packageName) {
return path.join(build, packageName);
},
installPrefix: prefix,
// FIXME: arguments to platform?
platform: {
buildPlatform: { arch: arch() },
hostPlatform: { arch: arch() },
}
});
for (const pkg of packages) {
await buildPackage(pkg);
}