Skip to content

Commit

Permalink
Merge pull request #1657 from microsoft/dev/andris/cmake_tools/gccVer…
Browse files Browse the repository at this point in the history
…Schema

Gcc/clang version analysis improvements
  • Loading branch information
andreeis authored Feb 11, 2021
2 parents de1a480 + 777a079 commit b9410f0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ async function getClangVersion(binPath: string): Promise<ClangVersion|null> {
return null;
}
const lines = exec.stderr.split('\n');
const version_re = /^(?:Apple LLVM|.*clang) version ([^\s-]+)(?:[\s-]|$)/;
const versionWord: string = localize("version.word", "version");
const version_re_str_loc: string = `^(?:Apple LLVM|.*clang) ${versionWord} ([^\\s-]+)(?:[\\s-]|$)`;
const version_re_str_en: string = `^(?:Apple LLVM|.*clang) version ([^\\s-]+)(?:[\\s-]|$)`;
const version_re_loc = RegExp(version_re_str_loc, "mgi");
const version_re_en = RegExp(version_re_str_en, "mgi");
let version: string = "";
let fullVersion: string = "";
for (const line of lines) {
const version_match = version_re.exec(line);
const version_match = version_re_en.exec(line) || version_re_loc.exec(line);
if (version_match !== null) {
version = version_match[1];
fullVersion = line;
Expand Down Expand Up @@ -194,12 +198,16 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
}

const compiler_version_output = exec.stderr.trim().split('\n');
const version_re = /^gcc version (.*?) .*/;
const versionWord: string = localize("version.word", "version");
const version_re_str_loc: string = `^gcc(-| )${versionWord} (.*?) .*`;
const version_re_str_en: string = `^gcc(-| )version (.*?) .*`;
const version_re_loc = RegExp(version_re_str_loc, "mgi");
const version_re_en = RegExp(version_re_str_en, "mgi");
let version: string = "";
for (const line of compiler_version_output) {
const version_match = version_re.exec(line);
const version_match = version_re_en.exec(line) || version_re_loc.exec(line);
if (version_match !== null) {
version = version_match[1];
version = version_match[2];
break;
}
}
Expand Down

0 comments on commit b9410f0

Please sign in to comment.