-
Notifications
You must be signed in to change notification settings - Fork 455
/
Copy pathcopyExes.js
executable file
·48 lines (38 loc) · 1.4 KB
/
copyExes.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
// Copy exes built by dune to platform bin dir
const path = require("path");
const fs = require("fs");
const child_process = require("child_process");
const { duneBinDir } = require("./dune");
const { absolutePath: platformBinDir } = require("#cli/bin_path");
const ninjaDir = path.join(__dirname, "..", "ninja");
const rewatchDir = path.join(__dirname, "..", "rewatch");
if (!fs.existsSync(platformBinDir)) {
fs.mkdirSync(platformBinDir);
}
function copyExe(dir, exe) {
const ext = process.platform === "win32" ? ".exe" : "";
const src = path.join(dir, exe + ext);
const dest = path.join(platformBinDir, exe + ".exe");
// For some reason, the copy operation fails in Windows CI if the file already exists.
if (process.platform === "win32" && fs.existsSync(dest)) {
fs.rmSync(dest);
}
fs.copyFileSync(src, dest);
if (process.platform !== "win32") {
child_process.execSync(`strip ${dest}`);
}
}
if (process.argv.includes("-all") || process.argv.includes("-compiler")) {
copyExe(duneBinDir, "rescript");
copyExe(duneBinDir, "rescript-editor-analysis");
copyExe(duneBinDir, "rescript-tools");
copyExe(duneBinDir, "bsc");
copyExe(duneBinDir, "bsb_helper");
}
if (process.argv.includes("-all") || process.argv.includes("-ninja")) {
copyExe(ninjaDir, "ninja");
}
if (process.argv.includes("-all") || process.argv.includes("-rewatch")) {
copyExe(rewatchDir, "rewatch");
}