diff options
author | Rubén Rincón Blanco <ruben@rinconblanco.es> | 2022-08-25 21:45:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 21:45:59 +0200 |
commit | 105b814acfc3f8b0286d0f59f3204be3dec3f9d3 (patch) | |
tree | 7e9aa8956519113baf75e5f3a5bafa742178a4da /lib/compilers | |
parent | 7c6a5291abdae74270c4462de29b086bdd67bb30 (diff) | |
download | compiler-explorer-105b814acfc3f8b0286d0f59f3204be3dec3f9d3.tar.gz compiler-explorer-105b814acfc3f8b0286d0f59f3204be3dec3f9d3.zip |
Fixes wrong types in libraries.interfaces.ts (#3982)gh-4021
* Fix getLibrary functions
* Fix library.path usage in Zig compiler
Diffstat (limited to 'lib/compilers')
-rw-r--r-- | lib/compilers/rust.ts | 32 | ||||
-rw-r--r-- | lib/compilers/zig.js | 14 |
2 files changed, 20 insertions, 26 deletions
diff --git a/lib/compilers/rust.ts b/lib/compilers/rust.ts index 89b52533d..f1d0d3a89 100644 --- a/lib/compilers/rust.ts +++ b/lib/compilers/rust.ts @@ -35,6 +35,7 @@ import {RustParser} from './argument-parsers'; export class RustCompiler extends BaseCompiler { linker: string; + static get key() { return 'rust'; } @@ -69,24 +70,19 @@ export class RustCompiler extends BaseCompiler { override getIncludeArguments(libraries) { const includeFlag = '--extern'; - return _.flatten( - _.map(libraries, selectedLib => { - const foundVersion = this.findLibVersion(selectedLib); - if (!foundVersion) return false; - if (!foundVersion.name) return false; - const list: string[] = []; - const lowercaseLibName = foundVersion.name.replaceAll('-', '_'); - for (const rlib of foundVersion.path) { - list.push( - includeFlag, - `${lowercaseLibName}=${foundVersion.name}/build/debug/${rlib}`, - '-L', - `dependency=${foundVersion.name}/build/debug/deps`, - ); - } - return list; - }), - ); + return libraries.flatMap(selectedLib => { + const foundVersion = this.findLibVersion(selectedLib); + if (!foundVersion || !foundVersion.name) return []; + const lowercaseLibName = foundVersion.name.replaceAll('-', '_'); + return foundVersion.path.flatMap(rlib => { + return [ + includeFlag, + `${lowercaseLibName}=${foundVersion.name}/build/debug/${rlib}`, + '-L', + `dependency=${foundVersion.name}/build/debug/deps`, + ]; + }); + }); } override orderArguments( diff --git a/lib/compilers/zig.js b/lib/compilers/zig.js index 1a9d0512d..d524fc1de 100644 --- a/lib/compilers/zig.js +++ b/lib/compilers/zig.js @@ -132,14 +132,12 @@ export class ZigCompiler extends BaseCompiler { } getIncludeArguments(libraries) { - return _.flatten( - _.map(libraries, selectedLib => { - const foundVersion = this.findLibVersion(selectedLib); - if (!foundVersion) return false; - // Zig should not have more than 1 path - return ['--pkg-begin', foundVersion.name, foundVersion.path, '--pkg-end']; - }), - ); + return libraries.flatMap(selectedLib => { + const foundVersion = this.findLibVersion(selectedLib); + if (!foundVersion) return []; + // Zig should not have more than 1 path, but it's still an array so spread it + return ['--pkg-begin', foundVersion.name, ...foundVersion.path, '--pkg-end']; + }); } getIrOutputFilename(inputFilename) { |