commands: add linker options
This commit is contained in:
@@ -8,3 +8,8 @@ export const optFlag = (flag: string, opt: string | undefined) => undefList(opt,
|
|||||||
* Generate a switch flag, like "--rebuild", "--nobuild"
|
* Generate a switch flag, like "--rebuild", "--nobuild"
|
||||||
*/
|
*/
|
||||||
export const optSwitch = (flag: string, opt: boolean | undefined) => undefList(opt, opt => opt ? [flag] : [])
|
export const optSwitch = (flag: string, opt: boolean | undefined) => undefList(opt, opt => opt ? [flag] : [])
|
||||||
|
|
||||||
|
export const optMultiFlag = (flag: string, opt: string[] | undefined) =>
|
||||||
|
undefList(
|
||||||
|
opt,
|
||||||
|
opt => opt.flatMap(name => [flag, name]))
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { optFlag, optSwitch, undefList } from "./common";
|
import { optFlag, optMultiFlag, optSwitch, undefList } from "./common";
|
||||||
|
|
||||||
export interface GeneralOptions {
|
export interface GeneralOptions {
|
||||||
output?: string;
|
output?: string
|
||||||
|
|
||||||
|
sysroot?: string
|
||||||
|
|
||||||
outputKind?: "exe" | "object" | "assembly" | "preprocessed"
|
outputKind?: "exe" | "object" | "assembly" | "preprocessed"
|
||||||
}
|
}
|
||||||
@@ -20,7 +22,28 @@ export function generalCommand(options: GeneralOptions) {
|
|||||||
case "preprocessed":
|
case "preprocessed":
|
||||||
return ["-E"]
|
return ["-E"]
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
|
...optFlag("--sysroot", options.sysroot),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LinkerOptions {
|
||||||
|
/**
|
||||||
|
* Directory searched for "-l"
|
||||||
|
*/
|
||||||
|
searchDirs?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -l libraries.
|
||||||
|
* Static library dependecies must be sorted in topologic order.
|
||||||
|
*/
|
||||||
|
libraries?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function linkerCommand(options: LinkerOptions) {
|
||||||
|
return [
|
||||||
|
...optMultiFlag("-L", options.searchDirs),
|
||||||
|
...optMultiFlag("-l", options.libraries),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +53,7 @@ export interface PreprocessorOptions {
|
|||||||
|
|
||||||
export function preprocessorCommand(options: PreprocessorOptions) {
|
export function preprocessorCommand(options: PreprocessorOptions) {
|
||||||
return [
|
return [
|
||||||
...undefList(options.includeDirs, dirs => dirs.flatMap(name => ["-I", name]))
|
...optMultiFlag("-I", options.includeDirs),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +84,8 @@ export interface ExtractOptions {
|
|||||||
|
|
||||||
export function extractCommand(options: ExtractOptions): string[] {
|
export function extractCommand(options: ExtractOptions): string[] {
|
||||||
return [
|
return [
|
||||||
...undefList(options.func, func => func.flatMap(name => ["--func", name])),
|
...optMultiFlag("--func", options.func),
|
||||||
...undefList(options.bb, bb => bb.flatMap(name => ["--bb", name])),
|
...optMultiFlag("--bb", options.bb),
|
||||||
...optFlag("-o", options.output),
|
...optFlag("-o", options.output),
|
||||||
...optSwitch("-S", options.asm),
|
...optSwitch("-S", options.asm),
|
||||||
...undefList(options.input, input => [input])
|
...undefList(options.input, input => [input])
|
||||||
|
|||||||
Reference in New Issue
Block a user