From ccf37005ecb23fcd1709aaf2f3a0381b3ca3ca26 Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Fri, 4 Aug 2023 01:46:32 +0900 Subject: [PATCH] Reland "Make glob output include product name" glob pattern could vary, depending on device configuration, but it uses the same glob output path for now. It makes unnecessary soong reevaluation due to the previous result is always overwritten whenever the target is changed. So make it product specific to avoid this. And also let bootstrap.ninja use 'new' ninja file for globbing Bug: 294378814 Bug: 294058160 Test: lunch a && m nothing && lunch b && m nothing && lunch a && m nothing and then check if there is no glob work. (a and b has different glob pattern due to RRO configuration or something) Test: check if bootstreap.ninja include 'new' ninja file for globbing Test: declare `cc_library { ... srcs: ["*.c"] }` && \ touch a.c && m nothing && touch b.c && m nothing && \ rm b.c && m nothing && mv a.c c.c && m nothing and then check if m includes 'regenerate glob..' log. Change-Id: I9337ae3b33cc2c0689f9731bbae5caae67612e3e --- ui/build/soong.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ui/build/soong.go b/ui/build/soong.go index a4cf7fbf0..b8543d929 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -161,6 +161,14 @@ type PrimaryBuilderFactory struct { debugPort string } +func getGlobPathName(config Config) string { + globPathName, ok := config.TargetProductOrErr() + if ok != nil { + globPathName = soongBuildTag + } + return globPathName +} + func (pb PrimaryBuilderFactory) primaryBuilderInvocation() bootstrap.PrimaryBuilderInvocation { commonArgs := make([]string, 0, 0) @@ -195,9 +203,14 @@ func (pb PrimaryBuilderFactory) primaryBuilderInvocation() bootstrap.PrimaryBuil var allArgs []string allArgs = append(allArgs, pb.specificArgs...) + globPathName := pb.name + // Glob path for soong build would be separated per product target + if pb.name == soongBuildTag { + globPathName = getGlobPathName(pb.config) + } allArgs = append(allArgs, - "--globListDir", pb.name, - "--globFile", pb.config.NamedGlobFile(pb.name)) + "--globListDir", globPathName, + "--globFile", pb.config.NamedGlobFile(globPathName)) allArgs = append(allArgs, commonArgs...) allArgs = append(allArgs, environmentArgs(pb.config, pb.name)...) @@ -247,7 +260,7 @@ func bootstrapEpochCleanup(ctx Context, config Config) { func bootstrapGlobFileList(config Config) []string { return []string{ - config.NamedGlobFile(soongBuildTag), + config.NamedGlobFile(getGlobPathName(config)), config.NamedGlobFile(bp2buildFilesTag), config.NamedGlobFile(jsonModuleGraphTag), config.NamedGlobFile(queryviewTag),