diff options
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/filesystem.go | 44 | ||||
-rw-r--r-- | filesystem/filesystem_test.go | 23 | ||||
-rw-r--r-- | filesystem/system_image.go | 2 |
3 files changed, 68 insertions, 1 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index cadf9c246..b342ae930 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -127,6 +127,10 @@ type filesystemProperties struct { // the make version. Include_make_built_files string + // When set, builds etc/event-log-tags file by merging logtags from all dependencies. + // Default is false + Build_logtags *bool + Fsverity fsverityProperties } @@ -137,6 +141,7 @@ type filesystemProperties struct { // partitions like system.img. For example, cc_library modules are placed under ./lib[64] directory. func filesystemFactory() android.Module { module := &filesystem{} + module.filterPackagingSpec = module.filterInstallablePackagingSpec initFilesystemModule(module) return module } @@ -189,6 +194,12 @@ func (f *filesystem) partitionName() string { return proptools.StringDefault(f.properties.Partition_name, f.Name()) } +func (f *filesystem) filterInstallablePackagingSpec(ps android.PackagingSpec) bool { + // Filesystem module respects the installation semantic. A PackagingSpec from a module with + // IsSkipInstall() is skipped. + return !ps.SkipInstall() +} + var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -288,6 +299,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi f.buildNonDepsFiles(ctx, builder, rootDir) f.addMakeBuiltFiles(ctx, builder, rootDir) f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir) + f.buildEventLogtagsFile(ctx, builder, rebasedDir) // run host_init_verifier // Ideally we should have a concept of pluggable linters that verify the generated image. @@ -428,6 +440,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) f.buildNonDepsFiles(ctx, builder, rootDir) f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir) + f.buildEventLogtagsFile(ctx, builder, rebasedDir) output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath cmd := builder.Command(). @@ -485,6 +498,37 @@ func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *andro Text(android.PathForArbitraryOutput(ctx, stagingDir).String()) } +func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) { + if !proptools.Bool(f.properties.Build_logtags) { + 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()). + FlagWithInput("-m ", android.MergedLogtagsPath(ctx)) + + for _, path := range android.SortedKeys(logtagsFilePaths) { + cmd.Text(path) + } +} + type partition interface { PartitionType() string } diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index 121504867..acd481352 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -442,3 +442,26 @@ func TestInconsistentPartitionTypesInDefaults(t *testing.T) { } `) } + +func TestPreventDuplicatedEntries(t *testing.T) { + fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( + "packaging conflict at")). + RunTestWithBp(t, ` + android_filesystem { + name: "fs", + deps: [ + "foo", + "foo_dup", + ], + } + + cc_binary { + name: "foo", + } + + cc_binary { + name: "foo_dup", + stem: "foo", + } + `) +} diff --git a/filesystem/system_image.go b/filesystem/system_image.go index 5028a493e..15cacfb4f 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -98,5 +98,5 @@ func (s *systemImage) buildLinkerConfigFile(ctx android.ModuleContext, root andr // Note that "apex" module installs its contents to "apex"(fake partition) as well // for symbol lookup by imitating "activated" paths. func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool { - return ps.Partition() == "system" + return s.filesystem.filterInstallablePackagingSpec(ps) && ps.Partition() == "system" } |