2020-05-28 21:07:39 +02:00
|
|
|
/*
|
2024-09-06 18:56:18 +02:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2020-05-28 21:07:39 +02:00
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-06 18:56:18 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-05-28 21:07:39 +02:00
|
|
|
*/
|
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
import path from "path";
|
|
|
|
import childProcess from "child_process";
|
2020-05-28 21:07:39 +02:00
|
|
|
|
2022-12-15 12:00:58 +01:00
|
|
|
import HakEnv from "../../scripts/hak/hakEnv";
|
|
|
|
import { DependencyInfo } from "../../scripts/hak/dep";
|
2020-05-28 21:07:39 +02:00
|
|
|
|
2021-12-14 15:32:27 +01:00
|
|
|
export default async function buildKeytar(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
|
2020-05-28 21:07:39 +02:00
|
|
|
const env = hakEnv.makeGypEnv();
|
|
|
|
|
|
|
|
console.log("Running yarn with env", env);
|
2021-12-14 15:32:27 +01:00
|
|
|
await new Promise<void>((resolve, reject) => {
|
2020-05-28 21:07:39 +02:00
|
|
|
const proc = childProcess.spawn(
|
2022-12-15 12:00:58 +01:00
|
|
|
path.join(moduleInfo.nodeModuleBinDir, "node-gyp" + (hakEnv.isWin() ? ".cmd" : "")),
|
2023-04-18 12:38:26 +02:00
|
|
|
["rebuild", "--arch", hakEnv.getTargetArch()],
|
2020-05-28 21:07:39 +02:00
|
|
|
{
|
|
|
|
cwd: moduleInfo.moduleBuildDir,
|
|
|
|
env,
|
2022-12-15 12:00:58 +01:00
|
|
|
stdio: "inherit",
|
2024-04-17 16:12:29 +02:00
|
|
|
// We need shell mode on Windows to be able to launch `.cmd` executables
|
|
|
|
// See https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
|
|
|
|
shell: hakEnv.isWin(),
|
2020-05-28 21:07:39 +02:00
|
|
|
},
|
|
|
|
);
|
2022-12-15 12:00:58 +01:00
|
|
|
proc.on("exit", (code) => {
|
2020-05-28 21:07:39 +02:00
|
|
|
code ? reject(code) : resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|