diff options
Diffstat (limited to 'lib/compilers')
-rw-r--r-- | lib/compilers/assembly.ts | 5 | ||||
-rw-r--r-- | lib/compilers/clean.ts | 10 | ||||
-rw-r--r-- | lib/compilers/dart.ts | 3 | ||||
-rw-r--r-- | lib/compilers/dosbox-compiler.ts | 2 | ||||
-rw-r--r-- | lib/compilers/fortran.ts | 48 | ||||
-rw-r--r-- | lib/compilers/spirv.ts | 5 | ||||
-rw-r--r-- | lib/compilers/win32.ts | 2 |
7 files changed, 47 insertions, 28 deletions
diff --git a/lib/compilers/assembly.ts b/lib/compilers/assembly.ts index ff08ffee3..0ef165840 100644 --- a/lib/compilers/assembly.ts +++ b/lib/compilers/assembly.ts @@ -157,10 +157,11 @@ export class AssemblyCompiler extends BaseCompiler { ), ); + const downloads = await buildEnvironment; + const execOptions = this.getDefaultExecOptions(); - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries); + execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries, dirPath); - const downloads = await buildEnvironment; const result = await this.buildExecutable(key.compiler.exe, compilerArguments, inputFilename, execOptions); const fullResult: BuildResult = { diff --git a/lib/compilers/clean.ts b/lib/compilers/clean.ts index 43d8a0c6f..169b964ea 100644 --- a/lib/compilers/clean.ts +++ b/lib/compilers/clean.ts @@ -27,10 +27,8 @@ import path from 'path'; import fs from 'fs-extra'; import type {ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; -import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {BaseCompiler} from '../base-compiler.js'; -import {propsFor} from '../properties.js'; import * as utils from '../utils.js'; export class CleanCompiler extends BaseCompiler { @@ -38,14 +36,6 @@ export class CleanCompiler extends BaseCompiler { return 'clean'; } - executionType: string; - - constructor(compiler: PreliminaryCompilerInfo, env) { - super(compiler, env); - const execProps = propsFor('execution'); - this.executionType = execProps('executionType', 'none'); - } - override optionsForFilter(filters: ParseFiltersAndOutputOptions) { if (filters.binary) { return []; diff --git a/lib/compilers/dart.ts b/lib/compilers/dart.ts index de67ec8b9..a3a6d578a 100644 --- a/lib/compilers/dart.ts +++ b/lib/compilers/dart.ts @@ -29,6 +29,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in import {BaseCompiler} from '../base-compiler.js'; import {DartAsmParser} from '../parsers/asm-parser-dart.js'; import * as utils from '../utils.js'; +import * as path from 'path'; import {BaseParser} from './argument-parsers.js'; import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js'; @@ -58,7 +59,7 @@ export class DartCompiler extends BaseCompiler { options = options.concat(utils.splitArguments(this.compiler.options)); } - const libIncludes = this.getIncludeArguments(libraries); + const libIncludes = this.getIncludeArguments(libraries, path.dirname(inputFilename)); const libOptions = this.getLibraryOptions(libraries); userOptions = this.filterUserOptions(userOptions) || []; diff --git a/lib/compilers/dosbox-compiler.ts b/lib/compilers/dosbox-compiler.ts index b4b08c716..73067573b 100644 --- a/lib/compilers/dosbox-compiler.ts +++ b/lib/compilers/dosbox-compiler.ts @@ -106,7 +106,7 @@ export class DosboxCompiler extends BaseCompiler { if (!options) { options = this.getDefaultExecOptions(); options.timeoutMs = 0; - options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); + options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([], undefined); } const key = this.getCompilerCacheKey(compiler, args, options); diff --git a/lib/compilers/fortran.ts b/lib/compilers/fortran.ts index d69fbacdb..bc1fbf69a 100644 --- a/lib/compilers/fortran.ts +++ b/lib/compilers/fortran.ts @@ -34,6 +34,7 @@ import * as utils from '../utils.js'; import {GccFortranParser} from './argument-parsers.js'; import {SelectedLibraryVersion} from '../../types/libraries/libraries.interfaces.js'; import _ from 'underscore'; +import * as fs from 'fs'; export class FortranCompiler extends BaseCompiler { static get key() { @@ -48,22 +49,44 @@ export class FortranCompiler extends BaseCompiler { return 'Change the Fortran standard version of the compiler.'; } - override getSharedLibraryPaths(libraries: CompileChildLibraries[]) { + getExactStaticLibNameAndPath(lib: string, libPaths: string[]): string { + const libFilename = 'lib' + lib + '.a'; + + // note: fortran doesn't use -llibname, + // you have to add the full filename to the commandline instead + // this thus requires the libraries to be downloaded before we can figure out the compiler arguments + for (const dir of libPaths) { + const testpath = path.join(dir, libFilename); + if (fs.existsSync(testpath)) { + return testpath; + } + } + + return ''; + } + + override getStaticLibraryLinks(libraries: CompileChildLibraries[], libPaths: string[] = []) { + return this.getSortedStaticLibraries(libraries) + .filter(lib => lib) + .map(lib => this.getExactStaticLibNameAndPath(lib, libPaths)); + } + + override getSharedLibraryPaths(libraries: CompileChildLibraries[], dirPath?: string): string[] { return libraries .map(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); if (!foundVersion) return false; const paths = [...foundVersion.libpath]; - if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot) { - paths.push(`/app/${selectedLib.id}/lib`); + if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot && dirPath) { + paths.push(path.join(dirPath, selectedLib.id, 'lib')); } return paths; }) - .flat(); + .flat() as string[]; } - override getIncludeArguments(libraries: SelectedLibraryVersion[]): string[] { + override getIncludeArguments(libraries: SelectedLibraryVersion[], dirPath: string): string[] { const includeFlag = this.compiler.includeFlag || '-I'; return libraries.flatMap(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); @@ -71,8 +94,10 @@ export class FortranCompiler extends BaseCompiler { const paths = foundVersion.path.map(path => includeFlag + path); if (foundVersion.packagedheaders) { - paths.push(`-I/app/${selectedLib.id}/mod`); - paths.push(includeFlag + `/app/${selectedLib.id}/include`); + const modPath = path.join(dirPath, selectedLib.id, 'mod'); + const includePath = path.join(dirPath, selectedLib.id, 'include'); + paths.push(`-I${modPath}`); + paths.push(includeFlag + includePath); } return paths; }); @@ -80,8 +105,9 @@ export class FortranCompiler extends BaseCompiler { override getSharedLibraryPathsAsArguments( libraries: CompileChildLibraries[], - libDownloadPath?: string, - toolchainPath?: string, + libDownloadPath: string, + toolchainPath: string, + dirPath: string, ) { const pathFlag = this.compiler.rpathFlag || this.defaultRpathFlag; const libPathFlag = this.compiler.libpathFlag || '-L'; @@ -100,8 +126,8 @@ export class FortranCompiler extends BaseCompiler { [pathFlag + libDownloadPath], this.compiler.libPath.map(path => pathFlag + path), toolchainLibraryPaths.map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => pathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => libPathFlag + path), ) as string[]; } diff --git a/lib/compilers/spirv.ts b/lib/compilers/spirv.ts index a709a43f8..c2b7fa1c5 100644 --- a/lib/compilers/spirv.ts +++ b/lib/compilers/spirv.ts @@ -79,7 +79,8 @@ export class SPIRVCompiler extends BaseCompiler { options = options.concat(unwrap(this.compiler.optArg)); } - const libIncludes = this.getIncludeArguments(libraries); + const dirPath = path.dirname(inputFilename); + const libIncludes = this.getIncludeArguments(libraries, dirPath); const libOptions = this.getLibraryOptions(libraries); let libLinks: string[] = []; let libPaths: string[] = []; @@ -87,7 +88,7 @@ export class SPIRVCompiler extends BaseCompiler { if (filters.binary) { libLinks = this.getSharedLibraryLinks(libraries); - libPaths = this.getSharedLibraryPathsAsArguments(libraries); + libPaths = this.getSharedLibraryPathsAsArguments(libraries, undefined, undefined, dirPath); staticLibLinks = this.getStaticLibraryLinks(libraries); } diff --git a/lib/compilers/win32.ts b/lib/compilers/win32.ts index 8f2cff314..9c793523b 100644 --- a/lib/compilers/win32.ts +++ b/lib/compilers/win32.ts @@ -116,7 +116,7 @@ export class Win32Compiler extends BaseCompiler { options = options.concat(unwrap(this.compiler.optArg)); } - const libIncludes = this.getIncludeArguments(libraries); + const libIncludes = this.getIncludeArguments(libraries, path.dirname(inputFilename)); const libOptions = this.getLibraryOptions(libraries); let libLinks: any[] = []; let libPaths: string[] = []; |