Skip to content

Commit c07aa8a

Browse files
cknittcristianoc
authored andcommitted
Do not unnecessarily extract ocaml.tar.gz when running CI tests
1 parent 6580f79 commit c07aa8a

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

scripts/buildocaml.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ var fs = require("fs");
77
var ocamlSrcDir = path.join(__dirname, "..", "native");
88
var ocamlVersionFilePath = path.join(ocamlSrcDir, "VERSION");
99

10+
/**
11+
* Checks whether an OCaml compiler is available.
12+
* If it is, we do not need to build one from the vendored sources.
13+
*/
14+
function checkEnvCompiler() {
15+
try {
16+
var o = cp.execSync(`ocamlopt.opt -version`, {
17+
encoding: "utf-8",
18+
});
19+
console.log("checking env compiler");
20+
console.log(o);
21+
return true;
22+
} catch (e) {
23+
console.log(e);
24+
return false;
25+
}
26+
}
27+
exports.checkEnvCompiler = checkEnvCompiler;
28+
1029
/**
1130
* Ensures the ocaml folder exists at the root of the project, either from the submodule,
1231
* or by extracting the vendor/ocaml.tar.gz there

scripts/ciTest.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ if (all) {
4242
}
4343

4444
function init() {
45-
var vendorOCamlPath = path.join(
46-
__dirname,
47-
"..",
48-
"native",
49-
require("./buildocaml.js").getVersionPrefix(),
50-
"bin"
51-
);
52-
53-
process.env["PATH"] = vendorOCamlPath + path.delimiter + process.env["PATH"];
45+
if (!require("./buildocaml.js").checkEnvCompiler()) {
46+
// No compiler available on path.
47+
// Assume that we built the compiler from source beforehand and add it to the path.
48+
var vendorOCamlPath = path.join(
49+
__dirname,
50+
"..",
51+
"native",
52+
require("./buildocaml.js").getVersionPrefix(),
53+
"bin"
54+
);
55+
56+
process.env["PATH"] = vendorOCamlPath + path.delimiter + process.env["PATH"];
57+
}
5458

5559
var ninjaPath = path.join(__dirname, "..", process.platform, "ninja.exe");
5660

scripts/install.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,6 @@ o all: phony runtime others $stdlib
178178
console.log("Build finished");
179179
}
180180

181-
/**
182-
* works only on *unix
183-
* used for dev environment or our prebuilt compiler
184-
* does not work for such version
185-
* @returns {boolean}
186-
*/
187-
function checkEnvCompiler() {
188-
try {
189-
var o = child_process.execSync(`ocamlopt.opt -version`, {
190-
encoding: "utf-8",
191-
});
192-
console.log("checking env compiler");
193-
console.log(o);
194-
return true;
195-
} catch (e) {
196-
console.log(e);
197-
return false;
198-
}
199-
}
200181
/**
201182
* @returns {string}
202183
*/
@@ -207,7 +188,7 @@ function provideCompiler() {
207188
} else {
208189
var ocamlopt = "ocamlopt.opt";
209190
myVersion = "4.06.1";
210-
if (!checkEnvCompiler()) {
191+
if (!require("./buildocaml.js").checkEnvCompiler()) {
211192
// no compiler available
212193
var prefix = require("./buildocaml.js").build(true);
213194
ocamlopt=`${prefix}/bin/${ocamlopt}`

0 commit comments

Comments
 (0)