Add re_analysis environment varibles fields to soong_metrics
Test: Tested by following steps
1.m nothing: field is empty
2.USE_RBE=false m nothing: field log cc_wrapper and rbe_wrapper
3.USE_RBE=false m nothing: field is empty
Bug: 281922291
Change-Id: I1bbb324752b9a2dea1ff2c9df5817559d4cec3a6
diff --git a/shared/env.go b/shared/env.go
index b7d3baf..75190cc 100644
--- a/shared/env.go
+++ b/shared/env.go
@@ -55,20 +55,23 @@
return data, nil
}
-// Reads and deserializes a Soong environment file located at the given file path to determine its
-// staleness. If any environment variable values have changed, it prints them out and returns true.
+// Reads and deserializes a Soong environment file located at the given file
+// path to determine its staleness. If any environment variable values have
+// changed, it prints and returns changed environment variable values and
+// returns true.
// Failing to read or parse the file also causes it to return true.
-func StaleEnvFile(filepath string, getenv func(string) string) (bool, error) {
+func StaleEnvFile(filepath string, getenv func(string) string) (isStale bool,
+ changedEnvironmentVariable []string, err error) {
data, err := ioutil.ReadFile(filepath)
if err != nil {
- return true, err
+ return true, nil, err
}
var contents envFileData
err = json.Unmarshal(data, &contents)
if err != nil {
- return true, err
+ return true, nil, err
}
var changed []string
@@ -78,6 +81,7 @@
cur := getenv(key)
if old != cur {
changed = append(changed, fmt.Sprintf("%s (%q -> %q)", key, old, cur))
+ changedEnvironmentVariable = append(changedEnvironmentVariable, key)
}
}
@@ -86,10 +90,10 @@
for _, s := range changed {
fmt.Printf(" %s\n", s)
}
- return true, nil
+ return true, changedEnvironmentVariable, nil
}
- return false, nil
+ return false, nil, nil
}
// Deserializes and environment serialized by EnvFileContents() and returns it