diff --git a/.gitignore b/.gitignore index 5a45d97..5df8049 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ out node_modules - -# Some executable folder that are intended to be invoked on-the-fly. -/src/bin diff --git a/src/bin/build-llvm.ts b/src/bin/build-llvm.ts new file mode 100644 index 0000000..766520e --- /dev/null +++ b/src/bin/build-llvm.ts @@ -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); +} \ No newline at end of file