forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildNinjaBinary.js
executable file
·29 lines (23 loc) · 941 Bytes
/
buildNinjaBinary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
const child_process = require("child_process");
const fs = require("fs");
const path = require("path");
const platform = process.platform;
const ninjaDir = path.join(__dirname, "..", "ninja");
const buildCommand = "python3 configure.py --bootstrap --verbose";
if (platform === "win32") {
// On Windows, the build uses the MSVC compiler which needs to be on the path.
child_process.execSync(buildCommand, { cwd: ninjaDir });
} else {
if (process.platform === "darwin") {
process.env["CXXFLAGS"] = "-flto";
}
child_process.execSync(buildCommand, { stdio: [0, 1, 2], cwd: ninjaDir });
child_process.execSync(`strip ninja`, { stdio: [0, 1, 2], cwd: ninjaDir });
}
const { absolutePath, ninja_exe } = require("./bin_path");
const src = path.join(ninjaDir, `ninja${platform === "win32" ? ".exe" : ""}`);
if (!fs.existsSync(absolutePath)) {
fs.mkdirSync(absolutePath);
}
fs.copyFileSync(src, ninja_exe);