Skip to content

Remove cppo stuff from ninja.js and move cppo files into separate folder #6934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jscomp/others/belt_HashSetInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

/***
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.

It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)

**See** [`Belt.HashSet`]()
**See** [`Belt.HashSet`]()
*/

type key = int
Expand Down
8 changes: 4 additions & 4 deletions jscomp/others/belt_HashSetString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

/***
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.

It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)

**See** [`Belt.HashSet`]()
**See** [`Belt.HashSet`]()
*/

type key = string
Expand Down
12 changes: 6 additions & 6 deletions jscomp/others/belt_SetInt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

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

**See** [`Belt.Set`]()
**See** [`Belt.Set`]()
*/

/** The type of the set elements. */
Expand Down Expand Up @@ -77,7 +77,7 @@ of sets.
*/
let cmp: (t, t) => int

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

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

/**
/**
`some(p, s)` checks if at least one element of the set satisfies the predicate
`p`. Oder unspecified.
*/
Expand Down
12 changes: 6 additions & 6 deletions jscomp/others/belt_SetString.resi
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

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

**See** [`Belt.Set`]()
**See** [`Belt.Set`]()
*/

/** The type of the set elements. */
Expand Down Expand Up @@ -77,7 +77,7 @@ of sets.
*/
let cmp: (t, t) => int

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

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

/**
/**
`some(p, s)` checks if at least one element of the set satisfies the predicate
`p`. Oder unspecified.
*/
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

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

**See** [`Belt.Set`]()
**See** [`Belt.Set`]()
*/

#ifdef TYPE_STRING
Expand Down Expand Up @@ -84,7 +84,7 @@ of sets.
*/
let cmp: (t, t) => int

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

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

/**
/**
`some(p, s)` checks if at least one element of the set satisfies the predicate
`p`. Oder unspecified.
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

/***
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.
This module is [`Belt.HashSet`]() specialized with key type to be a primitive type.

It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)
It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed,
and identity is not needed(using the built-in one)

**See** [`Belt.HashSet`]()
**See** [`Belt.HashSet`]()
*/

#ifdef TYPE_STRING
Expand Down
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.
51 changes: 51 additions & 0 deletions scripts/cppo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// @ts-check

const { execFileSync } = require("child_process");

[
["belt_HashSetString.res", "hashset.cppo.res", "TYPE_STRING"],
["belt_HashSetString.resi", "hashset.cppo.resi", "TYPE_STRING"],
["belt_HashSetInt.res", "hashset.cppo.res", "TYPE_INT"],
["belt_HashSetInt.resi", "hashset.cppo.resi", "TYPE_INT"],
["belt_HashMapString.res", "hashmap.cppo.res", "TYPE_STRING"],
["belt_HashMapString.resi", "hashmap.cppo.resi", "TYPE_STRING"],
["belt_HashMapInt.res", "hashmap.cppo.res", "TYPE_INT"],
["belt_HashMapInt.resi", "hashmap.cppo.resi", "TYPE_INT"],
["belt_MapString.res", "map.cppo.res", "TYPE_STRING"],
["belt_MapString.resi", "map.cppo.resi", "TYPE_STRING"],
["belt_MapInt.res", "map.cppo.res", "TYPE_INT"],
["belt_MapInt.resi", "map.cppo.resi", "TYPE_INT"],
["belt_SetString.res", "belt_Set.cppo.res", "TYPE_STRING"],
["belt_SetString.resi", "belt_Set.cppo.resi", "TYPE_STRING"],
["belt_SetInt.res", "belt_Set.cppo.res", "TYPE_INT"],
["belt_SetInt.resi", "belt_Set.cppo.resi", "TYPE_INT"],
["belt_MutableMapString.res", "mapm.cppo.res", "TYPE_STRING"],
["belt_MutableMapString.resi", "mapm.cppo.resi", "TYPE_STRING"],
["belt_MutableMapInt.res", "mapm.cppo.res", "TYPE_INT"],
["belt_MutableMapInt.resi", "mapm.cppo.resi", "TYPE_INT"],
["belt_MutableSetString.res", "setm.cppo.res", "TYPE_STRING"],
["belt_MutableSetString.resi", "setm.cppo.resi", "TYPE_STRING"],
["belt_MutableSetInt.res", "setm.cppo.res", "TYPE_INT"],
["belt_MutableSetInt.resi", "setm.cppo.resi", "TYPE_INT"],
["belt_SortArrayString.res", "sort.cppo.res", "TYPE_STRING"],
["belt_SortArrayString.resi", "sort.cppo.resi", "TYPE_STRING"],
["belt_SortArrayInt.res", "sort.cppo.res", "TYPE_INT"],
["belt_SortArrayInt.resi", "sort.cppo.resi", "TYPE_INT"],
["belt_internalMapString.res", "internal_map.cppo.res", "TYPE_STRING"],
["belt_internalMapInt.res", "internal_map.cppo.res", "TYPE_INT"],
["belt_internalSetString.res", "internal_set.cppo.res", "TYPE_STRING"],
["belt_internalSetInt.res", "internal_set.cppo.res", "TYPE_INT"],
].forEach(([output, input, type]) => {
execFileSync(
"cppo",
[
"-n",
"-D",
type,
`jscomp/others_cppo/${input}`,
"-o",
`jscomp/others/${output}`,
],
{ stdio: "inherit" },
);
});
90 changes: 1 addition & 89 deletions scripts/ninja.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,29 +435,6 @@ function ninjaQuickBuildList(xs) {
.join("\n");
}

/**
* @typedef { [string,string,string?]} CppoInput
* @param {CppoInput[]} xs
* @param {string} cwd
* @returns {string}
*/
function cppoList(cwd, xs) {
return xs
.map(x => {
/**
* @type {KV[]}
*/
var variables;
if (x[2]) {
variables = [["type", `-D ${x[2]}`]];
} else {
variables = [];
}
return ninjaQuickBuild(x[0], x[1], cppoRuleName, cwd, variables, [], []);
})
.join("\n");
}

/**
*
* @param {string} name
Expand Down Expand Up @@ -844,14 +821,6 @@ ${ninjaQuickBuildList([
}
}

var cppoRuleName = `cppo`;

var cppoRule = (flags = "") => `
rule ${cppoRuleName}
command = cppo -V OCAML:${getVersionString()} ${flags} $type $in -o $out
generator = true
`;

async function othersNinja(devmode = true) {
var compilerTarget = pseudoTarget("$bsc");
var externalDeps = [
Expand Down Expand Up @@ -901,7 +870,6 @@ ${ninjaQuickBuildList([
x =>
x.startsWith("js") &&
(x.endsWith(".res") || x.endsWith(".resi")) &&
!x.includes(".cppo") &&
!x.includes(".pp") &&
!x.includes("#") &&
x !== "js.res",
Expand All @@ -912,8 +880,7 @@ ${ninjaQuickBuildList([
x !== "belt.res" &&
x !== "belt_internals.resi" &&
(x.endsWith(".res") || x.endsWith(".resi")) &&
!x.includes("#") &&
!x.includes(".cppo"),
!x.includes("#"),
);
var jsTargets = collectTarget(jsPrefixSourceFiles);
var allJsTargets = scanFileTargets(jsTargets, []);
Expand Down Expand Up @@ -1219,7 +1186,6 @@ include body.ninja
`,
);

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

function preprocessorNinjaSync() {
var dTypeString = "TYPE_STRING";
var dTypeInt = "TYPE_INT";

var cppoNative = `
${cppoRule("-n")}
${cppoList("others", [
["belt_HashSetString.res", "hashset.cppo.res", dTypeString],
["belt_HashSetString.resi", "hashset.cppo.resi", dTypeString],
["belt_HashSetInt.res", "hashset.cppo.res", dTypeInt],
["belt_HashSetInt.resi", "hashset.cppo.resi", dTypeInt],
["belt_HashMapString.res", "hashmap.cppo.res", dTypeString],
["belt_HashMapString.resi", "hashmap.cppo.resi", dTypeString],
["belt_HashMapInt.res", "hashmap.cppo.res", dTypeInt],
["belt_HashMapInt.resi", "hashmap.cppo.resi", dTypeInt],
["belt_MapString.res", "map.cppo.res", dTypeString],
["belt_MapString.resi", "map.cppo.resi", dTypeString],
["belt_MapInt.res", "map.cppo.res", dTypeInt],
["belt_MapInt.resi", "map.cppo.resi", dTypeInt],
["belt_SetString.res", "belt_Set.cppo.res", dTypeString],
["belt_SetString.resi", "belt_Set.cppo.resi", dTypeString],
["belt_SetInt.res", "belt_Set.cppo.res", dTypeInt],
["belt_SetInt.resi", "belt_Set.cppo.resi", dTypeInt],
["belt_MutableMapString.res", "mapm.cppo.res", dTypeString],
["belt_MutableMapString.resi", "mapm.cppo.resi", dTypeString],
["belt_MutableMapInt.res", "mapm.cppo.res", dTypeInt],
["belt_MutableMapInt.resi", "mapm.cppo.resi", dTypeInt],
["belt_MutableSetString.res", "setm.cppo.res", dTypeString],
["belt_MutableSetString.resi", "setm.cppo.resi", dTypeString],
["belt_MutableSetInt.res", "setm.cppo.res", dTypeInt],
["belt_MutableSetInt.resi", "setm.cppo.resi", dTypeInt],
["belt_SortArrayString.res", "sort.cppo.res", dTypeString],
["belt_SortArrayString.resi", "sort.cppo.resi", dTypeString],
["belt_SortArrayInt.res", "sort.cppo.res", dTypeInt],
["belt_SortArrayInt.resi", "sort.cppo.resi", dTypeInt],
["belt_internalMapString.res", "internal_map.cppo.res", dTypeString],
["belt_internalMapInt.res", "internal_map.cppo.res", dTypeInt],
["belt_internalSetString.res", "internal_set.cppo.res", dTypeString],
["belt_internalSetInt.res", "internal_set.cppo.res", dTypeInt],
])}

rule copy
command = cp $in $out
description = $in -> $out
`;
var cppoNinjaFile = "cppoVendor.ninja";
writeFileSync(path.join(jscompDir, cppoNinjaFile), cppoNative);
cp.execFileSync(vendorNinjaPath, ["-f", cppoNinjaFile, "--verbose", "-v"], {
cwd: jscompDir,
stdio: [0, 1, 2],
encoding: "utf8",
});
}

function main() {
if (require.main === module) {
if (process.argv.includes("-check")) {
Expand Down