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 HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep"; import { DependencyInfo } from "../../scripts/hak/dep";
export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> { function run(
const env = hakEnv.makeGypEnv(); moduleInfo: DependencyInfo,
cmd: string,
if (!hakEnv.isHost()) { args: string[],
env.CARGO_BUILD_TARGET = hakEnv.getTargetId(); env: Record<string, string | undefined>,
} ): Promise<void> {
return new Promise<void>((resolve, reject) => {
console.log("Running yarn install"); const proc = childProcess.spawn(cmd, args, {
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], {
cwd: moduleInfo.moduleBuildDir, cwd: moduleInfo.moduleBuildDir,
env, env,
shell: true, 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);
}