compiler: add GCC common options generator

This commit is contained in:
2024-06-16 16:28:22 +08:00
parent 2d78db3c2a
commit 9c45a03a59

View File

@@ -93,6 +93,35 @@ export async function extract(options: ExtractOptions) {
return exitcode return exitcode
} }
export interface GeneralOptions {
output?: string;
outputKind?: "exe" | "object" | "assembly" | "preprocessed"
}
export function generalCommand(options: GeneralOptions) {
return [
...(options.output ? ["-o", options.output] : []),
...(options.outputKind ? {
exe: [],
object: ["-c"],
assembly: ["-S"],
preprocessed: ["-E"]
}[options.outputKind] : [])
]
}
export interface PreprocessorOptions {
includeDirs?: string[];
}
export function preprocessorCommand(options: PreprocessorOptions) {
return [
...((options.includeDirs ?? []).flatMap(name => ["-I", name]))
]
}
/** /**
* Links objects into an executable using specified environment variables and paths. * Links objects into an executable using specified environment variables and paths.