Merge "Move checkbuild targets of Soong modules into Soong" into main

This commit is contained in:
Colin Cross
2024-09-04 17:12:03 +00:00
committed by Gerrit Code Review
14 changed files with 131 additions and 36 deletions

View File

@@ -554,6 +554,14 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint
a.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", proptools.Bool(base.commonProperties.No_full_install))
}
if info.UncheckedModule {
a.SetBool("LOCAL_DONT_CHECK_MODULE", true)
} else if info.CheckbuildTarget != nil {
a.SetPath("LOCAL_CHECKED_MODULE", info.CheckbuildTarget)
} else {
a.SetOptionalPath("LOCAL_CHECKED_MODULE", a.OutputFile)
}
if len(info.TestData) > 0 {
a.AddStrings("LOCAL_TEST_DATA", androidMkDataPaths(info.TestData)...)
}

View File

@@ -1549,26 +1549,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)
}
})
@@ -1589,11 +1606,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 {
@@ -1710,9 +1726,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
@@ -1949,9 +1967,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

View File

@@ -122,6 +122,16 @@ type ModuleContext interface {
// dependency tags for which IsInstallDepNeeded returns true.
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFileWithoutCheckbuild creates a rule to copy srcPath to name in the installPath directory,
// with the given additional dependencies, but does not add the file to the list of files to build
// during `m checkbuild`.
//
// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
// installed file will be returned by PackagingSpecs() on this module or by
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// for which IsInstallDepNeeded returns true.
InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
// directory, and also unzip a zip file containing extra files to install into the same
// directory.
@@ -168,7 +178,8 @@ type ModuleContext interface {
// dependency tags for which IsInstallDepNeeded returns true.
PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
CheckbuildFile(srcPath Path)
CheckbuildFile(srcPaths ...Path)
UncheckedModule()
InstallInData() bool
InstallInTestcases() bool
@@ -237,11 +248,13 @@ type ModuleContext interface {
type moduleContext struct {
bp blueprint.ModuleContext
baseModuleContext
packagingSpecs []PackagingSpec
installFiles InstallPaths
checkbuildFiles Paths
module Module
phonies map[string]Paths
packagingSpecs []PackagingSpec
installFiles InstallPaths
checkbuildFiles Paths
checkbuildTarget Path
uncheckedModule bool
module Module
phonies map[string]Paths
// outputFiles stores the output of a module by tag and is used to set
// the OutputFilesProvider in GenerateBuildActions
outputFiles OutputFilesInfo
@@ -512,17 +525,22 @@ func (m *moduleContext) requiresFullInstall() bool {
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, false, true, nil)
return m.installFile(installPath, name, srcPath, deps, false, true, true, nil)
}
func (m *moduleContext) InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path,
deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, false, true, false, nil)
}
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, true, true, nil)
return m.installFile(installPath, name, srcPath, deps, true, true, true, nil)
}
func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
extraZip Path, deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, false, true, &extraFilesZip{
return m.installFile(installPath, name, srcPath, deps, false, true, true, &extraFilesZip{
zip: extraZip,
dir: installPath,
})
@@ -562,7 +580,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
}
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
executable bool, hooks bool, extraZip *extraFilesZip) InstallPath {
executable bool, hooks bool, checkbuild bool, extraZip *extraFilesZip) InstallPath {
fullInstallPath := installPath.Join(m, name)
if hooks {
@@ -629,7 +647,9 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
m.packageFile(fullInstallPath, srcPath, executable)
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
if checkbuild {
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
}
return fullInstallPath
}
@@ -670,7 +690,6 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
}
m.installFiles = append(m.installFiles, fullInstallPath)
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
}
overrides := CopyOf(m.Module().base().commonProperties.Overrides)
@@ -743,15 +762,21 @@ func (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath
ret := make(InstallPaths, 0, len(data))
for _, d := range data {
relPath := d.ToRelativeInstallPath()
installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, nil)
installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, true, nil)
ret = append(ret, installed)
}
return ret
}
func (m *moduleContext) CheckbuildFile(srcPath Path) {
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
// CheckbuildFile specifies the output files that should be built by checkbuild.
func (m *moduleContext) CheckbuildFile(srcPaths ...Path) {
m.checkbuildFiles = append(m.checkbuildFiles, srcPaths...)
}
// UncheckedModule marks the current module has having no files that should be built by checkbuild.
func (m *moduleContext) UncheckedModule() {
m.uncheckedModule = true
}
func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {

View File

@@ -136,6 +136,11 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir st
fmt.Fprintln(w, "LOCAL_SOONG_INSTALLED_MODULE :=", filepath.Join(modulePath, fi.stem()))
fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_PAIRS :=", fi.builtFile.String()+":"+filepath.Join(modulePath, fi.stem()))
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
if fi.checkbuildTarget != nil {
fmt.Fprintln(w, "LOCAL_CHECKED_MODULE :=", fi.checkbuildTarget.String())
} else {
fmt.Fprintln(w, "LOCAL_CHECKED_MODULE :=", fi.builtFile.String())
}
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.nameInMake())
if fi.module != nil {
// This apexFile's module comes from Soong

View File

@@ -577,6 +577,8 @@ type apexFile struct {
customStem string
symlinks []string // additional symlinks
checkbuildTarget android.Path
// Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk
// module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex
// suffix>]
@@ -612,6 +614,9 @@ func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidM
module: module,
}
if module != nil {
if installFilesInfo, ok := android.OtherModuleProvider(ctx, module, android.InstallFilesProvider); ok {
ret.checkbuildTarget = installFilesInfo.CheckbuildTarget
}
ret.moduleDir = ctx.OtherModuleDir(module)
ret.partition = module.PartitionTag(ctx.DeviceConfig())
ret.requiredModuleNames = module.RequiredModuleNames(ctx)

View File

@@ -403,6 +403,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
packageName: a.manifestValues.applicationId,
}
a.mergedManifestFile = manifestMerger(ctx, transitiveManifestPaths[0], manifestMergerParams)
ctx.CheckbuildFile(a.mergedManifestFile)
if !a.isLibrary {
// Only use the merged manifest for applications. For libraries, the transitive closure of manifests
// will be propagated to the final application and merged there. The merged manifest for libraries is
@@ -537,6 +538,8 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt,
linkFlags, linkDeps, compiledRes, compiledOverlay, transitiveAssets, splitPackages,
opts.aconfigTextFiles)
ctx.CheckbuildFile(packageRes)
// Extract assets from the resource package output so that they can be used later in aapt2link
// for modules that depend on this one.
if android.PrefixInList(linkFlags, "-A ") {
@@ -887,7 +890,6 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
var res android.Paths
if a.androidLibraryProperties.BuildAAR {
BuildAAR(ctx, a.aarFile, a.outputFile, a.manifestPath, a.rTxt, res)
ctx.CheckbuildFile(a.aarFile)
}
prebuiltJniPackages := android.Paths{}
@@ -1252,10 +1254,12 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
transitiveAssets := android.ReverseSliceInPlace(staticDeps.assets())
aapt2Link(ctx, exportPackage, nil, proguardOptionsFile, aaptRTxt,
linkFlags, linkDeps, nil, overlayRes, transitiveAssets, nil, nil)
ctx.CheckbuildFile(exportPackage)
a.exportPackage = exportPackage
rJar := android.PathForModuleOut(ctx, "busybox/R.jar")
resourceProcessorBusyBoxGenerateBinaryR(ctx, a.rTxt, a.manifest, rJar, nil, true, nil, false)
ctx.CheckbuildFile(rJar)
a.rJar = rJar
aapt2ExtractExtraPackages(ctx, extraAaptPackagesFile, a.rJar)
@@ -1350,6 +1354,9 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.headerJarFile = classpathFile
}
ctx.CheckbuildFile(a.headerJarFile)
ctx.CheckbuildFile(a.implementationJarFile)
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
HeaderJars: android.PathsIfNonNil(a.headerJarFile),
ResourceJars: android.PathsIfNonNil(resourceJarFile),

View File

@@ -1009,6 +1009,8 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
ctx.InstallFile(a.installDir, a.outputFile.Base(), a.outputFile, extraInstalledPaths...)
}
ctx.CheckbuildFile(a.outputFile)
a.buildAppDependencyInfo(ctx)
providePrebuiltInfo(ctx,

View File

@@ -1284,6 +1284,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
}
j.headerJarFile = combinedHeaderJarFile
ctx.CheckbuildFile(j.headerJarFile)
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
@@ -1764,6 +1766,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
j.dexpreopt(ctx, libName, dexOutputFile)
outputFile = dexOutputFile
ctx.CheckbuildFile(dexOutputFile)
} else {
// There is no code to compile into a dex jar, make sure the resources are propagated
// to the APK if this is an app.
@@ -1807,7 +1811,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
j.collectTransitiveSrcFiles(ctx, srcFiles)
ctx.CheckbuildFile(outputFile)
ctx.CheckbuildFile(j.implementationJarFile)
ctx.CheckbuildFile(j.headerJarFile)
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
@@ -1975,6 +1980,8 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
TransformJarsToJar(ctx, combinedHeaderJarOutputPath, "for turbine", jars, android.OptionalPath{},
false, nil, []string{"META-INF/TRANSITIVE"})
ctx.CheckbuildFile(combinedHeaderJarOutputPath)
return headerJar, combinedHeaderJarOutputPath
}

View File

@@ -489,6 +489,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
d.configPath = android.PathForModuleOut(ctx, "dexpreopt", dexJarStem, "dexpreopt.config")
dexpreopt.WriteModuleConfig(ctx, dexpreoptConfig, d.configPath)
ctx.CheckbuildFile(d.configPath)
if d.dexpreoptDisabled(ctx, libName) {
return
@@ -592,7 +593,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
}
} else if !d.preventInstall {
ctx.InstallFile(installPath, installBase, install.From)
// Install without adding to checkbuild to match behavior of previous Make-based checkbuild rules
ctx.InstallFileWithoutCheckbuild(installPath, installBase, install.From)
}
}

View File

@@ -2735,6 +2735,8 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
ctx.CheckbuildFile(outputFile)
if ctx.Device() {
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
// obtained from the associated deapexer module.
@@ -2801,6 +2803,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if ctx.Failed() {
return
}
ctx.CheckbuildFile(dexOutputFile)
// Initialize the hiddenapi structure.
j.initHiddenAPI(ctx, makeDexJarPathFromPath(dexOutputFile), outputFile, j.dexProperties.Uncompress_dex)

View File

@@ -1595,6 +1595,11 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
module.hostdexInstallFile = module.implLibraryModule.hostdexInstallFile
}
if installFilesInfo, ok := android.OtherModuleProvider(ctx, module.implLibraryModule, android.InstallFilesProvider); ok {
if installFilesInfo.CheckbuildTarget != nil {
ctx.CheckbuildFile(installFilesInfo.CheckbuildTarget)
}
}
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: module.implLibraryModule.uniqueSrcFiles.Strings()})
}

View File

@@ -947,6 +947,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
}
ctx.CheckbuildFile(mod.sourceProvider.Srcs()...)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: mod.sourceProvider.Srcs().Strings()})
}
@@ -957,15 +958,13 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
return
}
mod.outputFile = android.OptionalPathForPath(buildOutput.outputFile)
ctx.CheckbuildFile(buildOutput.outputFile)
if buildOutput.kytheFile != nil {
mod.kytheFiles = append(mod.kytheFiles, buildOutput.kytheFile)
}
bloaty.MeasureSizeForPaths(ctx, mod.compiler.strippedOutputFilePath(), android.OptionalPathForPath(mod.compiler.unstrippedOutputFilePath()))
mod.docTimestampFile = mod.compiler.rustdoc(ctx, flags, deps)
if mod.docTimestampFile.Valid() {
ctx.CheckbuildFile(mod.docTimestampFile.Path())
}
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !proptools.BoolDefault(mod.Installable(), mod.EverInstallable()) && !mod.ProcMacro() {

View File

@@ -211,6 +211,11 @@ func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries {
OutputFile: s.snapshotFile,
DistFiles: android.MakeDefaultDistFiles(s.snapshotFile.Path(), s.infoFile.Path()),
Include: "$(BUILD_PHONY_PACKAGE)",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetBool("LOCAL_DONT_CHECK_MODULE", true)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string) {
// Allow the sdk to be built by simply passing its name on the command line.

View File

@@ -563,11 +563,11 @@ be unnecessary as every module in the sdk already has its own licenses property.
}
builder.infoContents = string(output)
android.WriteFileRuleVerbatim(ctx, info, builder.infoContents)
installedInfo := ctx.InstallFile(android.PathForMainlineSdksInstall(ctx), info.Base(), info)
installedInfo := ctx.InstallFileWithoutCheckbuild(android.PathForMainlineSdksInstall(ctx), info.Base(), info)
s.infoFile = android.OptionalPathForPath(installedInfo)
// Install the zip, making sure that the info file has been installed as well.
installedZip := ctx.InstallFile(android.PathForMainlineSdksInstall(ctx), outputZipFile.Base(), outputZipFile, installedInfo)
installedZip := ctx.InstallFileWithoutCheckbuild(android.PathForMainlineSdksInstall(ctx), outputZipFile.Base(), outputZipFile, installedInfo)
s.snapshotFile = android.OptionalPathForPath(installedZip)
}