diff --git a/compiler.ts b/compiler.ts index e4c2220..b2bc5a9 100644 --- a/compiler.ts +++ b/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.