ensure out/bazel_metrics exists before writing to cquery-buildroot_bazel_profile.gz

Bug: 222133546
Test: `rm -rf out` then `USE_BAZEL_ANALYSIS m libnativehelper` and ensure 'out/bazel_metrics' exists
Change-Id: I6803aba830e1c40f3618bfc41109728d721fd2af
This commit is contained in:
Usta Shrestha 2022-03-02 15:27:49 -05:00
parent 6bd0d4e864
commit 902fd17a99

View file

@ -664,7 +664,12 @@ func (context *bazelContext) InvokeBazel() error {
if err != nil {
return err
}
if metricsDir := context.paths.BazelMetricsDir(); metricsDir != "" {
err = os.MkdirAll(metricsDir, 0777)
if err != nil {
return err
}
}
err = ioutil.WriteFile(filepath.Join(soongInjectionPath, "WORKSPACE.bazel"), []byte{}, 0666)
if err != nil {
return err
@ -716,9 +721,9 @@ func (context *bazelContext) InvokeBazel() error {
}
}
for val, _ := range context.requests {
for val := range context.requests {
if cqueryResult, ok := cqueryResults[getCqueryId(val)]; ok {
context.results[val] = string(cqueryResult)
context.results[val] = cqueryResult
} else {
return fmt.Errorf("missing result for bazel target %s. query output: [%s], cquery err: [%s]",
getCqueryId(val), cqueryOutput, cqueryErr)