Skip to content

Commit 1d6035a

Browse files
committed
build stdlib without depending on runtime
1 parent 148d57f commit 1d6035a

File tree

7 files changed

+988
-950
lines changed

7 files changed

+988
-950
lines changed

jscomp/core/bs_conditional_initial.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ let setup_env () =
6363
Clflags.include_dirs :=
6464
(root_dir//"jscomp"//"others") ::
6565
(root_dir//"jscomp"//"stdlib-406") ::
66-
(root_dir//"jscomp"//"runtime") ::
6766
!Clflags.include_dirs);
6867

69-
# 66 "core/bs_conditional_initial.pp.ml"
68+
# 65 "core/bs_conditional_initial.pp.ml"
7069
Rescript_cpp.replace_directive_bool "BS" true;
7170
Rescript_cpp.replace_directive_bool "JS" true;
7271
Rescript_cpp.replace_directive_string "BS_VERSION" Bs_version.version

jscomp/core/bs_conditional_initial.pp.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ let setup_env () =
6060
Clflags.include_dirs :=
6161
(root_dir//"jscomp"//"others") ::
6262
(root_dir//"jscomp"//"stdlib-406") ::
63-
(root_dir//"jscomp"//"runtime") ::
6463
!Clflags.include_dirs);
6564
#endif
6665
Rescript_cpp.replace_directive_bool "BS" true;

jscomp/main/cmij_main.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ let () =
171171
[] folders
172172
in
173173
let cmj_files =
174-
(Filename.dirname Sys.argv.(0) // ".." // "runtime" // "js.cmj")
175-
:: get_files Literals.suffix_cmj
176-
(Filename.dirname Sys.argv.(0) // ".." // stdlib)
174+
get_files Literals.suffix_cmj
175+
(Filename.dirname Sys.argv.(0) // ".." // stdlib)
177176
@ get_files Literals.suffix_cmj
178177
(Filename.dirname Sys.argv.(0) // ".." // "others")
179178
@ third_party_cmj_files
@@ -193,12 +192,11 @@ let () =
193192
if release_cmi then get_files Literals.suffix_cmi (".." // "lib" // "ocaml")
194193
else
195194
let files =
196-
(Filename.dirname Sys.argv.(0) // ".." // "runtime" // "js.cmi")
197-
:: (get_files Literals.suffix_cmi
198-
(Filename.dirname Sys.argv.(0) // ".." // stdlib)
199-
@ get_files Literals.suffix_cmi
200-
(Filename.dirname Sys.argv.(0) // ".." // "others")
201-
@ third_party_cmi_files)
195+
get_files Literals.suffix_cmi
196+
(Filename.dirname Sys.argv.(0) // ".." // stdlib)
197+
@ get_files Literals.suffix_cmi
198+
(Filename.dirname Sys.argv.(0) // ".." // "others")
199+
@ third_party_cmi_files
202200
in
203201
Ext_list.filter files (fun x ->
204202
x |~ "js_OO" || x |~ "camlinternal" || not (x |~ "internal"))

jscomp/others/release.ninja

Lines changed: 141 additions & 137 deletions
Large diffs are not rendered by default.

jscomp/stdlib-406/release.ninja

Lines changed: 80 additions & 80 deletions
Large diffs are not rendered by default.

jscomp/test/build.ninja

Lines changed: 714 additions & 714 deletions
Large diffs are not rendered by default.

scripts/ninja.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,16 +950,51 @@ rule ${mlyRuleName}
950950
generator = true
951951
`;
952952
async function othersNinja(devmode = true) {
953-
var externalDeps = [runtimeTarget];
953+
var externalDeps = [compilerTarget, fileTarget('belt_internals.cmi'), fileTarget('js.cmi')];
954954
var ninjaOutput = devmode ? "build.ninja" : "release.ninja";
955955
var ninjaCwd = "others";
956956

957957
var templateOthersRules = `
958-
bsc_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -open Bs_stdlib_mini -I ./runtime
958+
bsc_primitive_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
959+
bsc_flags = $bsc_primitive_flags -open Belt_internals
959960
${ruleCC(ninjaCwd)}
960961
${ninjaQuickBuidList([
961-
[["belt.cmj", "belt.cmi"], "belt.ml", "cc", ninjaCwd, [], [], externalDeps],
962-
[["node.cmj", "node.cmi"], "node.ml", "cc", ninjaCwd, [], [], externalDeps],
962+
[
963+
["belt.cmj", "belt.cmi"],
964+
"belt.ml",
965+
"cc",
966+
ninjaCwd,
967+
[["bsc_flags", "$bsc_primitive_flags"]],
968+
[],
969+
[compilerTarget],
970+
],
971+
[
972+
["js.cmj", "js.cmi"],
973+
"js.ml",
974+
"cc",
975+
ninjaCwd,
976+
[["bsc_flags", "$bsc_primitive_flags"]],
977+
[],
978+
[compilerTarget],
979+
],
980+
[
981+
["belt_internals.cmi"],
982+
"belt_internals.mli",
983+
"cc",
984+
ninjaCwd,
985+
[["bsc_flags", "$bsc_primitive_flags"]],
986+
[],
987+
[compilerTarget],
988+
],
989+
[
990+
["node.cmj", "node.cmi"],
991+
"node.ml",
992+
"cc",
993+
ninjaCwd,
994+
[], // need -I ./runtime
995+
[],
996+
[compilerTarget, fileTarget('js.cmi')], // need js.cm*
997+
],
963998
])}
964999
`;
9651000
var othersDirFiles = fs.readdirSync(othersDir, "ascii");
@@ -969,12 +1004,14 @@ ${ninjaQuickBuidList([
9691004
(x.endsWith(".ml") || x.endsWith(".mli")) &&
9701005
!x.includes(".cppo") &&
9711006
!x.includes(".pp") &&
972-
!x.includes("#")
1007+
!x.includes("#") &&
1008+
x !== "js.ml"
9731009
);
9741010
var othersFiles = othersDirFiles.filter(
9751011
(x) =>
9761012
!x.startsWith("js") &&
9771013
x !== "belt.ml" &&
1014+
x !== "belt_internals.mli" &&
9781015
x !== "node.ml" &&
9791016
(x.endsWith(".ml") || x.endsWith(".mli")) &&
9801017
!x.includes("#") &&
@@ -1027,7 +1064,7 @@ async function stdlibNinja(devmode = true) {
10271064
var stdlibVersion = "stdlib-406";
10281065
var ninjaCwd = stdlibVersion;
10291066
var stdlibDir = path.join(jscompDir, stdlibVersion);
1030-
var externalDeps = [othersTarget];
1067+
var externalDeps = [compilerTarget, othersTarget];
10311068
var ninjaOutput = devmode ? "build.ninja" : "release.ninja";
10321069
var bsc_flags = "bsc_flags";
10331070
/**
@@ -1038,7 +1075,7 @@ async function stdlibNinja(devmode = true) {
10381075
// deprecations diabled due to string_of_float
10391076
var warnings = "-w -9-3-106 -warn-error A";
10401077
var templateStdlibRules = `
1041-
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I runtime -I others
1078+
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others
10421079
${ruleCC(ninjaCwd)}
10431080
${ninjaQuickBuidList([
10441081
// we make it still depends on external
@@ -1176,6 +1213,7 @@ ${mllList(ninjaCwd, [
11761213
await Promise.all(depModulesForBscAsync(sources, testDir, depsMap));
11771214
var targets = collectTarget(sources);
11781215
var output = generateNinja(depsMap, targets, ninjaCwd, [
1216+
runtimeTarget,
11791217
stdlibTarget,
11801218
pseudoTarget("$bsc"),
11811219
]);

0 commit comments

Comments
 (0)