diff options
author | Alexandros Naskos <alex_naskos@hotmail.com> | 2020-10-04 20:20:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 19:20:44 +0200 |
commit | 1ecfa68e0990b0d8de3a7cb1b0da62159d52dac3 (patch) | |
tree | 6fd6abff60c83dd9e40cd7b5ca4f564cfb1379e7 /lib/compilers/zig.js | |
parent | a659ad6a64a9599a281ecd120f8de4d873994b03 (diff) | |
download | compiler-explorer-1ecfa68e0990b0d8de3a7cb1b0da62159d52dac3.tar.gz compiler-explorer-1ecfa68e0990b0d8de3a7cb1b0da62159d52dac3.zip |
Update Zig to use the new CLI (#2254)
* Fixed zig.js for the new self hosted command line interface
* Broke up long line into two
Diffstat (limited to 'lib/compilers/zig.js')
-rw-r--r-- | lib/compilers/zig.js | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/compilers/zig.js b/lib/compilers/zig.js index 35115581b..bcc396e41 100644 --- a/lib/compilers/zig.js +++ b/lib/compilers/zig.js @@ -65,11 +65,29 @@ export class ZigCompiler extends BaseCompiler { optionsForFilter(filters, outputFilename, userOptions) { let options = [filters.execute ? 'build-exe' : 'build-obj']; - if (this.compiler.semver === 'trunk' || (this.compiler.semver && Semver.gt(this.compiler.semver, '0.3.0'))) { + + let self_hosted_cli = this.compiler.semver === 'trunk' || + (this.compiler.semver && Semver.gt(this.compiler.semver, '0.6.0')); + const desiredName = path.basename(outputFilename); + // strip '.s' if we aren't executing + const name = filters.execute ? desiredName : desiredName.slice(0, -2); + + if (self_hosted_cli) { + // Versions after 0.6.0 use a different command line interface. + const outputDir = path.dirname(outputFilename); + options.push('--cache-dir', outputDir, + '--name', name); + + if (!filters.binary) { + options.push('-fno-emit-bin', '-femit-asm=' + desiredName); + } else { + options.push('-femit-bin=' + desiredName); + } + return options; + } + + if (this.compiler.semver && Semver.gt(this.compiler.semver, '0.3.0')) { const outputDir = path.dirname(outputFilename); - const desiredName = path.basename(outputFilename); - // strip '.s' if we aren't executing - const name = filters.execute ? desiredName : desiredName.slice(0, -2); options.push('--cache-dir', outputDir, '--output-dir', outputDir, '--name', name); @@ -96,7 +114,7 @@ export class ZigCompiler extends BaseCompiler { } filterUserOptions(userOptions) { - const forbiddenOptions = /^(((--(cache-dir|name|output|verbose))|(-mllvm)).*)$/; + const forbiddenOptions = /^(((--(cache-dir|name|output|verbose))|(-mllvm|-fno-emit-bin|-femit-bin)).*)$/; return _.filter(userOptions, option => !forbiddenOptions.test(option)); } |