aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/WSL-CL.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers/WSL-CL.js')
-rw-r--r--lib/compilers/WSL-CL.js68
1 files changed, 33 insertions, 35 deletions
diff --git a/lib/compilers/WSL-CL.js b/lib/compilers/WSL-CL.js
index 1a3e37ec1..0848db92b 100644
--- a/lib/compilers/WSL-CL.js
+++ b/lib/compilers/WSL-CL.js
@@ -28,68 +28,66 @@
// 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();
+ }
+
+ 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;