find bazel-related files and add them to bazel.list and ninja deps
This retriggers soong_build whenever a new bzl, WORKSPACE, or BUILD.bazel file is changed or added. Test: Manually verified on bionic/libc genrules with manual changes to related BUILD/bzl/WORKSPACE files -- these all retrigger builds. Test: Updated finder_test.go Change-Id: I634384f88781a6b6db32f5d6bf9c07e179e14c39
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user