Skip to content

Commit 6077950

Browse files
authored
Remove cppo stuff from ninja.js and move cppo files into separate folder (#6934)
* Remove cppo stuff from ninja.js and move cppo files into separate folder * Fix some comments formatting
1 parent 19a71b9 commit 6077950

22 files changed

+82
-119
lines changed

jscomp/others/belt_HashSetInt.resi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
26+
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
2727
28-
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29-
and identity is not needed(using the built-in one)
28+
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29+
and identity is not needed(using the built-in one)
3030
31-
**See** [`Belt.HashSet`]()
31+
**See** [`Belt.HashSet`]()
3232
*/
3333

3434
type key = int

jscomp/others/belt_HashSetString.resi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
26+
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
2727
28-
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29-
and identity is not needed(using the built-in one)
28+
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29+
and identity is not needed(using the built-in one)
3030
31-
**See** [`Belt.HashSet`]()
31+
**See** [`Belt.HashSet`]()
3232
*/
3333

3434
type key = string

jscomp/others/belt_SetInt.resi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27-
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28-
and identity is not needed(using the built-in one)
26+
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27+
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28+
and identity is not needed(using the built-in one)
2929
30-
**See** [`Belt.Set`]()
30+
**See** [`Belt.Set`]()
3131
*/
3232

3333
/** The type of the set elements. */
@@ -77,7 +77,7 @@ of sets.
7777
*/
7878
let cmp: (t, t) => int
7979

80-
/**
80+
/**
8181
`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain
8282
equal elements.
8383
*/
@@ -105,7 +105,7 @@ let every: (t, value => bool) => bool
105105

106106
let someU: (t, (. value) => bool) => bool
107107

108-
/**
108+
/**
109109
`some(p, s)` checks if at least one element of the set satisfies the predicate
110110
`p`. Oder unspecified.
111111
*/

jscomp/others/belt_SetString.resi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27-
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28-
and identity is not needed(using the built-in one)
26+
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27+
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28+
and identity is not needed(using the built-in one)
2929
30-
**See** [`Belt.Set`]()
30+
**See** [`Belt.Set`]()
3131
*/
3232

3333
/** The type of the set elements. */
@@ -77,7 +77,7 @@ of sets.
7777
*/
7878
let cmp: (t, t) => int
7979

80-
/**
80+
/**
8181
`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain
8282
equal elements.
8383
*/
@@ -105,7 +105,7 @@ let every: (t, value => bool) => bool
105105

106106
let someU: (t, (. value) => bool) => bool
107107

108-
/**
108+
/**
109109
`some(p, s)` checks if at least one element of the set satisfies the predicate
110110
`p`. Oder unspecified.
111111
*/

jscomp/others/belt_Set.cppo.resi renamed to jscomp/others_cppo/belt_Set.cppo.resi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27-
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28-
and identity is not needed(using the built-in one)
26+
This module is [`Belt.Set`]() specialized with value type to be a primitive type.
27+
It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed,
28+
and identity is not needed(using the built-in one)
2929
30-
**See** [`Belt.Set`]()
30+
**See** [`Belt.Set`]()
3131
*/
3232

3333
#ifdef TYPE_STRING
@@ -84,7 +84,7 @@ of sets.
8484
*/
8585
let cmp: (t, t) => int
8686

87-
/**
87+
/**
8888
`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain
8989
equal elements.
9090
*/
@@ -112,7 +112,7 @@ let every: (t, value => bool) => bool
112112

113113
let someU: (t, (. value) => bool) => bool
114114

115-
/**
115+
/**
116116
`some(p, s)` checks if at least one element of the set satisfies the predicate
117117
`p`. Oder unspecified.
118118
*/
File renamed without changes.
File renamed without changes.

jscomp/others/hashset.cppo.resi renamed to jscomp/others_cppo/hashset.cppo.resi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

2525
/***
26-
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
26+
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
2727
28-
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29-
and identity is not needed(using the built-in one)
28+
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
29+
and identity is not needed(using the built-in one)
3030
31-
**See** [`Belt.HashSet`]()
31+
**See** [`Belt.HashSet`]()
3232
*/
3333

3434
#ifdef TYPE_STRING
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/cppo.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// @ts-check
2+
3+
const { execFileSync } = require("child_process");
4+
5+
[
6+
["belt_HashSetString.res", "hashset.cppo.res", "TYPE_STRING"],
7+
["belt_HashSetString.resi", "hashset.cppo.resi", "TYPE_STRING"],
8+
["belt_HashSetInt.res", "hashset.cppo.res", "TYPE_INT"],
9+
["belt_HashSetInt.resi", "hashset.cppo.resi", "TYPE_INT"],
10+
["belt_HashMapString.res", "hashmap.cppo.res", "TYPE_STRING"],
11+
["belt_HashMapString.resi", "hashmap.cppo.resi", "TYPE_STRING"],
12+
["belt_HashMapInt.res", "hashmap.cppo.res", "TYPE_INT"],
13+
["belt_HashMapInt.resi", "hashmap.cppo.resi", "TYPE_INT"],
14+
["belt_MapString.res", "map.cppo.res", "TYPE_STRING"],
15+
["belt_MapString.resi", "map.cppo.resi", "TYPE_STRING"],
16+
["belt_MapInt.res", "map.cppo.res", "TYPE_INT"],
17+
["belt_MapInt.resi", "map.cppo.resi", "TYPE_INT"],
18+
["belt_SetString.res", "belt_Set.cppo.res", "TYPE_STRING"],
19+
["belt_SetString.resi", "belt_Set.cppo.resi", "TYPE_STRING"],
20+
["belt_SetInt.res", "belt_Set.cppo.res", "TYPE_INT"],
21+
["belt_SetInt.resi", "belt_Set.cppo.resi", "TYPE_INT"],
22+
["belt_MutableMapString.res", "mapm.cppo.res", "TYPE_STRING"],
23+
["belt_MutableMapString.resi", "mapm.cppo.resi", "TYPE_STRING"],
24+
["belt_MutableMapInt.res", "mapm.cppo.res", "TYPE_INT"],
25+
["belt_MutableMapInt.resi", "mapm.cppo.resi", "TYPE_INT"],
26+
["belt_MutableSetString.res", "setm.cppo.res", "TYPE_STRING"],
27+
["belt_MutableSetString.resi", "setm.cppo.resi", "TYPE_STRING"],
28+
["belt_MutableSetInt.res", "setm.cppo.res", "TYPE_INT"],
29+
["belt_MutableSetInt.resi", "setm.cppo.resi", "TYPE_INT"],
30+
["belt_SortArrayString.res", "sort.cppo.res", "TYPE_STRING"],
31+
["belt_SortArrayString.resi", "sort.cppo.resi", "TYPE_STRING"],
32+
["belt_SortArrayInt.res", "sort.cppo.res", "TYPE_INT"],
33+
["belt_SortArrayInt.resi", "sort.cppo.resi", "TYPE_INT"],
34+
["belt_internalMapString.res", "internal_map.cppo.res", "TYPE_STRING"],
35+
["belt_internalMapInt.res", "internal_map.cppo.res", "TYPE_INT"],
36+
["belt_internalSetString.res", "internal_set.cppo.res", "TYPE_STRING"],
37+
["belt_internalSetInt.res", "internal_set.cppo.res", "TYPE_INT"],
38+
].forEach(([output, input, type]) => {
39+
execFileSync(
40+
"cppo",
41+
[
42+
"-n",
43+
"-D",
44+
type,
45+
`jscomp/others_cppo/${input}`,
46+
"-o",
47+
`jscomp/others/${output}`,
48+
],
49+
{ stdio: "inherit" },
50+
);
51+
});

scripts/ninja.js

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -435,29 +435,6 @@ function ninjaQuickBuildList(xs) {
435435
.join("\n");
436436
}
437437

438-
/**
439-
* @typedef { [string,string,string?]} CppoInput
440-
* @param {CppoInput[]} xs
441-
* @param {string} cwd
442-
* @returns {string}
443-
*/
444-
function cppoList(cwd, xs) {
445-
return xs
446-
.map(x => {
447-
/**
448-
* @type {KV[]}
449-
*/
450-
var variables;
451-
if (x[2]) {
452-
variables = [["type", `-D ${x[2]}`]];
453-
} else {
454-
variables = [];
455-
}
456-
return ninjaQuickBuild(x[0], x[1], cppoRuleName, cwd, variables, [], []);
457-
})
458-
.join("\n");
459-
}
460-
461438
/**
462439
*
463440
* @param {string} name
@@ -844,14 +821,6 @@ ${ninjaQuickBuildList([
844821
}
845822
}
846823

847-
var cppoRuleName = `cppo`;
848-
849-
var cppoRule = (flags = "") => `
850-
rule ${cppoRuleName}
851-
command = cppo -V OCAML:${getVersionString()} ${flags} $type $in -o $out
852-
generator = true
853-
`;
854-
855824
async function othersNinja(devmode = true) {
856825
var compilerTarget = pseudoTarget("$bsc");
857826
var externalDeps = [
@@ -901,7 +870,6 @@ ${ninjaQuickBuildList([
901870
x =>
902871
x.startsWith("js") &&
903872
(x.endsWith(".res") || x.endsWith(".resi")) &&
904-
!x.includes(".cppo") &&
905873
!x.includes(".pp") &&
906874
!x.includes("#") &&
907875
x !== "js.res",
@@ -912,8 +880,7 @@ ${ninjaQuickBuildList([
912880
x !== "belt.res" &&
913881
x !== "belt_internals.resi" &&
914882
(x.endsWith(".res") || x.endsWith(".resi")) &&
915-
!x.includes("#") &&
916-
!x.includes(".cppo"),
883+
!x.includes("#"),
917884
);
918885
var jsTargets = collectTarget(jsPrefixSourceFiles);
919886
var allJsTargets = scanFileTargets(jsTargets, []);
@@ -1219,7 +1186,6 @@ include body.ninja
12191186
`,
12201187
);
12211188

1222-
preprocessorNinjaSync(); // This is needed so that ocamldep makes sense
12231189
runtimeNinja();
12241190
stdlibNinja(true);
12251191
if (fs.existsSync(bsc_exe)) {
@@ -1230,60 +1196,6 @@ include body.ninja
12301196
exports.updateDev = updateDev;
12311197
exports.updateRelease = updateRelease;
12321198

1233-
function preprocessorNinjaSync() {
1234-
var dTypeString = "TYPE_STRING";
1235-
var dTypeInt = "TYPE_INT";
1236-
1237-
var cppoNative = `
1238-
${cppoRule("-n")}
1239-
${cppoList("others", [
1240-
["belt_HashSetString.res", "hashset.cppo.res", dTypeString],
1241-
["belt_HashSetString.resi", "hashset.cppo.resi", dTypeString],
1242-
["belt_HashSetInt.res", "hashset.cppo.res", dTypeInt],
1243-
["belt_HashSetInt.resi", "hashset.cppo.resi", dTypeInt],
1244-
["belt_HashMapString.res", "hashmap.cppo.res", dTypeString],
1245-
["belt_HashMapString.resi", "hashmap.cppo.resi", dTypeString],
1246-
["belt_HashMapInt.res", "hashmap.cppo.res", dTypeInt],
1247-
["belt_HashMapInt.resi", "hashmap.cppo.resi", dTypeInt],
1248-
["belt_MapString.res", "map.cppo.res", dTypeString],
1249-
["belt_MapString.resi", "map.cppo.resi", dTypeString],
1250-
["belt_MapInt.res", "map.cppo.res", dTypeInt],
1251-
["belt_MapInt.resi", "map.cppo.resi", dTypeInt],
1252-
["belt_SetString.res", "belt_Set.cppo.res", dTypeString],
1253-
["belt_SetString.resi", "belt_Set.cppo.resi", dTypeString],
1254-
["belt_SetInt.res", "belt_Set.cppo.res", dTypeInt],
1255-
["belt_SetInt.resi", "belt_Set.cppo.resi", dTypeInt],
1256-
["belt_MutableMapString.res", "mapm.cppo.res", dTypeString],
1257-
["belt_MutableMapString.resi", "mapm.cppo.resi", dTypeString],
1258-
["belt_MutableMapInt.res", "mapm.cppo.res", dTypeInt],
1259-
["belt_MutableMapInt.resi", "mapm.cppo.resi", dTypeInt],
1260-
["belt_MutableSetString.res", "setm.cppo.res", dTypeString],
1261-
["belt_MutableSetString.resi", "setm.cppo.resi", dTypeString],
1262-
["belt_MutableSetInt.res", "setm.cppo.res", dTypeInt],
1263-
["belt_MutableSetInt.resi", "setm.cppo.resi", dTypeInt],
1264-
["belt_SortArrayString.res", "sort.cppo.res", dTypeString],
1265-
["belt_SortArrayString.resi", "sort.cppo.resi", dTypeString],
1266-
["belt_SortArrayInt.res", "sort.cppo.res", dTypeInt],
1267-
["belt_SortArrayInt.resi", "sort.cppo.resi", dTypeInt],
1268-
["belt_internalMapString.res", "internal_map.cppo.res", dTypeString],
1269-
["belt_internalMapInt.res", "internal_map.cppo.res", dTypeInt],
1270-
["belt_internalSetString.res", "internal_set.cppo.res", dTypeString],
1271-
["belt_internalSetInt.res", "internal_set.cppo.res", dTypeInt],
1272-
])}
1273-
1274-
rule copy
1275-
command = cp $in $out
1276-
description = $in -> $out
1277-
`;
1278-
var cppoNinjaFile = "cppoVendor.ninja";
1279-
writeFileSync(path.join(jscompDir, cppoNinjaFile), cppoNative);
1280-
cp.execFileSync(vendorNinjaPath, ["-f", cppoNinjaFile, "--verbose", "-v"], {
1281-
cwd: jscompDir,
1282-
stdio: [0, 1, 2],
1283-
encoding: "utf8",
1284-
});
1285-
}
1286-
12871199
function main() {
12881200
if (require.main === module) {
12891201
if (process.argv.includes("-check")) {

0 commit comments

Comments
 (0)