From a6182ab2fa21738384a3d83c6038c17f01b29dda Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 21 Aug 2024 10:47:44 -0700 Subject: Move checkbuild targets of Soong modules into Soong Pass the name of Soong's checkbuild target for each module to Make so that it can depend on it from the main checkbuild rule. This will give better control over which files get built, allowing checkbuild to skip the jar combining step when transitive classpath jars are enabled. The per-module checkbuild targets are passed to make instead of added directly as a dependency of checkbuild in order to maintain the existing behavior of only building modules exposed to make in checkbuild. Also tweak the existing calls to CheckbuildFile and add InstallFileWithoutCheckbuild to match the files that are in the Make-based checkbuild. Bug: 308016794 Test: m checkbuild Change-Id: Ic5140819381d58f4d00f23a7a12447950c4cf268 --- android/module.go | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'android/module.go') diff --git a/android/module.go b/android/module.go index 7ce4e0535..297a1dc87 100644 --- a/android/module.go +++ b/android/module.go @@ -1545,26 +1545,43 @@ func (m *ModuleBase) VintfFragmentModuleNames(ctx ConfigAndErrorContext) []strin return m.base().commonProperties.Vintf_fragment_modules.GetOrDefault(m.ConfigurableEvaluator(ctx), nil) } +func (m *ModuleBase) generateVariantTarget(ctx *moduleContext) { + namespacePrefix := ctx.Namespace().id + if namespacePrefix != "" { + namespacePrefix = namespacePrefix + "-" + } + + if !ctx.uncheckedModule { + name := namespacePrefix + ctx.ModuleName() + "-" + ctx.ModuleSubDir() + "-checkbuild" + ctx.Phony(name, ctx.checkbuildFiles...) + ctx.checkbuildTarget = PathForPhony(ctx, name) + } + +} + func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { var allInstalledFiles InstallPaths - var allCheckbuildFiles Paths + var allCheckbuildTargets Paths ctx.VisitAllModuleVariants(func(module Module) { a := module.base() - var checkBuilds Paths + var checkbuildTarget Path + var uncheckedModule bool if a == m { allInstalledFiles = append(allInstalledFiles, ctx.installFiles...) - checkBuilds = ctx.checkbuildFiles + checkbuildTarget = ctx.checkbuildTarget + uncheckedModule = ctx.uncheckedModule } else { info := OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider) allInstalledFiles = append(allInstalledFiles, info.InstallFiles...) - checkBuilds = info.CheckbuildFiles + checkbuildTarget = info.CheckbuildTarget + uncheckedModule = info.UncheckedModule } // 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, a) { - allCheckbuildFiles = append(allCheckbuildFiles, checkBuilds...) + if (!ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, a)) && !uncheckedModule && checkbuildTarget != nil { + allCheckbuildTargets = append(allCheckbuildTargets, checkbuildTarget) } }) @@ -1585,11 +1602,10 @@ func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { deps = append(deps, info.InstallTarget) } - if len(allCheckbuildFiles) > 0 { + if len(allCheckbuildTargets) > 0 { name := namespacePrefix + ctx.ModuleName() + "-checkbuild" - ctx.Phony(name, allCheckbuildFiles...) - info.CheckbuildTarget = PathForPhony(ctx, name) - deps = append(deps, info.CheckbuildTarget) + ctx.Phony(name, allCheckbuildTargets...) + deps = append(deps, PathForPhony(ctx, name)) } if len(deps) > 0 { @@ -1706,9 +1722,11 @@ func (m *ModuleBase) archModuleContextFactory(ctx archModuleContextFactoryContex } type InstallFilesInfo struct { - InstallFiles InstallPaths - CheckbuildFiles Paths - PackagingSpecs []PackagingSpec + InstallFiles InstallPaths + CheckbuildFiles Paths + CheckbuildTarget Path + UncheckedModule bool + PackagingSpecs []PackagingSpec // katiInstalls tracks the install rules that were created by Soong but are being exported // to Make to convert to ninja rules so that Make can add additional dependencies. KatiInstalls katiInstalls @@ -1945,9 +1963,13 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) return } + m.generateVariantTarget(ctx) + installFiles.LicenseMetadataFile = ctx.licenseMetadataFile installFiles.InstallFiles = ctx.installFiles installFiles.CheckbuildFiles = ctx.checkbuildFiles + installFiles.CheckbuildTarget = ctx.checkbuildTarget + installFiles.UncheckedModule = ctx.uncheckedModule installFiles.PackagingSpecs = ctx.packagingSpecs installFiles.KatiInstalls = ctx.katiInstalls installFiles.KatiSymlinks = ctx.katiSymlinks -- cgit v1.2.3-59-g8ed1b