From 902fd17a99d5d3d5249004ea093be88c82c39bf3 Mon Sep 17 00:00:00 2001 From: Usta Shrestha Date: Wed, 2 Mar 2022 15:27:49 -0500 Subject: [PATCH] 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 --- android/bazel_handler.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 804a5fbbd..3d6babc51 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -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)