diff options
author | Matt Godbolt <matt@godbolt.org> | 2017-07-12 15:12:49 -0500 |
---|---|---|
committer | Matt Godbolt <matt@godbolt.org> | 2017-07-12 15:12:49 -0500 |
commit | 3c80c6eff0a66604c0dc8529aa99a744f9edfba2 (patch) | |
tree | 747268b5c4e84735d896c14953635fe3e09acb5f /lib/compilers/argument-parsers.js | |
parent | df22d86a02f15e09d7349ce1e99a1ad5365d7896 (diff) | |
download | compiler-explorer-3c80c6eff0a66604c0dc8529aa99a744f9edfba2.tar.gz compiler-explorer-3c80c6eff0a66604c0dc8529aa99a744f9edfba2.zip |
Fix some minor issues with compiler type determination.
Remove 'compiler.type' in favour of the comiler itself being
given an option to say what type it is. Default for that does
the same guess that the old code did (plus some bug fixes).
Fixed up (I hope!) some of the parsing of the output. I should write
some tests really.
CC @jaredw for further comment
Diffstat (limited to 'lib/compilers/argument-parsers.js')
-rw-r--r-- | lib/compilers/argument-parsers.js | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/compilers/argument-parsers.js b/lib/compilers/argument-parsers.js index 3be006e5e..241ba2bb2 100644 --- a/lib/compilers/argument-parsers.js +++ b/lib/compilers/argument-parsers.js @@ -22,31 +22,32 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -const _ = require('underscore-node'), - logger = require('../logger').logger, - utils = require('../utils'); +const _ = require('underscore-node'), + logger = require('../logger').logger, + utils = require('../utils'); -const getOptions = function(compiler, helpArg) { +const getOptions = function (compiler, helpArg) { + "use strict"; return compiler.exec(compiler.compiler.exe, [helpArg]) - .then(_.bind(function (result) { - var options = {}; - if (result.code === 0) { - var splitness = /--?[-a-zA-Z]+( ?[-a-zA-Z]+)/; - - utils.eachLine(result.stdout + result.stderr, function (line) { - var match = line.match(splitness); - if (!match) return; - options[match[0]] = true; - }); - } - compiler.compiler.supportedOptions = options; - logger.debug("compiler options: ", compiler.compiler.supportedOptions); - return compiler; + .then(_.bind(function (result) { + let options = {}; + if (result.code === 0) { + let optionFinder = /^\s+(--?[-a-zA-Z]+)/; + + utils.eachLine(result.stdout + result.stderr, function (line) { + var match = line.match(optionFinder); + if (!match) return; + options[match[1]] = true; + }); + } + compiler.compiler.supportedOptions = options; + logger.debug("compiler options: ", compiler.compiler.supportedOptions); + return compiler; })); }; -const gccparser = function(compiler) { - return getOptions(compiler, "--target-help").then(function(compiler) { +const gccparser = function (compiler) { + return getOptions(compiler, "--target-help").then(function (compiler) { if (compiler.compiler.supportedOptions['-masm']) { compiler.compiler.intelAsm = "-masm=intel"; compiler.compiler.supportsIntel = true; @@ -55,8 +56,8 @@ const gccparser = function(compiler) { }); }; -const clangparser = function(compiler) { - return getOptions(compiler, "--help").then(function(compiler) { +const clangparser = function (compiler) { + return getOptions(compiler, "--help").then(function (compiler) { if (compiler.compiler.supportedOptions['-fsave-optimization-record']) { compiler.compiler.optArg = "-fsave-optimization-record"; compiler.compiler.supportsOptOutput = true; @@ -67,6 +68,6 @@ const clangparser = function(compiler) { module.exports = { - "clang": clangparser, - "gcc": gccparser + clang: clangparser, + gcc: gccparser };
\ No newline at end of file |