Make soong's event-log-tags file match make
Make included all event-log-tags in the source tree, wether or not
they were installed on the device. Soong was only including files from
the deps of the system image.
In the long run, we'll want a per-partition event-log-tags file
for incremental soong and an independant treble system image. But
this works for now.
Bug: 382515940
Test: diff out/target/product/vsoc_x86_64/system/etc/event-log-tags out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_system_image/android_common/root/system/etc/event-log-tags
Change-Id: Id631c4292dda9531df3e460ef736fd9b15f6b566
diff --git a/android/logtags.go b/android/logtags.go
index 1e92dad..abc37f9 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -14,10 +14,56 @@
package android
-import "github.com/google/blueprint"
+import (
+ "strings"
+
+ "github.com/google/blueprint"
+)
+
+func init() {
+ RegisterParallelSingletonType("logtags", LogtagsSingleton)
+}
type LogtagsInfo struct {
Logtags Paths
}
var LogtagsProviderKey = blueprint.NewProvider[*LogtagsInfo]()
+
+func LogtagsSingleton() Singleton {
+ return &logtagsSingleton{}
+}
+
+type logtagsSingleton struct{}
+
+func MergedLogtagsPath(ctx PathContext) OutputPath {
+ return PathForIntermediates(ctx, "all-event-log-tags.txt")
+}
+
+func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) {
+ var allLogtags Paths
+ ctx.VisitAllModules(func(module Module) {
+ if !module.ExportedToMake() {
+ return
+ }
+ if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok {
+ allLogtags = append(allLogtags, logtagsInfo.Logtags...)
+ }
+ })
+ allLogtags = SortedUniquePaths(allLogtags)
+ filteredLogTags := make([]Path, 0, len(allLogtags))
+ for _, p := range allLogtags {
+ // Logic copied from make:
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=987;drc=0585bb1bcf4c89065adaf709f48acc8b869fd3ce
+ if !strings.HasPrefix(p.String(), "vendor/") && !strings.HasPrefix(p.String(), "device/") && !strings.HasPrefix(p.String(), "out/") {
+ filteredLogTags = append(filteredLogTags, p)
+ }
+ }
+
+ builder := NewRuleBuilder(pctx, ctx)
+ builder.Command().
+ BuiltTool("merge-event-log-tags").
+ FlagWithOutput("-o ", MergedLogtagsPath(ctx)).
+ Inputs(filteredLogTags)
+ builder.Build("all-event-log-tags.txt", "merge logtags")
+}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 1d32b8f..6d673e3 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -868,29 +868,10 @@
return
}
- logtagsFilePaths := make(map[string]bool)
- ctx.WalkDeps(func(child, parent android.Module) bool {
- if logtagsInfo, ok := android.OtherModuleProvider(ctx, child, android.LogtagsProviderKey); ok {
- for _, path := range logtagsInfo.Logtags {
- logtagsFilePaths[path.String()] = true
- }
- }
- return true
- })
-
- if len(logtagsFilePaths) == 0 {
- return
- }
-
etcPath := rebasedDir.Join(ctx, "etc")
eventLogtagsPath := etcPath.Join(ctx, "event-log-tags")
builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String())
- cmd := builder.Command().BuiltTool("merge-event-log-tags").
- FlagWithArg("-o ", eventLogtagsPath.String())
-
- for _, path := range android.SortedKeys(logtagsFilePaths) {
- cmd.Text(path)
- }
+ builder.Command().Text("cp").Input(android.MergedLogtagsPath(ctx)).Text(eventLogtagsPath.String())
f.appendToEntry(ctx, eventLogtagsPath)
}