command/compiler: add optimize and target options
This commit is contained in:
@@ -1,11 +1,37 @@
|
||||
import { optFlag, optMultiFlag, optSwitch, undefList } from "./common";
|
||||
|
||||
export interface GeneralOptions {
|
||||
output?: string
|
||||
output?: string;
|
||||
|
||||
sysroot?: string
|
||||
sysroot?: string;
|
||||
|
||||
outputKind?: "exe" | "object" | "assembly" | "preprocessed"
|
||||
outputKind?: "exe" | "object" | "assembly" | "preprocessed";
|
||||
}
|
||||
|
||||
export interface Sw64TargetOptions {
|
||||
simd?: boolean;
|
||||
}
|
||||
|
||||
export function sw64TargetOptions(o: Sw64TargetOptions) {
|
||||
return [
|
||||
...optSwitch("-msimd", o.simd)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Options That Control Optimization.
|
||||
* https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
|
||||
*/
|
||||
export interface OptimizeOptions {
|
||||
optimize?: "1" | "2" | "3" | "0" | "s" | "fast" | "g" | "z";
|
||||
}
|
||||
|
||||
export function optimizeOptions(o: OptimizeOptions) {
|
||||
return [
|
||||
...undefList(o.optimize, optimize => {
|
||||
return [`-O${optimize}`];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
export function generalCommand(options: GeneralOptions) {
|
||||
@@ -14,17 +40,17 @@ export function generalCommand(options: GeneralOptions) {
|
||||
...undefList(options.outputKind, (opt) => {
|
||||
switch (opt) {
|
||||
case "object":
|
||||
return ["-c"]
|
||||
return ["-c"];
|
||||
case "exe":
|
||||
return []
|
||||
return [];
|
||||
case "assembly":
|
||||
return ["-S"]
|
||||
return ["-S"];
|
||||
case "preprocessed":
|
||||
return ["-E"]
|
||||
return ["-E"];
|
||||
}
|
||||
}),
|
||||
...optFlag("--sysroot", options.sysroot),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
interface LinkerOptions {
|
||||
@@ -44,7 +70,7 @@ export function linkerCommand(options: LinkerOptions) {
|
||||
return [
|
||||
...optMultiFlag("-L", options.searchDirs),
|
||||
...optMultiFlag("-l", options.libraries),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
export interface PreprocessorOptions {
|
||||
@@ -54,7 +80,7 @@ export interface PreprocessorOptions {
|
||||
export function preprocessorCommand(options: PreprocessorOptions) {
|
||||
return [
|
||||
...optMultiFlag("-I", options.includeDirs),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user