Files
work-ts/src/commands/spec.ts
2024-06-25 18:40:36 +08:00

101 lines
3.0 KiB
TypeScript

import { optFlag, optSwitch, undefList } from "./common";
export interface RunCPUOptions {
/**
* Most runcpu commands perform an action on a set of benchmarks.
*
* The default action is validate.
*
* 'build'
*/
action?: 'build'
| 'buildstep'
| 'validate'
| 'runsetup';
/**
* Config file, used for compiling flags, compiler versions, etc.
*/
config?: string;
/**
* SPEC workload scale for each benchmark
*/
workload?: "test" | "train" | "ref";
/**
* Selected benchmarks
*/
benchmarks?: string[];
buildType?: "nobuild" | "rebuild",
/**
* Default: HTML and text
* Meaning: Desired report format.
* An output format may be deselected by prepending any of the names with the word "no".
* If more than one option is used, separate them by commas or colons.
* The values are not case-sensitive.
*/
outputFormat?: ("all"
/** config file used for this run, written as a numbered file in the result directory, for example */
| "config"
/** Reportable syntax check */
| "check"
/**
* Comma-separated variable.
* If you populate spreadsheets from your runs,
* you probably should not cut/paste data from text files;
* you'll get more accurate data by using --output_format csv.
* The csv report includes all runs, more decimal places,
* system information, and even the compiler flags.
*/
| "csv"
| "default"
| "flags"
| "html"
| "mail"
| "pdf"
| "postscript"
| "raw"
| "screen"
/** Plain ASCII text file */
| "text")[];
/**
* Synonyms: none
* Default: --setprocgroup
* Meaning: Attempt to create all processes in a single group. Improves the chances that ^C will get the whole run, not just one of the children.
*/
setprocgroup?: boolean;
/**
* If set to a non-empty value, all output files will be rooted under the named directory, instead of under $SPEC (or %SPEC%).
* If directory is not an absolute path (one that begins with "/" on Unix, or a device name on Windows), the path will be created under $SPEC.
*
* This option can be useful for sharing an installation.
*/
outputRoot?: string;
}
export function runcpuOptions(o: RunCPUOptions): string[] {
return [
...optFlag("-c", o.config),
...optFlag("-i", o.workload),
...undefList(o.buildType, opt => {
switch (opt) {
case "nobuild":
return ["--nobuild"];
case "rebuild":
return ["--rebuild"];
default:
return [];
}
}),
...undefList(o.benchmarks, bench => bench),
...undefList(o.outputFormat, of => ["--output_format", of.join(",")]),
...optSwitch("--setprocgroup", o.setprocgroup),
...optFlag("--output_root", o.outputRoot),
];
}