mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-11-30 19:44:33 -06:00
+25
-18
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user