element-desktop/hak/matrix-seshat/build.ts

49 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

/*
2024-09-06 16:56:18 +00:00
Copyright 2024 New Vector Ltd.
Copyright 2020, 2021 The Matrix.org Foundation C.I.C.
2024-09-06 16:56:18 +00:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
2022-12-15 11:00:58 +00:00
import childProcess from "child_process";
2020-02-15 16:52:41 +00:00
2022-12-15 11:00:58 +00:00
import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
2022-12-15 11:00:58 +00:00
export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();
2020-02-15 16:52:41 +00:00
if (!hakEnv.isHost()) {
env.CARGO_BUILD_TARGET = hakEnv.getTargetId();
2023-03-23 13:22:29 +00:00
}
2020-02-15 16:52:41 +00:00
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",
});
2022-12-15 11:00:58 +00:00
proc.on("exit", (code) => {
2020-02-15 16:52:41 +00:00
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,
env,
shell: true,
stdio: "inherit",
});
2022-12-15 11:00:58 +00:00
proc.on("exit", (code) => {
code ? reject(code) : resolve();
});
});
}