summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/soong_build/main.go5
-rw-r--r--ui/build/config.go7
-rw-r--r--ui/build/finder.go11
3 files changed, 22 insertions, 1 deletions
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 0669f65db..7d4930dca 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -256,6 +256,11 @@ func runApiBp2build(configuration android.Config, extraNinjaDeps []string) strin
// Exclude all src BUILD files
excludes = append(excludes, apiBuildFileExcludes()...)
+ // Android.bp files for api surfaces are mounted to out/, but out/ should not be a
+ // dep for api_bp2build.
+ // Otherwise api_bp2build will be run every single time
+ excludes = append(excludes, configuration.OutDir())
+
// Create the symlink forest
symlinkDeps := bp2build.PlantSymlinkForest(
configuration.IsEnvTrue("BP2BUILD_VERBOSE"),
diff --git a/ui/build/config.go b/ui/build/config.go
index 36119f0f1..dff7c4ff8 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -82,6 +82,7 @@ type configImpl struct {
skipSoong bool
skipNinja bool
skipSoongTests bool
+ searchApiDir bool // Scan the Android.bp files generated in out/api_surfaces
// From the product config
katiArgs []string
@@ -725,6 +726,8 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
c.bazelDevMode = true
} else if arg == "--bazel-mode-staging" {
c.bazelStagingMode = true
+ } else if arg == "--search-api-dir" {
+ c.searchApiDir = true
} else if len(arg) > 0 && arg[0] == '-' {
parseArgNum := func(def int) int {
if len(arg) > 2 {
@@ -884,6 +887,10 @@ func (c *configImpl) SoongOutDir() string {
return filepath.Join(c.OutDir(), "soong")
}
+func (c *configImpl) ApiSurfacesOutDir() string {
+ return filepath.Join(c.OutDir(), "api_surfaces")
+}
+
func (c *configImpl) PrebuiltOS() string {
switch runtime.GOOS {
case "linux":
diff --git a/ui/build/finder.go b/ui/build/finder.go
index 4d6ad426f..3f628cf7b 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -63,7 +63,7 @@ func NewSourceFinder(ctx Context, config Config) (f *finder.Finder) {
// Set up configuration parameters for the Finder cache.
cacheParams := finder.CacheParams{
WorkingDirectory: dir,
- RootDirs: []string{"."},
+ RootDirs: androidBpSearchDirs(config),
FollowSymlinks: config.environ.IsEnvTrue("ALLOW_BP_UNDER_SYMLINKS"),
ExcludeDirs: []string{".git", ".repo"},
PruneFiles: pruneFiles,
@@ -100,6 +100,15 @@ func NewSourceFinder(ctx Context, config Config) (f *finder.Finder) {
return f
}
+func androidBpSearchDirs(config Config) []string {
+ dirs := []string{"."} // always search from root of source tree.
+ if config.searchApiDir {
+ // Search in out/api_surfaces
+ dirs = append(dirs, config.ApiSurfacesOutDir())
+ }
+ return dirs
+}
+
// Finds the list of Bazel-related files (BUILD, WORKSPACE and Starlark) in the tree.
func findBazelFiles(entries finder.DirEntries) (dirNames []string, fileNames []string) {
matches := []string{}