Only stat compilers if absolute.

Fixes #487
This commit is contained in:
Matt Godbolt
2017-07-30 09:46:29 -05:00
parent 476fde3c4c
commit d350ec1c1a
+25 -18
View File
@@ -25,6 +25,7 @@
var child_process = require('child_process'),
temp = require('temp'),
fs = require('fs'),
path = require('path'),
httpProxy = require('http-proxy'),
Promise = require('promise'), // jshint ignore:line
quote = require('shell-quote'),
@@ -63,26 +64,32 @@ function CompileHandler(gccProps, compilerProps) {
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);
var compilerPath = './compilers/' + type;
logger.info("Loading compiler from", compilerPath);
this.factories[type] = require(compilerPath);
}
return this.stat(compiler.exe)
.then(_.bind(function (res) {
var cached = this.compilersById[compiler.id];
if (cached && cached.mtime.getTime() === res.mtime.getTime()) {
logger.debug(compiler.id + " is unchanged");
return cached;
}
return this.factories[type](compiler, this.compilerEnv).then(function (compiler) {
compiler.mtime = res.mtime;
return compiler;
if (path.isAbsolute(compiler.exe)) {
// Try stat'ing the compiler to cache its mtime and only re-run it if it
// has changed since the last time.
return this.stat(compiler.exe)
.then(_.bind(function (res) {
var cached = this.compilersById[compiler.id];
if (cached && cached.mtime.getTime() === res.mtime.getTime()) {
logger.debug(compiler.id + " is unchanged");
return cached;
}
return this.factories[type](compiler, this.compilerEnv).then(function (compiler) {
compiler.mtime = res.mtime;
return compiler;
});
}, this))
.catch(function (err) {
logger.warn("Unable to stat compiler binary", err);
return null;
});
}, this))
.catch(function(err) {
logger.warn("Unable to stat compiler binary", err);
return null;
});
} else {
return this.factories[type](compiler, this.compilerEnv);
}
};
this.setCompilers = function (compilers) {