Skip to content

Commit

Permalink
Re-add gen_listings.ts
Browse files Browse the repository at this point in the history
Chromium build infrastructure depends on this file. In order to migrate to the new `gen_listings_and_webworkers.ts`, we need to do a N-way patch.
  • Loading branch information
ben-clayton committed Mar 12, 2024
1 parent 02a12ed commit 40acabf
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/common/tools/gen_listings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as fs from 'fs';
import * as path from 'path';
import * as process from 'process';

import { crawl } from './crawl.js';

function usage(rc: number): void {
console.error(`Usage: tools/gen_listings [options] [OUT_DIR] [SUITE_DIRS...]
For each suite in SUITE_DIRS, generate listings and write each listing.js
into OUT_DIR/{suite}/listing.js. Example:
tools/gen_listings gen/ src/unittests/ src/webgpu/
Options:
--help Print this message and exit.
`);
process.exit(rc);
}

const argv = process.argv;
if (argv.indexOf('--help') !== -1) {
usage(0);
}

{
// Ignore old argument that is now the default
const i = argv.indexOf('--no-validate');
if (i !== -1) {
argv.splice(i, 1);
}
}

if (argv.length < 4) {
usage(0);
}

const myself = 'src/common/tools/gen_listings.ts';

const outDir = argv[2];

for (const suiteDir of argv.slice(3)) {
// Run concurrently for each suite (might be a tiny bit more efficient)
void crawl(suiteDir, false).then(listing => {
const suite = path.basename(suiteDir);
const outFile = path.normalize(path.join(outDir, `${suite}/listing.js`));
fs.mkdirSync(path.join(outDir, suite), { recursive: true });
fs.writeFileSync(
outFile,
`\
// AUTO-GENERATED - DO NOT EDIT. See ${myself}.
export const listing = ${JSON.stringify(listing, undefined, 2)};
`
);
});
}

0 comments on commit 40acabf

Please sign in to comment.