Skip to content

Commit 2021bc9

Browse files
jchavarricristianoc
authored andcommitted
add bsc_path helper + use bsc.exe for super-errors test
1 parent 6e468c5 commit 2021bc9

File tree

8 files changed

+58
-67
lines changed

8 files changed

+58
-67
lines changed

bsc

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
"use strict";
33

44
var child_process = require("child_process");
5-
var path = require("path");
6-
var exe = path.join(
7-
__dirname,
8-
process.platform === "darwin" && process.arch === "arm64"
9-
? process.platform + process.arch
10-
: process.platform,
11-
"bsc.exe"
12-
);
5+
var exe = require("./scripts/bin_path").bsc_exe;
136
var delegate_args = process.argv.slice(2);
147

158
try {

jscomp/build_tests/super_errors/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path')
33
const child_process = require('child_process')
44

55

6-
var bsc = path.join(__dirname,'..','..','..','bsc')
6+
var bsc = require("../../../scripts/bin_path").bsc_exe;
77
// var refmt = path.join(__dirname,'..','..','..','lib','refmt.exe')
88

99

rescript

+2-21
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,10 @@ var child_process = require("child_process");
1111
var os = require("os");
1212
var path = require("path");
1313
var fs = require("fs");
14+
var bsc_exe = require("./scripts/bin_path").bsc_exe;
15+
var rescript_exe = require("./scripts/bin_path").rescript_exe;
1416
var bsconfig = "bsconfig.json";
1517

16-
/**
17-
*
18-
* @type{string}
19-
*/
20-
var bin_path = path.join(
21-
__dirname,
22-
process.platform === "darwin" && process.arch === "arm64"
23-
? process.platform + process.arch
24-
: process.platform
25-
);
26-
27-
/**
28-
* @type{string}
29-
*/
30-
var rescript_exe = path.join(bin_path, "rescript.exe");
31-
3218
var LAST_BUILD_START = 0;
3319
var LAST_FIRED_EVENT = 0;
3420
/**
@@ -225,11 +211,6 @@ if (
225211
maybe_subcommand !== "info"
226212
// delegate to native
227213
) {
228-
/**
229-
* @type {string}
230-
*/
231-
var bsc_exe = path.join(bin_path, "bsc.exe");
232-
233214
switch (maybe_subcommand) {
234215
case "format":
235216
require("./scripts/rescript_format.js").main(

scripts/bin_path.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//@ts-check
2+
3+
var path = require("path");
4+
5+
/**
6+
*
7+
* @type{string}
8+
*/
9+
var bin_path = path.join(
10+
__dirname,
11+
"..",
12+
process.platform === "darwin" && process.arch === "arm64"
13+
? process.platform + process.arch
14+
: process.platform
15+
);
16+
17+
/**
18+
* @type{string}
19+
*/
20+
var bsc_exe = path.join(bin_path, "bsc.exe");
21+
22+
/**
23+
* @type{string}
24+
*/
25+
var ninja_exe = path.join(bin_path, "ninja.exe");
26+
27+
/**
28+
* @type{string}
29+
*/
30+
var rescript_exe = path.join(bin_path, "rescript.exe");
31+
32+
exports.folder = bin_path;
33+
exports.bsc_exe = bsc_exe;
34+
exports.ninja_exe = ninja_exe;
35+
exports.rescript_exe = rescript_exe;

scripts/install.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ if (supported_os.indexOf(process.platform) < 0) {
2424
}
2525
var is_windows = process.platform === "win32";
2626

27-
var my_target =
28-
process.platform === "darwin" && process.arch === "arm64"
29-
? process.platform + process.arch
30-
: process.platform;
31-
var bin_path = path.join(root_dir, my_target);
27+
var bsc_exe = require("./bin_path").bsc_exe;
3228

3329
var ninja_bin_filename = process.platform === "win32" ? "ninja.exe" : "ninja";
34-
var ninja_bin_output = path.join(bin_path, "ninja.exe");
30+
var ninja_bin_output = require("./bin_path").ninja_exe;
3531

3632
var force_compiler_rebuild = process.argv.includes("-force-compiler-rebuild");
3733
var force_lib_rebuild = process.argv.includes("-force-lib-rebuild");
@@ -130,7 +126,7 @@ function checkPrebuiltBscCompiler() {
130126
}
131127
try {
132128
var version = String(
133-
child_process.execFileSync(path.join(bin_path, "bsc.exe"), ["-v"])
129+
child_process.execFileSync(bsc_exe, ["-v"])
134130
);
135131

136132
var myOCamlVersion = version.substr(
@@ -159,7 +155,7 @@ function buildLibs(stdlib) {
159155
ensureExists(path.join(lib_dir, "es6"));
160156
process.env.NINJA_IGNORE_GENERATOR = "true";
161157
var releaseNinja = `
162-
bsc = ../${my_target}/bsc.exe
158+
bsc = ${bsc_exe}
163159
stdlib = ${stdlib}
164160
subninja runtime/release.ninja
165161
subninja others/release.ninja

scripts/ninja.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ var js_package = pseudoTarget("js_pkg");
2828
var runtimeTarget = pseudoTarget("runtime");
2929
var othersTarget = pseudoTarget("others");
3030
var stdlibTarget = pseudoTarget("$stdlib");
31-
var my_target =
32-
process.platform === "darwin" && process.arch === "arm64"
33-
? process.platform + process.arch
34-
: process.platform;
31+
var my_target = require("./bin_path").folder;
32+
var bsc_exe = require("./bin_path").bsc_exe;
3533

36-
var vendorNinjaPath = path.join(__dirname, "..", my_target, "ninja.exe");
34+
var vendorNinjaPath = require("./bin_path").ninja_exe;
3735

3836
// Let's enforce a Node version >= 16 to make sure M1 users don't trip up on
3937
// cryptic issues caused by mismatching assembly architectures Node 16 ships
@@ -666,7 +664,7 @@ function depModulesForBscAsync(files, dir, depsMap) {
666664
return [
667665
new Promise((resolve, reject) => {
668666
cp.exec(
669-
`../../${my_target}/bsc.exe -modules -bs-syntax-only ${resFiles.join(
667+
`${bsc_exe} -modules -bs-syntax-only ${resFiles.join(
670668
" "
671669
)} ${reFiles.join(" ")} ${ocamlFiles.join(" ")}`,
672670
config,
@@ -854,7 +852,7 @@ function generateNinja(depsMap, allTargets, cwd, extraDeps = []) {
854852
return build_stmts;
855853
}
856854

857-
var COMPILIER = `../${my_target}/bsc.exe`;
855+
var COMPILIER = bsc_exe;
858856
var BSC_COMPILER = `bsc = ${COMPILIER}`;
859857

860858
async function runtimeNinja(devmode = true) {
@@ -1406,7 +1404,7 @@ include body.ninja
14061404
nativeNinja();
14071405
runtimeNinja();
14081406
stdlibNinja(true);
1409-
if (fs.existsSync(path.join(__dirname, "..", my_target, "bsc.exe"))) {
1407+
if (fs.existsSync(bsc_exe)) {
14101408
testNinja();
14111409
}
14121410
othersNinja();
@@ -1730,14 +1728,14 @@ o core/js_record_map.ml: p4of core/j.ml
17301728
o core/js_record_fold.ml: p4of core/j.ml
17311729
flags = -record-fold
17321730
1733-
o ../${my_target}/bsc.exe: link ${makeLibs(
1731+
o ${my_target}/bsc.exe: link ${makeLibs(
17341732
bsc_libs
17351733
)} main/rescript_compiler_main.cmx
1736-
o ../${my_target}/rescript.exe: link ${makeLibs(
1734+
o ${my_target}/rescript.exe: link ${makeLibs(
17371735
rescript_libs
17381736
)} main/rescript_main.cmx
17391737
libs = unix.cmxa str.cmxa
1740-
o ../${my_target}/bsb_helper.exe: link ${makeLibs(
1738+
o ${my_target}/bsb_helper.exe: link ${makeLibs(
17411739
bsb_helper_libs
17421740
)} main/bsb_helper_main.cmx
17431741
libs = unix.cmxa str.cmxa
@@ -1750,7 +1748,7 @@ o ./bin/cmij.exe: link ${makeLibs(cmij_libs)} main/cmij_main.cmx
17501748
17511749
o ./bin/tests.exe: link ${makeLibs(tests_libs)} main/ounit_tests_main.cmx
17521750
libs = str.cmxa unix.cmxa
1753-
build native: phony ../${my_target}/bsc.exe ../${my_target}/rescript.exe ../${my_target}/bsb_helper.exe ./bin/bspack.exe ./bin/cmjdump.exe ./bin/cmij.exe ./bin/tests.exe
1751+
build native: phony ${my_target}/bsc.exe ${my_target}/rescript.exe ${my_target}/bsb_helper.exe ./bin/bspack.exe ./bin/cmjdump.exe ./bin/cmij.exe ./bin/tests.exe
17541752
17551753
17561754
${mllRule}

scripts/ninjaFactory.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
// # build bsdep.exe: cc bsdep.mli bsdep.ml
77
// ../native/4.06.1/bin/ocamlopt.opt -c -O2 -nodynlink -I 4.06.1 -g -w a+32 4.06.1/whole_compiler.mli 4.06.1/whole_compiler.ml &> warning.log
88

9-
/**
10-
* @type{string}
11-
*/
12-
var targetDir =
13-
process.platform === "darwin" && process.arch === "arm64"
14-
? process.platform + process.arch
15-
: process.platform;
9+
var targetDir = require("./bin_path").folder;
1610

1711
/**
1812
*
@@ -30,11 +24,11 @@ rule cc
3024
config.isWin ? "" : "&& strip $out"
3125
}
3226
description = Making $out
33-
build ../${targetDir}/rescript$ext: cc $INCL/rescript.mli $INCL/rescript.ml
27+
build ${targetDir}/rescript$ext: cc $INCL/rescript.mli $INCL/rescript.ml
3428
flags = $flags -unboxed-types unix.cmxa str.cmxa
35-
build ../${targetDir}/bsb_helper$ext: cc $INCL/bsb_helper.mli $INCL/bsb_helper.ml
29+
build ${targetDir}/bsb_helper$ext: cc $INCL/bsb_helper.mli $INCL/bsb_helper.ml
3630
flags = $flags -unboxed-types -w -a
37-
build ../${targetDir}/bsc$ext: cc $INCL/whole_compiler.mli $INCL/whole_compiler.ml
31+
build ${targetDir}/bsc$ext: cc $INCL/whole_compiler.mli $INCL/whole_compiler.ml
3832
flags = $flags -w A-4-9-48-40-45-41-44-50-21-30-32-34-37-27-60-42
3933
`;
4034
}

scripts/prebuilt.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ function rebuild() {
5252
}
5353

5454
var use_env_compiler = process.argv.includes("-use-env-compiler");
55-
var bin_path = path.join(
56-
__dirname,
57-
"..",
58-
process.platform === "darwin" && process.arch === "arm64"
59-
? process.platform + process.arch
60-
: process.platform
61-
);
55+
var bin_path = require("./bin_path").folder;
6256

6357
function buildCompiler() {
6458
var prebuilt = "prebuilt.ninja";

0 commit comments

Comments
 (0)