aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/argument-parsers.js
diff options
context:
space:
mode:
authorPartouf <partouf@gmail.com>2019-08-08 17:19:20 +0200
committerPartouf <partouf@gmail.com>2019-08-08 17:19:20 +0200
commitfb286bd306e594c61e701ca9e6a522cc4680e470 (patch)
treea063541cf2fda94447645de0314b84d03774c684 /lib/compilers/argument-parsers.js
parent3999d4ead3cbb869230605c5a32a062fb86c5b13 (diff)
downloadcompiler-explorer-fb286bd306e594c61e701ca9e6a522cc4680e470.tar.gz
compiler-explorer-fb286bd306e594c61e701ca9e6a522cc4680e470.zip
add custom argument parser for rust
Diffstat (limited to 'lib/compilers/argument-parsers.js')
-rw-r--r--lib/compilers/argument-parsers.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/compilers/argument-parsers.js b/lib/compilers/argument-parsers.js
index 19717dd2d..93de5f6a9 100644
--- a/lib/compilers/argument-parsers.js
+++ b/lib/compilers/argument-parsers.js
@@ -251,6 +251,36 @@ class VCParser extends BaseParser {
}
}
+class RustParser extends BaseParser {
+ static parse(compiler) {
+ return Promise.all([
+ RustParser.getOptions(compiler, "--help"),
+ RustParser.getOptions(compiler, "-C help")
+ ]).then(() => {
+ return compiler;
+ });
+ }
+
+ static getOptions(compiler, helpArg) {
+ return compiler.execCompilerCached(compiler.compiler.exe, [helpArg]).then(result => {
+ let options = {};
+ if (result.code === 0) {
+ if (helpArg === "-C help") {
+ const optionFinder = /^\s*(-C\s*[a-z0-9=-]*)\s--\s(.*)/i;
+
+ options = BaseParser.parseLines(result.stdout + result.stderr, optionFinder);
+ } else if (helpArg === "--help") {
+ const optionFinder = /^\s*(--?[a-z0-9=+,[\]<>|-]*)\s*(.*)/i;
+
+ options = BaseParser.parseLines(result.stdout + result.stderr, optionFinder);
+ }
+ }
+ compiler.possibleArguments.populateOptions(options);
+ return options;
+ });
+ }
+}
+
module.exports = {
Base: BaseParser,
Clang: ClangParser,
@@ -258,5 +288,6 @@ module.exports = {
Java: JavaParser,
VC: VCParser,
Pascal: PascalParser,
- ISPC: ISPCParser
+ ISPC: ISPCParser,
+ Rust: RustParser
};