aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/asm-cl.js2
-rw-r--r--lib/base-compiler.js (renamed from lib/compile.js)261
-rw-r--r--lib/compilation-env.js4
-rw-r--r--lib/compile-handler.js130
-rw-r--r--lib/compilers/6g.js60
-rw-r--r--lib/compilers/CL.js58
-rw-r--r--lib/compilers/default.js30
-rw-r--r--lib/compilers/ldc.js38
-rw-r--r--lib/compilers/rust.js39
-rw-r--r--lib/diff.js2
10 files changed, 394 insertions, 230 deletions
diff --git a/lib/asm-cl.js b/lib/asm-cl.js
index ad2932466..b701a789a 100644
--- a/lib/asm-cl.js
+++ b/lib/asm-cl.js
@@ -29,7 +29,7 @@ var expandTabs = require('./utils').expandTabs;
var sourceTag = /^;\s*([0-9]+)\s*:/;
var ignoreAll = /^\s*include listing\.inc$/;
var fileFind = /^; File\s+(.*)$/;
-var gccExplorerDir = /\\gcc-explorer-compiler/; // has to match part of the path in compile.js (ugly)
+var gccExplorerDir = /\\gcc-explorer-compiler/; // has to match part of the path in compile-handler.js (ugly)
// Parse into:
// * optional leading whitespace
// * middle part
diff --git a/lib/compile.js b/lib/base-compiler.js
index 6c218f81f..10cc779c6 100644
--- a/lib/compile.js
+++ b/lib/base-compiler.js
@@ -1,71 +1,45 @@
// Copyright (c) 2012-2016, Matt Godbolt
// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
+//
+// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
+//
+// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
var child_process = require('child_process'),
temp = require('temp'),
path = require('path'),
- httpProxy = require('http-proxy'),
fs = require('fs-extra'),
Promise = require('promise'), // jshint ignore:line
asm = require('./asm'),
- utils = require('./utils'),
- quote = require('shell-quote'),
+ utils = require('./utils'
+),
+quote = require('shell-quote'),
_ = require('underscore-node'),
- logger = require('./logger').logger,
- CompilationEnvironment = require('./compilation-env').CompilationEnvironment;
-
-temp.track();
-
-function periodicCleanup() {
- temp.cleanup(function (err, stats) {
- if (err) logger.error("Error cleaning directories: ", err);
- if (stats) logger.debug("Directory cleanup stats:", stats);
- });
-}
-var gccProps = null;
-var compilerProps = null;
-var stubRe = null;
-var stubText = null;
-
-function identity(x) {
- return x;
-}
-
-function initialise(gccProps_, compilerProps_) {
- gccProps = gccProps_;
- compilerProps = compilerProps_;
- var tempDirCleanupSecs = gccProps("tempDirCleanupSecs", 600);
- logger.info("Cleaning temp dirs every " + tempDirCleanupSecs + " secs");
- setInterval(periodicCleanup, tempDirCleanupSecs * 1000);
- asm.initialise(compilerProps);
- stubRe = compilerProps("stubRe");
- stubText = compilerProps("stubText");
-}
+ logger = require('./logger').logger;
function Compile(compiler, env) {
this.compiler = compiler;
this.env = env;
+ // TODO: make `asm` an object instead of a big fat global. Then CL can instantiate
+ // a completely different ASM here instead of a dodgy regexp to choose its parser.
+ asm.initialise(env.compilerProps);
}
Compile.prototype.newTempDir = function () {
@@ -91,10 +65,10 @@ Compile.prototype.getRemote = function () {
Compile.prototype.runCompiler = function (compiler, options, inputFilename) {
return this.exec(compiler, options, {
- timeoutMs: gccProps("compileTimeoutMs", 100),
- maxErrorOutput: gccProps("max-error-output", 5000),
+ timeoutMs: this.env.gccProps("compileTimeoutMs", 100),
+ maxErrorOutput: this.env.gccProps("max-error-output", 5000),
env: this.env.getEnv(this.compiler.needsMulti),
- wrapper: compilerProps("compiler-wrapper")
+ wrapper: this.env.compilerProps("compiler-wrapper")
}).then(function (result) {
result.stdout = utils.parseOutput(result.stdout, inputFilename);
result.stderr = utils.parseOutput(result.stderr, inputFilename);
@@ -158,13 +132,13 @@ Compile.prototype.compile = function (source, options, filters) {
return Promise.resolve(cached);
}
- if (filters.binary && !source.match(stubRe)) {
- source += "\n" + stubText + "\n";
+ if (filters.binary && !source.match(this.env.compilerProps("stubRe"))) {
+ source += "\n" + this.env.compilerProps("stubText") + "\n";
}
var tempFileAndDirPromise = Promise.resolve().then(function () {
return self.newTempDir().then(function (dirPath) {
- var inputFilename = path.join(dirPath, compilerProps("compileFilename"));
+ var inputFilename = path.join(dirPath, self.env.compilerProps("compileFilename"));
return self.writeFile(inputFilename, source).then(function () {
return {inputFilename: inputFilename, dirPath: dirPath};
});
@@ -177,7 +151,7 @@ Compile.prototype.compile = function (source, options, filters) {
var outputFilename = path.join(dirPath, 'output.s'); // NB keep lower case as ldc compiler `tolower`s the output name
options = self.prepareArguments(options, filters, inputFilename, outputFilename);
- options = options.filter(identity);
+ options = options.filter(_.identity);
return self.runCompiler(self.compiler.exe, options, self.filename(inputFilename))
.then(function (result) {
result.dirPath = dirPath;
@@ -225,8 +199,8 @@ Compile.prototype.postProcessAsm = function (result) {
};
Compile.prototype.postProcess = function (result, outputFilename, filters) {
- var postProcess = this.compiler.postProcess.filter(identity);
- var maxSize = gccProps("max-asm-size", 8 * 1024 * 1024);
+ var postProcess = this.compiler.postProcess.filter(_.identity);
+ var maxSize = this.env.gccProps("max-asm-size", 8 * 1024 * 1024);
if (filters.binary && this.supportsObjdump()) {
return this.objdump(outputFilename, result, maxSize, filters.intel);
}
@@ -399,171 +373,4 @@ Compile.prototype.getInfo = function () {
return this.compiler;
};
-function compileCl(info, env) {
- var compile = new Compile(info, env);
- info.supportsFiltersInBinary = true;
- if (process.platform == "linux") {
- var wine = gccProps("wine");
- var origExec = compile.exec;
- compile.exec = function (command, args, options) {
- if (command.toLowerCase().endsWith(".exe")) {
- args.unshift(command);
- command = wine;
- }
- return origExec(command, args, options);
- };
- compile.filename = function (fn) {
- return 'Z:' + fn;
- };
- }
- compile.supportsObjdump = function () {
- return false;
- };
- compile.optionsForFilter = function (filters, outputFilename) {
- return [
- '/FAsc',
- '/c',
- '/Fa' + this.filename(outputFilename),
- '/Fo' + this.filename(outputFilename + '.obj')
- ];
- };
- return compile.initialise();
-}
-
-function compile6g(info, env) {
- function convert6g(code) {
- var re = /^[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/;
- var prevLine = null;
- var file = null;
- return code.map(function (obj) {
- var line = obj.line;
- var match = line.match(re);
- if (match) {
- var res = "";
- if (file === null) {
- res += "\t.file 1 \"" + match[1] + "\"\n";
- file = match[1];
- }
- if (prevLine != match[2]) {
- res += "\t.loc 1 " + match[2] + "\n";
- prevLine = match[2];
- }
- return res + "\t" + match[3].toLowerCase() + match[4];
- } else
- return null;
- }).filter(identity).join("\n");
- }
-
- var compiler = new Compile(info, env);
- compiler.postProcess = function () {
- result.asm = this.convert6g(result.stdout);
- result.stdout = [];
- return Promise.resolve(result);
- };
- return compiler;
-}
-
-function compileRust(info, env) {
- var compiler = new Compile(info, env);
- // TODO this needs testing!
- compiler.optionsForFilter = function (filters, outputFilename) {
- var options = ['-g', '-o', this.filename(outputFilename)];
- // TODO: binary not supported(?)
- if (!filters.binary) options = options.concat('--emit', 'asm');
- options = options.concat(['--crate-type', 'staticlib']);
- return options;
- };
-}
-
-function compileLdc(info, env) {
- var compiler = new Compile(info, env);
- // TODO this needs testing!
- compiler.optionsForFilter = function (filters, outputFilename) {
- var options = ['-g', '-of', this.filename(outputFilename)];
- if (filters.intel && !filters.binary) options.concat('-x86-asm-syntax=intel');
- if (!filters.binary) options = options.concat('-output-s');
- return options;
- };
-}
-
-var compileFactories = {
- "": function (info, env) {
- var comp = new Compile(info, env);
- return comp.initialise();
- },
- "CL": compileCl,
- "6g": compile6g,
- "rust": compileRust,
- "ldc": compileLdc
-};
-
-function CompileHandler() {
- this.compilersById = {};
- this.compilerEnv = new CompilationEnvironment(gccProps);
-
- this.setCompilers = function (compilers) {
- var initPromises = _.map(compilers, function (compiler) {
- return compileFactories[compiler.compilerType](compiler, this.compilerEnv);
- }, this);
- return Promise.all(initPromises)
- .then(function (compilers) {
- return _.filter(compilers, identity);
- })
- .then(_.bind(function (compilers) {
- _.each(compilers, function (compiler) {
- this.compilersById[compiler.compiler.id] = compiler;
- }, this);
- return _.map(compilers, function (compiler) {
- return compiler.getInfo();
- });
- }, this)).catch(function (err) {
- logger.error(err);
- });
- };
- var proxy = httpProxy.createProxyServer({});
-
- this.handler = _.bind(function compile(req, res, next) {
- var compiler = this.compilersById[req.body.compiler];
- if (!compiler) return next();
-
- var remote = compiler.getRemote();
- if (remote) {
- proxy.web(req, res, {target: remote}, function (e) {
- logger.error("Proxy error: ", e);
- next(e);
- });
- return;
- }
- var source = req.body.source;
- var options = req.body.options || '';
- if (source === undefined) {
- return next(new Error("Bad request"));
- }
- options = _.chain(quote.parse(options)
- .map(function (x) {
- if (typeof(x) == "string") return x;
- return x.pattern;
- }))
- .filter(identity)
- .value();
- var filters = req.body.filters;
- compiler.compile(source, options, filters).then(
- function (result) {
- res.set('Content-Type', 'application/json');
- res.end(JSON.stringify(result));
- },
- function (error) {
- logger.error("Error: " + error);
- if (typeof(error) !== "string") {
- error = "Internal GCC explorer error: " + error.toString();
- }
- res.end(JSON.stringify({code: -1, stderr: [{text: error}]}));
- }
- );
- }, this);
-}
-
-module.exports = {
- CompileHandler: CompileHandler,
- initialise: initialise
-};
+module.exports = Compile; \ No newline at end of file
diff --git a/lib/compilation-env.js b/lib/compilation-env.js
index 3a19d1ced..0e91da1cf 100644
--- a/lib/compilation-env.js
+++ b/lib/compilation-env.js
@@ -31,7 +31,9 @@ var LRU = require('lru-cache'),
Queue.configure(Promise);
-function CompilationEnvironment(gccProps) {
+function CompilationEnvironment(gccProps, compilerProps) {
+ this.gccProps = gccProps;
+ this.compilerProps = compilerProps;
this.okOptions = new RegExp(gccProps('optionsWhitelistRe', '.*'));
this.badOptions = new RegExp(gccProps('optionsBlacklistRe', '(?!)'));
this.cache = LRU({
diff --git a/lib/compile-handler.js b/lib/compile-handler.js
new file mode 100644
index 000000000..1b2ff7570
--- /dev/null
+++ b/lib/compile-handler.js
@@ -0,0 +1,130 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var child_process = require('child_process'),
+ temp = require('temp'),
+ httpProxy = require('http-proxy'),
+ Promise = require('promise'), // jshint ignore:line
+ quote = require('shell-quote'),
+ _ = require('underscore-node'),
+ logger = require('./logger').logger,
+ CompilationEnvironment = require('./compilation-env').CompilationEnvironment;
+
+temp.track();
+
+function periodicCleanup() {
+ temp.cleanup(function (err, stats) {
+ if (err) logger.error("Error cleaning directories: ", err);
+ if (stats) logger.debug("Directory cleanup stats:", stats);
+ });
+}
+
+var oneTimeInit = false;
+function initialise(gccProps, compilerProps) {
+ if (oneTimeInit) return;
+ oneTimeInit = true;
+ var tempDirCleanupSecs = gccProps("tempDirCleanupSecs", 600);
+ logger.info("Cleaning temp dirs every " + tempDirCleanupSecs + " secs");
+ setInterval(periodicCleanup, tempDirCleanupSecs * 1000);
+}
+
+function CompileHandler(gccProps, compilerProps) {
+ initialise(gccProps, compilerProps);
+ this.compilersById = {};
+ this.compilerEnv = new CompilationEnvironment(gccProps, compilerProps);
+ this.factories = {};
+
+ this.create = function (compiler) {
+ var type = compiler.compilerType || "default";
+ if (this.factories[type] === undefined) {
+ var path = './compilers/' + type;
+ logger.info("Loading compiler from", path);
+ this.factories[type] = require(path);
+ }
+ return this.factories[type](compiler, this.compilerEnv);
+ };
+
+ this.setCompilers = function (compilers) {
+ var initPromises = _.map(compilers, this.create, this);
+ return Promise.all(initPromises)
+ .then(function (compilers) {
+ return _.filter(compilers, _.identity);
+ })
+ .then(_.bind(function (compilers) {
+ _.each(compilers, function (compiler) {
+ this.compilersById[compiler.compiler.id] = compiler;
+ }, this);
+ return _.map(compilers, function (compiler) {
+ return compiler.getInfo();
+ });
+ }, this)).catch(function (err) {
+ logger.error(err);
+ });
+ };
+ var proxy = httpProxy.createProxyServer({});
+
+ this.handler = _.bind(function compile(req, res, next) {
+ var compiler = this.compilersById[req.body.compiler];
+ if (!compiler) return next();
+
+ var remote = compiler.getRemote();
+ if (remote) {
+ proxy.web(req, res, {target: remote}, function (e) {
+ logger.error("Proxy error: ", e);
+ next(e);
+ });
+ return;
+ }
+ var source = req.body.source;
+ var options = req.body.options || '';
+ if (source === undefined) {
+ return next(new Error("Bad request"));
+ }
+ options = _.chain(quote.parse(options)
+ .map(function (x) {
+ if (typeof(x) == "string") return x;
+ return x.pattern;
+ }))
+ .filter(_.identity)
+ .value();
+ var filters = req.body.filters;
+ compiler.compile(source, options, filters).then(
+ function (result) {
+ res.set('Content-Type', 'application/json');
+ res.end(JSON.stringify(result));
+ },
+ function (error) {
+ logger.error("Error: " + error);
+ if (typeof(error) !== "string") {
+ error = "Internal GCC explorer error: " + error.toString();
+ }
+ res.end(JSON.stringify({code: -1, stderr: [{text: error}]}));
+ }
+ );
+ }, this);
+}
+
+module.exports = {
+ CompileHandler: CompileHandler
+};
diff --git a/lib/compilers/6g.js b/lib/compilers/6g.js
new file mode 100644
index 000000000..168970926
--- /dev/null
+++ b/lib/compilers/6g.js
@@ -0,0 +1,60 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var Compile = require('../base-compiler');
+
+function compile6g(info, env) {
+ function convert6g(code) {
+ var re = /^[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/;
+ var prevLine = null;
+ var file = null;
+ return code.map(function (obj) {
+ var line = obj.line;
+ var match = line.match(re);
+ if (match) {
+ var res = "";
+ if (file === null) {
+ res += "\t.file 1 \"" + match[1] + "\"\n";
+ file = match[1];
+ }
+ if (prevLine != match[2]) {
+ res += "\t.loc 1 " + match[2] + "\n";
+ prevLine = match[2];
+ }
+ return res + "\t" + match[3].toLowerCase() + match[4];
+ } else
+ return null;
+ }).filter(_.identity).join("\n");
+ }
+
+ var compiler = new Compile(info, env);
+ compiler.postProcess = function () {
+ result.asm = this.convert6g(result.stdout);
+ result.stdout = [];
+ return Promise.resolve(result);
+ };
+ return compiler;
+}
+
+module.exports = compile6g; \ No newline at end of file
diff --git a/lib/compilers/CL.js b/lib/compilers/CL.js
new file mode 100644
index 000000000..693e6044d
--- /dev/null
+++ b/lib/compilers/CL.js
@@ -0,0 +1,58 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var Compile = require('../base-compiler');
+
+function compileCl(info, env) {
+ var compile = new Compile(info, env);
+ info.supportsFiltersInBinary = true;
+ if (process.platform == "linux") {
+ var wine = env.gccProps("wine");
+ var origExec = compile.exec;
+ compile.exec = function (command, args, options) {
+ if (command.toLowerCase().endsWith(".exe")) {
+ args.unshift(command);
+ command = wine;
+ }
+ return origExec(command, args, options);
+ };
+ compile.filename = function (fn) {
+ return 'Z:' + fn;
+ };
+ }
+ compile.supportsObjdump = function () {
+ return false;
+ };
+ compile.optionsForFilter = function (filters, outputFilename) {
+ return [
+ '/FAsc',
+ '/c',
+ '/Fa' + this.filename(outputFilename),
+ '/Fo' + this.filename(outputFilename + '.obj')
+ ];
+ };
+ return compile.initialise();
+}
+
+module.exports = compileCl; \ No newline at end of file
diff --git a/lib/compilers/default.js b/lib/compilers/default.js
new file mode 100644
index 000000000..5bc6facdc
--- /dev/null
+++ b/lib/compilers/default.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var Compile = require('../base-compiler');
+
+module.exports = function (info, env) {
+ var comp = new Compile(info, env);
+ return comp.initialise();
+}; \ No newline at end of file
diff --git a/lib/compilers/ldc.js b/lib/compilers/ldc.js
new file mode 100644
index 000000000..86d07bac9
--- /dev/null
+++ b/lib/compilers/ldc.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var Compile = require('../base-compiler');
+
+function compileLdc(info, env) {
+ var compiler = new Compile(info, env);
+ // TODO this needs testing!
+ compiler.optionsForFilter = function (filters, outputFilename) {
+ var options = ['-g', '-of', this.filename(outputFilename)];
+ if (filters.intel && !filters.binary) options.concat('-x86-asm-syntax=intel');
+ if (!filters.binary) options = options.concat('-output-s');
+ return options;
+ };
+}
+
+module.exports = compileLdc; \ No newline at end of file
diff --git a/lib/compilers/rust.js b/lib/compilers/rust.js
new file mode 100644
index 000000000..e4c4b0bea
--- /dev/null
+++ b/lib/compilers/rust.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012-2016, Matt Godbolt
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+var Compile = require('../base-compiler');
+
+function compileRust(info, env) {
+ var compiler = new Compile(info, env);
+ // TODO this needs testing!
+ compiler.optionsForFilter = function (filters, outputFilename) {
+ var options = ['-g', '-o', this.filename(outputFilename)];
+ // TODO: binary not supported(?)
+ if (!filters.binary) options = options.concat('--emit', 'asm');
+ options = options.concat(['--crate-type', 'staticlib']);
+ return options;
+ };
+}
+
+module.exports = compileRust; \ No newline at end of file
diff --git a/lib/diff.js b/lib/diff.js
index c456b1e17..cf73cbdf7 100644
--- a/lib/diff.js
+++ b/lib/diff.js
@@ -197,7 +197,7 @@ function buildDiffHandler(config) {
reject(e);
});
child.on('exit', function () {
- // See comment in compile.js - seems needed if the child has immediately exited
+ // See comment in compile-handler.js - seems needed if the child has immediately exited
setTimeout(function () {
resolve(stdout);
}, 0);