cmake: change sources from glob-based to file-based (#19535)

This commit is contained in:
Dylan Conway
2025-05-08 16:58:06 -07:00
committed by GitHub
parent 500199fe8b
commit ff1ff78e77
16 changed files with 1541 additions and 82 deletions

40
scripts/glob-sources.mjs Normal file
View File

@@ -0,0 +1,40 @@
import { write, Glob, file } from "bun";
import { join, resolve, relative } from "path";
import { normalize } from "path/posix";
const root = resolve(import.meta.dirname, "..");
let total = 0;
async function globSources(output, patterns, excludes = []) {
const paths = [];
for (const pattern of patterns) {
const glob = new Glob(pattern);
for await (const path of glob.scan()) {
if (excludes?.some(exclude => normalize(path) === normalize(exclude))) {
continue;
}
paths.push(path);
}
}
total += paths.length;
const sources = paths
.map(path => normalize(relative(root, path)))
.sort((a, b) => a.localeCompare(b))
.join("\n");
await write(join(root, "cmake", output), sources);
}
const input = await file(join(root, "cmake", "Sources.json")).json();
const start = performance.now();
for (const item of input) {
await globSources(item.output, item.paths, item.exclude);
}
const end = performance.now();
const green = "\x1b[32m";
const reset = "\x1b[0m";
const bold = "\x1b[1m";
console.log(`\nGlobbed ${bold}${green}${total}${reset} sources [${(end - start).toFixed(2)}ms]`);