compiler: add GCC common options generator
This commit is contained in:
29
compiler.ts
29
compiler.ts
@@ -93,6 +93,35 @@ export async function extract(options: ExtractOptions) {
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user