Repository navigation
Expand file tree
/
Copy pathcheckCompilerExes.js
More file actions
61 lines (53 loc) · 1.6 KB
/
Copy pathcheckCompilerExes.js
File metadata and controls
61 lines (53 loc) · 1.6 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
// @ts-check
// Verify that the compiler binaries in the platform npm package were
// produced by dune promotion from the current build (compiler/sync/dune is
// their only producer). Fails when a binary is missing - e.g. this
// platform's promotion rule did not fire - or when a stale binary from an
// earlier build is still in place.
import * as fs from "node:fs";
import * as path from "node:path";
import { binDir } from "#cli/bins";
const syncDir = path.join(
import.meta.dirname,
"..",
"_build",
"default",
"compiler",
"sync",
);
let ok = true;
const executables = [
"bsc",
"rescript-editor-analysis",
"rescript-tools",
"rescript",
];
for (const exe of executables) {
const promoted = path.join(binDir, `${exe}.exe`);
const built = path.join(syncDir, `${exe}.exe`);
if (
!fs.existsSync(promoted) ||
!fs.existsSync(built) ||
!fs.readFileSync(promoted).equals(fs.readFileSync(built))
) {
console.error(`Error: ${promoted} does not match ${built}.`);
ok = false;
} else if (process.platform !== "win32") {
// Content being right is not enough: an archive round-trip can drop the
// executable bit while preserving bytes.
try {
fs.accessSync(promoted, fs.constants.X_OK);
} catch {
console.error(`Error: ${promoted} is not executable.`);
ok = false;
}
}
}
if (!ok) {
console.error(
"Dune promotion did not produce these binaries; check that this platform is covered by a rule in compiler/sync/dune.",
);
process.exit(1);
}
console.log("Compiler binaries in the platform package match the dune build.");