treewide: refactor some constants to environment.ts

This commit is contained in:
2024-06-16 17:51:46 +08:00
parent 9c45a03a59
commit bf628dc609
3 changed files with 108 additions and 57 deletions

View File

@@ -2,21 +2,8 @@ import child_process from "child_process"
import { PlatformPath } from "path"
import path from "path"
const PREFIX = "/home/lyc/workspace/sw-autovec/swllvm-13.0.0-vect0919/local/installed/85e4fed0c9e4cd4ab8bce89f307127ccbad31294"
const PREFIXBIN = path.join(PREFIX, "bin")
const LLVM_EXTRACT = path.join(PREFIXBIN, "llvm-extract")
const SYSROOT_PREFIX = "/usr/sw/standard-830-6b-test"
const CXX = path.join(PREFIXBIN, "clang++")
const CC = path.join(PREFIXBIN, "clang")
const FC = path.join(PREFIXBIN, "flang")
const SYSROOT_COMMAND = [
"--sysroot",
SYSROOT_PREFIX,
]
// FIXME: these imports basically looks ugly.
import { LLVM_EXTRACT, PREFIX, SYSROOT_PREFIX, FLANG } from "./environment";
/**
@@ -93,35 +80,6 @@ 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.
@@ -140,7 +98,7 @@ export async function link(objects: string[], exe: string) {
// Construct link command
const linkcmd = [
FC,
FLANG,
...objects,
"-L", path.join(PREFIX, 'lib'),
// TODO: Implement rpath logic here if needed