aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorMichael Pratt <michael@prattmic.com>2018-12-13 00:38:59 -0800
committerDmitry Vyukov <dvyukov@google.com>2018-12-13 09:38:59 +0100
commitec0147d47fb25d0efdc677000312db1919ea0086 (patch)
tree07e3b776ca28a318a90cbe69498b6155c2fd07a0 /pkg
parentd5cf08b04e971ca055c7e799178b879bd8eeb56e (diff)
Merge pull request #874 from prattmic/bazel_version
pkg/build: fix bazel version parsing
Diffstat (limited to 'pkg')
-rw-r--r--pkg/build/build.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go
index 7ce21e9b0..3e9e73912 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -82,8 +82,11 @@ func CompilerIdentity(compiler string) (string, error) {
if compiler == "" {
return "", nil
}
+
+ bazel := strings.HasSuffix(compiler, "bazel")
+
arg := "--version"
- if strings.HasSuffix(compiler, "bazel") {
+ if bazel {
arg = ""
}
output, err := osutil.RunCmd(time.Minute, "", compiler, arg)
@@ -91,9 +94,19 @@ func CompilerIdentity(compiler string) (string, error) {
return "", err
}
for _, line := range strings.Split(string(output), "\n") {
- if strings.Contains(line, "Extracting Bazel") {
- continue
+ if bazel {
+ // Strip extracting and log lines...
+ if strings.Contains(line, "Extracting Bazel") {
+ continue
+ }
+ if strings.HasPrefix(line, "INFO: ") {
+ continue
+ }
+ if strings.HasPrefix(line, "WARNING: ") {
+ continue
+ }
}
+
return strings.TrimSpace(line), nil
}
return "", fmt.Errorf("no output from compiler --version")