summaryrefslogtreecommitdiff
path: root/android/bazel_handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/bazel_handler.go')
-rw-r--r--android/bazel_handler.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index d4f6e4c9e..4f17fecc6 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -18,11 +18,15 @@ import (
"bytes"
"errors"
"fmt"
+ "io/ioutil"
"os"
"os/exec"
+ "path/filepath"
"runtime"
"strings"
"sync"
+
+ "github.com/google/blueprint/bootstrap"
)
// Map key to describe bazel cquery requests.
@@ -237,3 +241,28 @@ func (context *bazelContext) InvokeBazel() error {
context.requests = map[cqueryKey]bool{}
return nil
}
+
+// Singleton used for registering BUILD file ninja dependencies (needed
+// for correctness of builds which use Bazel.
+func BazelSingleton() Singleton {
+ return &bazelSingleton{}
+}
+
+type bazelSingleton struct{}
+
+func (c *bazelSingleton) GenerateBuildActions(ctx SingletonContext) {
+ if ctx.Config().BazelContext.BazelEnabled() {
+ bazelBuildList := absolutePath(filepath.Join(
+ filepath.Dir(bootstrap.ModuleListFile), "bazel.list"))
+ ctx.AddNinjaFileDeps(bazelBuildList)
+
+ data, err := ioutil.ReadFile(bazelBuildList)
+ if err != nil {
+ ctx.Errorf(err.Error())
+ }
+ files := strings.Split(strings.TrimSpace(string(data)), "\n")
+ for _, file := range files {
+ ctx.AddNinjaFileDeps(file)
+ }
+ }
+}