diff options
-rw-r--r-- | android/module.go | 79 | ||||
-rw-r--r-- | android/module_context.go | 13 | ||||
-rw-r--r-- | android/prebuilt_test.go | 3 | ||||
-rw-r--r-- | android/test_suites_test.go | 3 | ||||
-rw-r--r-- | filesystem/avb_add_hash_footer.go | 3 |
5 files changed, 51 insertions, 50 deletions
diff --git a/android/module.go b/android/module.go index 405573c1b..7786f13ee 100644 --- a/android/module.go +++ b/android/module.go @@ -1654,38 +1654,10 @@ func (m *ModuleBase) generateVariantTarget(ctx *moduleContext) { } +// generateModuleTarget generates phony targets so that you can do `m <module-name>`. +// It will be run on every variant of the module, so it relies on the fact that phony targets +// are deduped to merge all the deps from different variants together. func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { - var allInstalledFiles InstallPaths - var allCheckbuildTargets Paths - var alloutputFiles Paths - ctx.VisitAllModuleVariantProxies(func(module ModuleProxy) { - var checkbuildTarget Path - var uncheckedModule bool - var skipAndroidMkProcessing bool - if EqualModules(m.module, module) { - allInstalledFiles = append(allInstalledFiles, ctx.installFiles...) - checkbuildTarget = ctx.checkbuildTarget - uncheckedModule = ctx.uncheckedModule - skipAndroidMkProcessing = shouldSkipAndroidMkProcessing(ctx, m) - } else { - info := OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider) - allInstalledFiles = append(allInstalledFiles, info.InstallFiles...) - checkbuildTarget = info.CheckbuildTarget - uncheckedModule = info.UncheckedModule - skipAndroidMkProcessing = OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoKey).SkipAndroidMkProcessing - } - if outputFiles, err := outputFilesForModule(ctx, module, ""); err == nil { - alloutputFiles = append(alloutputFiles, outputFiles...) - } - // A module's -checkbuild phony targets should - // not be created if the module is not exported to make. - // Those could depend on the build target and fail to compile - // for the current build target. - if (!ctx.Config().KatiEnabled() || !skipAndroidMkProcessing) && !uncheckedModule && checkbuildTarget != nil { - allCheckbuildTargets = append(allCheckbuildTargets, checkbuildTarget) - } - }) - var namespacePrefix string nameSpace := ctx.Namespace().Path if nameSpace != "." { @@ -1693,24 +1665,28 @@ func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { } var deps Paths - var info FinalModuleBuildTargetsInfo + var info ModuleBuildTargetsInfo - if len(allInstalledFiles) > 0 { + if len(ctx.installFiles) > 0 { name := namespacePrefix + ctx.ModuleName() + "-install" - ctx.Phony(name, allInstalledFiles.Paths()...) + ctx.Phony(name, ctx.installFiles.Paths()...) info.InstallTarget = PathForPhony(ctx, name) deps = append(deps, info.InstallTarget) } - if len(allCheckbuildTargets) > 0 { + // A module's -checkbuild phony targets should + // not be created if the module is not exported to make. + // Those could depend on the build target and fail to compile + // for the current build target. + if (!ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, m)) && !ctx.uncheckedModule && ctx.checkbuildTarget != nil { name := namespacePrefix + ctx.ModuleName() + "-checkbuild" - ctx.Phony(name, allCheckbuildTargets...) + ctx.Phony(name, ctx.checkbuildTarget) deps = append(deps, PathForPhony(ctx, name)) } - if len(alloutputFiles) > 0 { + if outputFiles, err := outputFilesForModule(ctx, ctx.Module(), ""); err == nil && len(outputFiles) > 0 { name := namespacePrefix + ctx.ModuleName() + "-outputs" - ctx.Phony(name, alloutputFiles...) + ctx.Phony(name, outputFiles...) deps = append(deps, PathForPhony(ctx, name)) } @@ -1734,7 +1710,7 @@ func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { } info.BlueprintDir = ctx.ModuleDir() - SetProvider(ctx, FinalModuleBuildTargetsProvider, info) + SetProvider(ctx, ModuleBuildTargetsProvider, info) } } @@ -1876,15 +1852,15 @@ type SourceFilesInfo struct { var SourceFilesInfoProvider = blueprint.NewProvider[SourceFilesInfo]() -// FinalModuleBuildTargetsInfo is used by buildTargetSingleton to create checkbuild and -// per-directory build targets. Only set on the final variant of each module -type FinalModuleBuildTargetsInfo struct { +// ModuleBuildTargetsInfo is used by buildTargetSingleton to create checkbuild and +// per-directory build targets. +type ModuleBuildTargetsInfo struct { InstallTarget WritablePath CheckbuildTarget WritablePath BlueprintDir string } -var FinalModuleBuildTargetsProvider = blueprint.NewProvider[FinalModuleBuildTargetsInfo]() +var ModuleBuildTargetsProvider = blueprint.NewProvider[ModuleBuildTargetsInfo]() type CommonModuleInfo struct { Enabled bool @@ -2151,14 +2127,19 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) } if sourceFileProducer, ok := m.module.(SourceFileProducer); ok { + srcs := sourceFileProducer.Srcs() + for _, src := range srcs { + if src == nil { + ctx.ModuleErrorf("SourceFileProducer cannot return nil srcs") + return + } + } SetProvider(ctx, SourceFilesInfoProvider, SourceFilesInfo{Srcs: sourceFileProducer.Srcs()}) } - if ctx.IsFinalModule(m.module) { - m.generateModuleTarget(ctx) - if ctx.Failed() { - return - } + m.generateModuleTarget(ctx) + if ctx.Failed() { + return } ctx.TransitiveInstallFiles = depset.New[InstallPath](depset.TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles) @@ -3098,7 +3079,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) { modulesInDir := make(map[string]Paths) ctx.VisitAllModuleProxies(func(module ModuleProxy) { - info := OtherModuleProviderOrDefault(ctx, module, FinalModuleBuildTargetsProvider) + info := OtherModuleProviderOrDefault(ctx, module, ModuleBuildTargetsProvider) if info.CheckbuildTarget != nil { checkbuildDeps = append(checkbuildDeps, info.CheckbuildTarget) diff --git a/android/module_context.go b/android/module_context.go index fb62e6749..0a23a745f 100644 --- a/android/module_context.go +++ b/android/module_context.go @@ -456,6 +456,11 @@ func (m *moduleContext) Build(pctx PackageContext, params BuildParams) { } func (m *moduleContext) Phony(name string, deps ...Path) { + for _, dep := range deps { + if dep == nil { + panic("Phony dep cannot be nil") + } + } m.phonies[name] = append(m.phonies[name], deps...) } @@ -748,6 +753,9 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat m.packageFile(fullInstallPath, srcPath, executable, m.requiresFullInstall()) if checkbuild { + if srcPath == nil { + panic("srcPath cannot be nil") + } m.checkbuildFiles = append(m.checkbuildFiles, srcPath) } @@ -879,6 +887,11 @@ func (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath // CheckbuildFile specifies the output files that should be built by checkbuild. func (m *moduleContext) CheckbuildFile(srcPaths ...Path) { + for _, srcPath := range srcPaths { + if srcPath == nil { + panic("CheckbuildFile() files cannot be nil") + } + } m.checkbuildFiles = append(m.checkbuildFiles, srcPaths...) } diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index 27a68fbe5..d31fc4fcd 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -551,6 +551,9 @@ func (s *sourceModule) GenerateAndroidBuildActions(ctx ModuleContext) { } func (s *sourceModule) Srcs() Paths { + if s.src == nil { + return nil + } return Paths{s.src} } diff --git a/android/test_suites_test.go b/android/test_suites_test.go index dda93297a..03aa42413 100644 --- a/android/test_suites_test.go +++ b/android/test_suites_test.go @@ -108,7 +108,8 @@ var prepareForFakeTestSuite = GroupFixturePreparers( func (f *fake_module) GenerateAndroidBuildActions(ctx ModuleContext) { for _, output := range f.props.Outputs { - ctx.InstallFile(pathForTestCases(ctx), output, nil) + f := PathForModuleOut(ctx, output) + ctx.InstallFile(pathForTestCases(ctx), output, f) } SetProvider(ctx, TestSuiteInfoProvider, TestSuiteInfo{ diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go index c1e03cb62..327a41fda 100644 --- a/filesystem/avb_add_hash_footer.go +++ b/filesystem/avb_add_hash_footer.go @@ -210,6 +210,9 @@ var _ android.SourceFileProducer = (*avbAddHashFooter)(nil) // Implements android.SourceFileProducer func (a *avbAddHashFooter) Srcs() android.Paths { + if a.output == nil { + return nil + } return append(android.Paths{}, a.output) } |