diff options
author | RabsRincon <rubrinbla@gmail.com> | 2018-01-18 19:43:10 +0100 |
---|---|---|
committer | RabsRincon <rubrinbla@gmail.com> | 2018-01-18 19:43:10 +0100 |
commit | a54faefb4c8668d9c9f93c78bd6bc639d1f0c219 (patch) | |
tree | 6465bf3e1d8e270cc53e67c04277c5773b16f7d6 /lib/compilers/WSL-CL.js | |
parent | 7bd30b4c4b10f93f26db81fbbe492149b8d487eb (diff) | |
download | compiler-explorer-a54faefb4c8668d9c9f93c78bd6bc639d1f0c219.tar.gz compiler-explorer-a54faefb4c8668d9c9f93c78bd6bc639d1f0c219.zip |
ES6fy compilers inheritance
Diffstat (limited to 'lib/compilers/WSL-CL.js')
-rw-r--r-- | lib/compilers/WSL-CL.js | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/lib/compilers/WSL-CL.js b/lib/compilers/WSL-CL.js index 1a3e37ec1..675c163ba 100644 --- a/lib/compilers/WSL-CL.js +++ b/lib/compilers/WSL-CL.js @@ -28,68 +28,73 @@ // Don't run under Wine (obviously) // Translate compiler path from Unix mounted volume (/mnt/c/tmp) to Windows (c:/tmp) -const Compile = require('../base-compiler'), - asm = require('../asm-cl'), +const BaseCompiler = require('../base-compiler'), + asmCl = require('../asm-cl'), temp = require('temp'), - RunCLDemangler = require('../cl-support').RunCLDemangler; + RunCLDemangler = require('../cl-support').RunCLDemangler, + argumentParsers = require("./argument-parsers"); -function compileCl(info, env) { - var compile = new Compile(info, env); - compile.asm = new asm.AsmParser(compile.compilerProps); - info.supportsFiltersInBinary = true; - if ((process.platform === "linux") || (process.platform === "darwin")) { - const origExec = compile.exec; - compile.exec = function (command, args, options) { - return origExec(command, args, options); - }; - compile.filename = function (fn) { - // AP: Need to translate compiler paths from what the Node.js process sees +class WSLCLCompiler extends BaseCompiler { + constructor(info, env) { + info.supportsFiltersInBinary = true; + super(info, env); + this.asm = new asmCl.AsmParser(); + + if (info.unitTestMode) { + this.initialise(); + return this; + } else { + return this.initialise(); + } + } + + filename(fn) { + if (process.platform === "linux" || process.platform === "darwin") { + // AP: Need to translate compiler paths from what the Node.js process sees // on a Unix mounted volume (/mnt/c/tmp) to what CL sees on Windows (c:/tmp) // We know process.env.tmpDir is of format /mnt/X/dir where X is drive letter. const driveLetter = process.env.winTmp.substring(5, 6); const directoryPath = process.env.winTmp.substring(7); const windowsStyle = driveLetter.concat(":/", directoryPath); return fn.replace(process.env.winTmp, windowsStyle); - }; + } else { + return super.filename(fn); + } } + // AP: Create CE temp directory in winTmp directory instead of the tmpDir directory. // NPM temp package: https://www.npmjs.com/package/temp, see Affixes - compile.newTempDir = function () { - return new Promise(function (resolve, reject) { - temp.mkdir({prefix: 'compiler-explorer-compiler', dir: process.env.winTmp}, function (err, dirPath) { + newTempDir () { + return new Promise((resolve, reject) => { + temp.mkdir({prefix: 'compiler-explorer-compiler', dir: process.env.winTmp}, (err, dirPath) => { if (err) - reject("Unable to open temp file: " + err); + reject(`Unable to open temp file: ${err}`); else resolve(dirPath); }); }); - }; - compile.supportsObjdump = function () { + } + + supportsObjdump() { return false; - }; + } - compile.getArgumentParser = () => (compiler) => compiler; + getArgumentParser() { + return argumentParsers.Base; + } - compile.postProcessAsm = function(result) { + postProcessAsm(result) { return RunCLDemangler(this, result); - }; + } - compile.optionsForFilter = function (filters, outputFilename) { + optionsForFilter(filters, outputFilename) { return [ '/FAsc', '/c', '/Fa' + this.filename(outputFilename), '/Fo' + this.filename(outputFilename + '.obj') ]; - }; - - if (info.unitTestMode) { - compile.initialise(); - - return compile; - } else { - return compile.initialise(); } } -module.exports = compileCl; +module.exports = WSLCLCompiler; |