Write all build scripts at once
This commit is contained in:
parent
5ef6c0ff51
commit
33edf76b93
2
Makefile
2
Makefile
|
@ -57,7 +57,7 @@ scripts:
|
||||||
node tools/make-foreach.js --types script L=$(L)
|
node tools/make-foreach.js --types script L=$(L)
|
||||||
|
|
||||||
all-scripts:
|
all-scripts:
|
||||||
node tools/make-foreach.js --pkgs script
|
node tools/write-all-build-scripts.js
|
||||||
|
|
||||||
pkg-clean:
|
pkg-clean:
|
||||||
@: $${L} $${T}
|
@: $${L} $${T}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import nodePath from "path";
|
import nodePath from "path";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
import url from "url";
|
||||||
|
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
|
@ -321,6 +322,22 @@ function makeSharedScript(langConfig) {
|
||||||
return makeLangScript(langConfig, true);
|
return makeLangScript(langConfig, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generateBuildScript({ lang, type }) {
|
||||||
|
const scriptMaker = {
|
||||||
|
lang: makeLangScript,
|
||||||
|
config: makeConfigScript,
|
||||||
|
shared: makeSharedScript,
|
||||||
|
}[type];
|
||||||
|
if (!scriptMaker) {
|
||||||
|
throw new Error(`unsupported script type ${type}`);
|
||||||
|
}
|
||||||
|
return scriptMaker(
|
||||||
|
type === "shared"
|
||||||
|
? await readSharedDepConfig(lang)
|
||||||
|
: await readLangConfig(lang)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Parse command-line arguments, run main functionality, and exit.
|
// Parse command-line arguments, run main functionality, and exit.
|
||||||
async function main() {
|
async function main() {
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
@ -331,26 +348,13 @@ async function main() {
|
||||||
"package category (lang, config, shared)"
|
"package category (lang, config, shared)"
|
||||||
);
|
);
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
const scriptMaker = {
|
console.log(generateBuildScript({ lang: program.lang, type: program.type }));
|
||||||
lang: makeLangScript,
|
|
||||||
config: makeConfigScript,
|
|
||||||
shared: makeSharedScript,
|
|
||||||
}[program.type];
|
|
||||||
if (!scriptMaker) {
|
|
||||||
console.error(`make-script.js: unsupported --type ${program.type}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
console.log(
|
|
||||||
scriptMaker(
|
|
||||||
program.type === "shared"
|
|
||||||
? await readSharedDepConfig(program.lang)
|
|
||||||
: await readLangConfig(program.lang)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
||||||
console.error(err);
|
main().catch((err) => {
|
||||||
process.exit(1);
|
console.error(err);
|
||||||
});
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
// This script is not really needed per se, but it's a bit slow to run
|
||||||
|
// Make/Node.js several hundred times in order to 'make all-scripts',
|
||||||
|
// hence having a single script that does the whole thing.
|
||||||
|
|
||||||
|
import { promises as fs } from "fs";
|
||||||
|
import process from "process";
|
||||||
|
import url from "url";
|
||||||
|
|
||||||
|
import { getPackages } from "./config.js";
|
||||||
|
import { generateBuildScript } from "./generate-build-script.js";
|
||||||
|
|
||||||
|
// Parse command-line arguments, run main functionality, and exit.
|
||||||
|
async function main() {
|
||||||
|
for (const { lang, type } of await getPackages()) {
|
||||||
|
await fs.mkdir(`build/${type}/${lang}`, { recursive: true });
|
||||||
|
await fs.writeFile(
|
||||||
|
`build/${type}/${lang}/build.bash`,
|
||||||
|
await generateBuildScript({ lang, type })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue