Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 394aa32e authored by Spandan Das's avatar Spandan Das
Browse files

Special-case Soong finder to look in out/api_surfaces

Add a new argument in soong_ui that will be used to gate this behavior.

This approach is expected to solve incrementality issues in multi-tree.
As part of soong's bootstrap process, all source dirs are added to deps
of out/soong/build.ninja (via globs). Since multitree_build writes to the
"source" api_surfaces directory, it changes its mtime and causes a
recompilation of out/soong/build.ninja in the subsequent invocation.

Test: TH (for single-tree)
Test: Inspected ninja files (for multi-tree)
(Run a full build)
touch out/api_surfaces/vendorapi/libc/.../math.h
orchestrator/prebuilts/build-tools/linux-x86/bin/nsjail --config
out/trees/vendor_aosp_cf_arm64_phone/nsjail.cfg --
prebuilts/build-tools/linux-x86/bin/ninja -f out/soong/bootstrap.ninja
-d explain -n out/soong/build.ninja
(ninja: no work to do)

Change-Id: Ib823163ec1153344a2f593daa8d7156c24ff5bc3
parent 2d997046
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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"),
+7 −0
Original line number Diff line number Diff line
@@ -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":
+10 −1
Original line number Diff line number Diff line
@@ -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{}