Skip to content

Commit a094cdb

Browse files
committed
install cm* in prebuilt
1 parent fb06fac commit a094cdb

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

scripts/prebuilt.js

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,53 @@ function rebuild() {
1818
stdio: [0, 1, 2]
1919
});
2020
}
21+
var assert = require('assert')
22+
/**
23+
*
24+
* @param {string} src
25+
* @param {(file:string)=>boolean} filter
26+
* @param {string} dest
27+
*/
28+
function installDirBy(src, dest, filter) {
29+
fs.readdir(src, function(err, files) {
30+
if (err === null) {
31+
files.forEach(function(file) {
32+
if (filter(file)) {
33+
var x = path.join(src, file);
34+
var y = path.join(dest, file);
35+
// console.log(x, '----->', y )
36+
fs.copyFile(x, y, (err) => assert.equal(err,null));
37+
}
38+
});
39+
} else {
40+
throw err;
41+
}
42+
});
43+
}
44+
45+
function install() {
46+
var root_dir = path.join(__dirname, "..");
47+
var lib_dir = path.join(root_dir, "lib");
48+
var jscomp_dir = path.join(root_dir, "jscomp");
49+
var runtime_dir = path.join(jscomp_dir, "runtime");
50+
var others_dir = path.join(jscomp_dir, "others");
51+
var ocaml_dir = path.join(lib_dir, "ocaml");
52+
var stdlib_dir = path.join(jscomp_dir, "stdlib-406");
53+
54+
installDirBy(runtime_dir, ocaml_dir, function(file) {
55+
var y = path.parse(file);
56+
return y.name === "js" || y.ext.includes("cm");
57+
// install js.cmi, js.mli
58+
});
59+
installDirBy(others_dir, ocaml_dir, function(file) {
60+
var y = path.parse(file);
61+
return y.ext === ".ml" || y.ext === ".mli" || y.ext.includes("cm");
62+
});
63+
installDirBy(stdlib_dir, ocaml_dir, function(file) {
64+
var y = path.parse(file);
65+
return y.ext === ".ml" || y.ext === ".mli" || y.ext.includes("cm");
66+
});
67+
}
2168

2269
function buildCompiler() {
2370
// for 4.02.3 it relies on OCAMLLIB to find stdlib path
@@ -46,23 +93,20 @@ if (!is_windows) {
4693
if (!process.argv.includes("-noclean")) {
4794
rebuild();
4895
}
96+
4997
require("./ninja.js").updateRelease();
5098
}
51-
var os = require("os");
99+
52100
function createOCamlTar() {
53-
if (os.platform() === hostPlatform) {
101+
if (process.platform === hostPlatform) {
102+
install();
54103
cp.execSync(`git -C ocaml status -uno`, { cwd: root, stdio: [0, 1, 2] });
55104
cp.execSync(
56105
`git -C ocaml archive --format=tar.gz HEAD -o ../vendor/ocaml.tar.gz`,
57106
{ cwd: root, stdio: [0, 1, 2] }
58107
);
59-
// fs.copyFileSync(
60-
// path.join(root, "ocaml", "VERSION"),
61-
// path.join(root, "OCAML_VERSION")
62-
// );
63108
}
64109
}
110+
65111
createOCamlTar();
66112
buildCompiler();
67-
68-
//

0 commit comments

Comments
 (0)