|
|
|
@ -33,7 +33,16 @@ var nopt = require('nopt'),
|
|
|
|
|
path = require('path'), |
|
|
|
|
fs = require('fs-extra'), |
|
|
|
|
http = require('http'), |
|
|
|
|
Promise = require('promise'); |
|
|
|
|
Promise = require('promise'), |
|
|
|
|
memwatch = require('memwatch'); |
|
|
|
|
|
|
|
|
|
memwatch.on('leak', function (info) { |
|
|
|
|
console.log("Memwatch leak: " + JSON.stringify(info)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
memwatch.on('stats', function (stats) { |
|
|
|
|
console.log("Memwatch stats: " + JSON.stringify(stats)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var opts = nopt({ |
|
|
|
|
'env': [String], |
|
|
|
@ -186,29 +195,29 @@ function configuredCompilers() {
|
|
|
|
|
var port = parseInt(bits[1]); |
|
|
|
|
console.log("Fetching compilers from remote source " + host + ":" + port); |
|
|
|
|
return retryPromise(function () { |
|
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
|
http.get({ |
|
|
|
|
hostname: host, |
|
|
|
|
port: port, |
|
|
|
|
path: "/api/compilers" |
|
|
|
|
}, function (res) { |
|
|
|
|
var str = ''; |
|
|
|
|
res.on('data', function (chunk) { |
|
|
|
|
str += chunk; |
|
|
|
|
}); |
|
|
|
|
res.on('end', function () { |
|
|
|
|
var compilers = JSON.parse(str).map(function (compiler) { |
|
|
|
|
compiler.exe = null; |
|
|
|
|
compiler.remote = "http://" + host + ":" + port; |
|
|
|
|
return compiler; |
|
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
|
http.get({ |
|
|
|
|
hostname: host, |
|
|
|
|
port: port, |
|
|
|
|
path: "/api/compilers" |
|
|
|
|
}, function (res) { |
|
|
|
|
var str = ''; |
|
|
|
|
res.on('data', function (chunk) { |
|
|
|
|
str += chunk; |
|
|
|
|
}); |
|
|
|
|
res.on('end', function () { |
|
|
|
|
var compilers = JSON.parse(str).map(function (compiler) { |
|
|
|
|
compiler.exe = null; |
|
|
|
|
compiler.remote = "http://" + host + ":" + port; |
|
|
|
|
return compiler; |
|
|
|
|
}); |
|
|
|
|
resolve(compilers); |
|
|
|
|
}); |
|
|
|
|
resolve(compilers); |
|
|
|
|
}).on('error', function (e) { |
|
|
|
|
reject(e); |
|
|
|
|
}); |
|
|
|
|
}).on('error', function (e) { |
|
|
|
|
reject(e); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
host + ":" + port, |
|
|
|
|
props.get('gcc-explorer', 'proxyRetries', 20), |
|
|
|
|
props.get('gcc-explorer', 'proxyRetryMs', 500)); |
|
|
|
@ -254,7 +263,7 @@ function getCompilerInfo(compilerInfo) {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (options['-masm']) { |
|
|
|
|
compilerInfo.intelAsm="-masm=intel"; |
|
|
|
|
compilerInfo.intelAsm = "-masm=intel"; |
|
|
|
|
} |
|
|
|
|
resolve(compilerInfo); |
|
|
|
|
}); |
|
|
|
@ -286,7 +295,7 @@ function findCompilers() {
|
|
|
|
|
function apiHandler(compilers) { |
|
|
|
|
var reply = JSON.stringify(compilers); |
|
|
|
|
return function apiHandler(req, res, next) { |
|
|
|
|
var bits = req.url.split("/"); |
|
|
|
|
var bits = req.url.split("/eafe0fa644b616c7d265623b17ad69042f79b3e5"); |
|
|
|
|
if (bits.length !== 2 || req.method !== "GET") return next(); |
|
|
|
|
switch (bits[1]) { |
|
|
|
|
default: |
|
|
|
|