Simplify matrix-seshat hak build script

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-05-10 20:54:18 +01:00
parent fd6ed16839
commit 4dad0a9785
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D

View File

@ -19,31 +19,14 @@ import childProcess from "child_process";
import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();
if (!hakEnv.isHost()) {
env.CARGO_BUILD_TARGET = hakEnv.getTargetId();
}
console.log("Running yarn install");
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["install"], {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
stdio: "inherit",
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
});
});
const buildTarget = hakEnv.wantsStaticSqlCipher() ? "build-bundled" : "build";
console.log("Running yarn build");
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["run", buildTarget], {
function run(
moduleInfo: DependencyInfo,
cmd: string,
args: string[],
env: Record<string, string | undefined>,
): Promise<void> {
return new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(cmd, args, {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
@ -54,3 +37,20 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
});
});
}
export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();
if (!hakEnv.isHost()) {
env.CARGO_BUILD_TARGET = hakEnv.getTargetId();
}
const yarnCmd = "yarn" + (hakEnv.isWin() ? ".cmd" : "");
console.log("Running yarn install");
await run(moduleInfo, yarnCmd, ["install"], env);
const buildTarget = hakEnv.wantsStaticSqlCipher() ? "build-bundled" : "build";
console.log("Running yarn build");
await run(moduleInfo, yarnCmd, ["run", buildTarget], env);
}