Merge "Add vintf_data inputPaths as Implicits to build command" into main
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index bb90607..9086c93 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -19,6 +19,8 @@
"slices"
"android/soong/android"
+
+ "github.com/google/blueprint/proptools"
)
// A singleton module that collects all of the aconfig flags declared in the
@@ -41,7 +43,7 @@
}
type allAconfigReleaseDeclarationsProperties struct {
- Api_files []string `android:"arch_variant,path"`
+ Api_files proptools.Configurable[[]string] `android:"arch_variant,path"`
}
type allAconfigDeclarationsSingleton struct {
@@ -62,7 +64,7 @@
func (this *allAconfigDeclarationsSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
apiFiles := android.Paths{}
- for _, apiFile := range this.properties.Api_files {
+ for _, apiFile := range this.properties.Api_files.GetOrDefault(ctx, nil) {
if path := android.PathForModuleSrc(ctx, apiFile); path != nil {
apiFiles = append(apiFiles, path)
}
diff --git a/android/androidmk.go b/android/androidmk.go
index 87a93e3..f84fd8c 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -741,8 +741,29 @@
// defined through the androidmk mechanisms, so this function is an alternate implementation of
// the androidmk singleton that just focuses on getting the dist contributions
func (c *androidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []blueprint.Module) {
- allDistContributions := getDistContributionsFromMods(ctx, mods)
+ allDistContributions, moduleInfoJSONs := getSoongOnlyDataFromMods(ctx, mods)
+ // Build module-info.json. Only in builds with HasDeviceProduct(), as we need a named
+ // device to have a TARGET_OUT folder.
+ if ctx.Config().HasDeviceProduct() {
+ moduleInfoJSONPath := pathForInstall(ctx, Android, X86_64, "", "module-info.json")
+ if err := writeModuleInfoJSON(ctx, moduleInfoJSONs, moduleInfoJSONPath); err != nil {
+ ctx.Errorf("%s", err)
+ }
+ ctx.Phony("module-info", moduleInfoJSONPath)
+ ctx.Phony("droidcore-unbundled", moduleInfoJSONPath)
+ allDistContributions = append(allDistContributions, distContributions{
+ copiesForGoals: []*copiesForGoals{{
+ goals: "general-tests droidcore-unbundled",
+ copies: []distCopy{{
+ from: moduleInfoJSONPath,
+ dest: "module-info.json",
+ }},
+ }},
+ })
+ }
+
+ // Build dist.mk for the packaging step to read and generate dist targets
distMkFile := absolutePath(filepath.Join(ctx.Config().katiPackageMkDir(), "dist.mk"))
var goalOutputPairs []string
@@ -793,8 +814,11 @@
}
}
-func getDistContributionsFromMods(ctx fillInEntriesContext, mods []blueprint.Module) []distContributions {
+// getSoongOnlyDataFromMods gathers data from the given modules needed in soong-only builds.
+// Currently, this is the dist contributions, and the module-info.json contents.
+func getSoongOnlyDataFromMods(ctx fillInEntriesContext, mods []blueprint.Module) ([]distContributions, []*ModuleInfoJSON) {
var allDistContributions []distContributions
+ var moduleInfoJSONs []*ModuleInfoJSON
for _, mod := range mods {
if amod, ok := mod.(Module); ok && shouldSkipAndroidMkProcessing(ctx, amod.base()) {
continue
@@ -806,6 +830,9 @@
if info.PrimaryInfo.disabled() {
continue
}
+ if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ moduleInfoJSONs = append(moduleInfoJSONs, moduleInfoJSON)
+ }
if contribution := info.PrimaryInfo.getDistContributions(ctx, mod); contribution != nil {
allDistContributions = append(allDistContributions, *contribution)
}
@@ -831,6 +858,9 @@
if data.Entries.disabled() {
continue
}
+ if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ moduleInfoJSONs = append(moduleInfoJSONs, moduleInfoJSON)
+ }
if contribution := data.Entries.getDistContributions(mod); contribution != nil {
allDistContributions = append(allDistContributions, *contribution)
}
@@ -841,6 +871,9 @@
if entries.disabled() {
continue
}
+ if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ moduleInfoJSONs = append(moduleInfoJSONs, moduleInfoJSON)
+ }
if contribution := entries.getDistContributions(mod); contribution != nil {
allDistContributions = append(allDistContributions, *contribution)
}
@@ -850,7 +883,7 @@
}
}
}
- return allDistContributions
+ return allDistContributions, moduleInfoJSONs
}
func translateAndroidMk(ctx SingletonContext, absMkFile string, moduleInfoJSONPath WritablePath, mods []blueprint.Module) error {
diff --git a/android/module.go b/android/module.go
index b9489b4..a58057e 100644
--- a/android/module.go
+++ b/android/module.go
@@ -990,8 +990,9 @@
// 2. `boot_signer` is `required` by modules like `build_image` which is explicitly list as
// the top-level build goal (in the shell file that invokes Soong).
// 3. `boot_signer` depends on `bouncycastle-unbundled` which is in the missing git project.
- // 4. aosp_kernel-build-tools invokes soong with `--skip-make`. Therefore, the absence of
- // ALLOW_MISSING_DEPENDENCIES didn't cause a problem.
+ // 4. aosp_kernel-build-tools invokes soong with `--soong-only`. Therefore, the absence of
+ // ALLOW_MISSING_DEPENDENCIES didn't cause a problem, as previously only make processed required
+ // dependencies.
// 5. Now, since Soong understands `required` deps, it tries to build `boot_signer` and the
// absence of external/bouncycastle fails the build.
//
diff --git a/android/variable.go b/android/variable.go
index 14094e2..3e637fe 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -555,6 +555,7 @@
type PartitionQualifiedVariablesType struct {
BuildingImage bool `json:",omitempty"`
+ PrebuiltImage bool `json:",omitempty"`
BoardErofsCompressor string `json:",omitempty"`
BoardErofsCompressHints string `json:",omitempty"`
BoardErofsPclusterSize string `json:",omitempty"`
diff --git a/bin/mm b/bin/mm
index 6461b1e..6f1c934 100755
--- a/bin/mm
+++ b/bin/mm
@@ -19,6 +19,6 @@
require_top
-_wrap_build "$TOP/build/soong/soong_ui.bash" --build-mode --modules-in-a-dir-no-deps --dir="$(pwd)" "$@"
+_wrap_build "$TOP/build/soong/soong_ui.bash" --build-mode --modules-in-a-dir --dir="$(pwd)" "$@"
exit $?
diff --git a/bin/mmm b/bin/mmm
index ab3a632..d9190e5 100755
--- a/bin/mmm
+++ b/bin/mmm
@@ -19,6 +19,6 @@
require_top
-_wrap_build "$TOP/build/soong/soong_ui.bash" --build-mode --modules-in-dirs-no-deps --dir="$(pwd)" "$@"
+_wrap_build "$TOP/build/soong/soong_ui.bash" --build-mode --modules-in-dirs --dir="$(pwd)" "$@"
exit $?
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 7926292..a884964 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -471,20 +471,6 @@
description: "Build action: build from the top of the source tree.",
action: build.BUILD_MODULES,
}, {
- // This is redirecting to mma build command behaviour. Once it has soaked for a
- // while, the build command is deleted from here once it has been removed from the
- // envsetup.sh.
- name: "modules-in-a-dir-no-deps",
- description: "Build action: builds all of the modules in the current directory without their dependencies.",
- action: build.BUILD_MODULES_IN_A_DIRECTORY,
- }, {
- // This is redirecting to mmma build command behaviour. Once it has soaked for a
- // while, the build command is deleted from here once it has been removed from the
- // envsetup.sh.
- name: "modules-in-dirs-no-deps",
- description: "Build action: builds all of the modules in the supplied directories without their dependencies.",
- action: build.BUILD_MODULES_IN_DIRECTORIES,
- }, {
name: "modules-in-a-dir",
description: "Build action: builds all of the modules in the current directory and their dependencies.",
action: build.BUILD_MODULES_IN_A_DIRECTORY,
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 98af479..6d6c15c 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -99,6 +99,9 @@
// The index used to prevent rollback of the image on device.
Avb_rollback_index *int64
+ // Rollback index location of this image. Must be 0, 1, 2, etc.
+ Avb_rollback_index_location *int64
+
// The security patch passed to as the com.android.build.<type>.security_patch avb property.
// Replacement for the make variables BOOT_SECURITY_PATCH / INIT_BOOT_SECURITY_PATCH.
Security_patch *string
@@ -237,6 +240,27 @@
Bootconfig: b.getBootconfigPath(ctx),
Output: output,
})
+
+ extractedPublicKey := android.PathForModuleOut(ctx, b.partitionName()+".avbpubkey")
+ if b.properties.Avb_private_key != nil {
+ key := android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key))
+ ctx.Build(pctx, android.BuildParams{
+ Rule: extractPublicKeyRule,
+ Input: key,
+ Output: extractedPublicKey,
+ })
+ }
+ var ril int
+ if b.properties.Avb_rollback_index_location != nil {
+ ril = proptools.Int(b.properties.Avb_rollback_index_location)
+ }
+
+ android.SetProvider(ctx, vbmetaPartitionProvider, vbmetaPartitionInfo{
+ Name: b.bootImageType.String(),
+ RollbackIndexLocation: ril,
+ PublicKey: extractedPublicKey,
+ Output: output,
+ })
}
var BootimgInfoProvider = blueprint.NewProvider[BootimgInfo]()
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 68cbee9..357ec32 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -131,6 +131,9 @@
// The index used to prevent rollback of the image. Only used if use_avb is true.
Rollback_index *int64
+ // Rollback index location of this image. Must be 0, 1, 2, etc.
+ Rollback_index_location *int64
+
// Name of the partition stored in vbmeta desc. Defaults to the name of this module.
Partition_name *string
@@ -537,6 +540,33 @@
if proptools.Bool(f.properties.Unchecked_module) {
ctx.UncheckedModule()
}
+
+ f.setVbmetaPartitionProvider(ctx)
+}
+
+func (f *filesystem) setVbmetaPartitionProvider(ctx android.ModuleContext) {
+ var extractedPublicKey android.ModuleOutPath
+ if f.properties.Avb_private_key != nil {
+ key := android.PathForModuleSrc(ctx, proptools.String(f.properties.Avb_private_key))
+ extractedPublicKey = android.PathForModuleOut(ctx, f.partitionName()+".avbpubkey")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: extractPublicKeyRule,
+ Input: key,
+ Output: extractedPublicKey,
+ })
+ }
+
+ var ril int
+ if f.properties.Rollback_index_location != nil {
+ ril = proptools.Int(f.properties.Rollback_index_location)
+ }
+
+ android.SetProvider(ctx, vbmetaPartitionProvider, vbmetaPartitionInfo{
+ Name: f.partitionName(),
+ RollbackIndexLocation: ril,
+ PublicKey: extractedPublicKey,
+ Output: f.output,
+ })
}
func (f *filesystem) getMapFile(ctx android.ModuleContext) android.WritablePath {
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index b7f312c..91826b2 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -148,8 +148,8 @@
var vbmetaChainedPartitionDep = chainedPartitionDep{}
func (v *vbmeta) DepsMutator(ctx android.BottomUpMutatorContext) {
- ctx.AddDependency(ctx.Module(), vbmetaPartitionDep, v.properties.Partitions.GetOrDefault(ctx, nil)...)
- ctx.AddDependency(ctx.Module(), vbmetaChainedPartitionDep, v.properties.Chained_partitions...)
+ ctx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), vbmetaPartitionDep, v.properties.Partitions.GetOrDefault(ctx, nil)...)
+ ctx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), vbmetaChainedPartitionDep, v.properties.Chained_partitions...)
}
func (v *vbmeta) installFileName() string {
diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go
index 889a4c2..58ebcc4 100644
--- a/fsgen/boot_imgs.go
+++ b/fsgen/boot_imgs.go
@@ -69,23 +69,26 @@
ctx.CreateModule(
filesystem.BootimgFactory,
&filesystem.BootimgProperties{
- Kernel_prebuilt: proptools.StringPtr(":" + kernelFilegroupName),
- Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
- Partition_size: partitionSize,
- Use_avb: avbInfo.avbEnable,
- Avb_mode: avbInfo.avbMode,
- Avb_private_key: avbInfo.avbkeyFilegroup,
- Avb_rollback_index: avbInfo.avbRollbackIndex,
- Avb_algorithm: avbInfo.avbAlgorithm,
- Security_patch: securityPatch,
- Dtb_prebuilt: dtbPrebuilt,
- Cmdline: cmdline,
- Stem: proptools.StringPtr("boot.img"),
+ Kernel_prebuilt: proptools.StringPtr(":" + kernelFilegroupName),
+ Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
+ Partition_size: partitionSize,
+ Use_avb: avbInfo.avbEnable,
+ Avb_mode: avbInfo.avbMode,
+ Avb_private_key: avbInfo.avbkeyFilegroup,
+ Avb_rollback_index: avbInfo.avbRollbackIndex,
+ Avb_rollback_index_location: avbInfo.avbRollbackIndexLocation,
+ Avb_algorithm: avbInfo.avbAlgorithm,
+ Security_patch: securityPatch,
+ Dtb_prebuilt: dtbPrebuilt,
+ Cmdline: cmdline,
+ Stem: proptools.StringPtr("boot.img"),
},
&struct {
- Name *string
+ Name *string
+ Visibility []string
}{
- Name: proptools.StringPtr(bootImageName),
+ Name: proptools.StringPtr(bootImageName),
+ Visibility: []string{"//visibility:public"},
},
)
return true
@@ -123,23 +126,26 @@
ctx.CreateModule(
filesystem.BootimgFactory,
&filesystem.BootimgProperties{
- Boot_image_type: proptools.StringPtr("vendor_boot"),
- Ramdisk_module: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor_ramdisk")),
- Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
- Partition_size: partitionSize,
- Use_avb: avbInfo.avbEnable,
- Avb_mode: avbInfo.avbMode,
- Avb_private_key: avbInfo.avbkeyFilegroup,
- Avb_rollback_index: avbInfo.avbRollbackIndex,
- Dtb_prebuilt: dtbPrebuilt,
- Cmdline: cmdline,
- Bootconfig: vendorBootConfigImg,
- Stem: proptools.StringPtr("vendor_boot.img"),
+ Boot_image_type: proptools.StringPtr("vendor_boot"),
+ Ramdisk_module: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "vendor_ramdisk")),
+ Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
+ Partition_size: partitionSize,
+ Use_avb: avbInfo.avbEnable,
+ Avb_mode: avbInfo.avbMode,
+ Avb_private_key: avbInfo.avbkeyFilegroup,
+ Avb_rollback_index: avbInfo.avbRollbackIndex,
+ Avb_rollback_index_location: avbInfo.avbRollbackIndexLocation,
+ Dtb_prebuilt: dtbPrebuilt,
+ Cmdline: cmdline,
+ Bootconfig: vendorBootConfigImg,
+ Stem: proptools.StringPtr("vendor_boot.img"),
},
&struct {
- Name *string
+ Name *string
+ Visibility []string
}{
- Name: proptools.StringPtr(bootImageName),
+ Name: proptools.StringPtr(bootImageName),
+ Visibility: []string{"//visibility:public"},
},
)
return true
@@ -172,22 +178,25 @@
ctx.CreateModule(
filesystem.BootimgFactory,
&filesystem.BootimgProperties{
- Boot_image_type: proptools.StringPtr("init_boot"),
- Ramdisk_module: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "ramdisk")),
- Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
- Security_patch: securityPatch,
- Partition_size: partitionSize,
- Use_avb: avbInfo.avbEnable,
- Avb_mode: avbInfo.avbMode,
- Avb_private_key: avbInfo.avbkeyFilegroup,
- Avb_rollback_index: avbInfo.avbRollbackIndex,
- Avb_algorithm: avbInfo.avbAlgorithm,
- Stem: proptools.StringPtr("init_boot.img"),
+ Boot_image_type: proptools.StringPtr("init_boot"),
+ Ramdisk_module: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "ramdisk")),
+ Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion),
+ Security_patch: securityPatch,
+ Partition_size: partitionSize,
+ Use_avb: avbInfo.avbEnable,
+ Avb_mode: avbInfo.avbMode,
+ Avb_private_key: avbInfo.avbkeyFilegroup,
+ Avb_rollback_index: avbInfo.avbRollbackIndex,
+ Avb_rollback_index_location: avbInfo.avbRollbackIndexLocation,
+ Avb_algorithm: avbInfo.avbAlgorithm,
+ Stem: proptools.StringPtr("init_boot.img"),
},
&struct {
- Name *string
+ Name *string
+ Visibility []string
}{
- Name: proptools.StringPtr(bootImageName),
+ Name: proptools.StringPtr(bootImageName),
+ Visibility: []string{"//visibility:public"},
},
)
return true
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index d2f00cd..ebcc68b 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -178,7 +178,7 @@
)
}
- for _, x := range createVbmetaPartitions(ctx, finalSoongGeneratedPartitions) {
+ for _, x := range f.createVbmetaPartitions(ctx, finalSoongGeneratedPartitions) {
f.properties.Vbmeta_module_names = append(f.properties.Vbmeta_module_names, x.moduleName)
f.properties.Vbmeta_partition_names = append(f.properties.Vbmeta_partition_names, x.partitionName)
}
@@ -865,6 +865,8 @@
fsProps.Avb_algorithm = avbInfo.avbAlgorithm
// BOARD_AVB_SYSTEM_ROLLBACK_INDEX
fsProps.Rollback_index = avbInfo.avbRollbackIndex
+ // BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION
+ fsProps.Rollback_index_location = avbInfo.avbRollbackIndexLocation
fsProps.Avb_hash_algorithm = avbInfo.avbHashAlgorithm
fsProps.Partition_name = proptools.StringPtr(partitionType)
@@ -893,13 +895,14 @@
}
type avbInfo struct {
- avbEnable *bool
- avbKeyPath *string
- avbkeyFilegroup *string
- avbAlgorithm *string
- avbRollbackIndex *int64
- avbMode *string
- avbHashAlgorithm *string
+ avbEnable *bool
+ avbKeyPath *string
+ avbkeyFilegroup *string
+ avbAlgorithm *string
+ avbRollbackIndex *int64
+ avbRollbackIndexLocation *int64
+ avbMode *string
+ avbHashAlgorithm *string
}
func getAvbInfo(config android.Config, partitionType string) avbInfo {
@@ -946,6 +949,13 @@
}
result.avbRollbackIndex = &parsed
}
+ if specificPartitionVars.BoardAvbRollbackIndexLocation != "" {
+ parsed, err := strconv.ParseInt(specificPartitionVars.BoardAvbRollbackIndexLocation, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("Rollback index location must be an int, got %s", specificPartitionVars.BoardAvbRollbackIndexLocation))
+ }
+ result.avbRollbackIndexLocation = &parsed
+ }
// Make allows you to pass arbitrary arguments to avbtool via this variable, but in practice
// it's only used for --hash_algorithm. The soong module has a dedicated property for the
diff --git a/fsgen/vbmeta_partitions.go b/fsgen/vbmeta_partitions.go
index e3dc416..be738ea 100644
--- a/fsgen/vbmeta_partitions.go
+++ b/fsgen/vbmeta_partitions.go
@@ -19,7 +19,6 @@
"android/soong/filesystem"
"slices"
"strconv"
- "strings"
"github.com/google/blueprint/proptools"
)
@@ -32,6 +31,27 @@
partitionName string
}
+// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=4849;drc=62e20f0d218f60bae563b4ee742d88cca1fc1901
+var avbPartitions = []string{
+ "boot",
+ "init_boot",
+ "vendor_boot",
+ "vendor_kernel_boot",
+ "system",
+ "vendor",
+ "product",
+ "system_ext",
+ "odm",
+ "vendor_dlkm",
+ "odm_dlkm",
+ "system_dlkm",
+ "dtbo",
+ "pvmfw",
+ "recovery",
+ "vbmeta_system",
+ "vbmeta_vendor",
+}
+
// Creates the vbmeta partition and the chained vbmeta partitions. Returns the list of module names
// that the function created. May return nil if the product isn't using avb.
//
@@ -43,7 +63,7 @@
// like vbmeta_system might contain the avb metadata for just a few products. In cuttlefish
// vbmeta_system contains metadata about product, system, and system_ext. Using chained partitions,
// that group of partitions can be updated independently from the other signed partitions.
-func createVbmetaPartitions(ctx android.LoadHookContext, generatedPartitionTypes []string) []vbmetaModuleInfo {
+func (f *filesystemCreator) createVbmetaPartitions(ctx android.LoadHookContext, generatedPartitionTypes []string) []vbmetaModuleInfo {
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
// Some products seem to have BuildingVbmetaImage as true even when BoardAvbEnable is false
if !partitionVars.BuildingVbmetaImage || !partitionVars.BoardAvbEnable {
@@ -52,14 +72,16 @@
var result []vbmetaModuleInfo
- var chainedPartitions []string
- var partitionTypesHandledByChainedPartitions []string
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=4593;drc=62e20f0d218f60bae563b4ee742d88cca1fc1901
+ var internalAvbPartitionsInChainedVbmetaImages []string
+ var chainedPartitionTypes []string
for _, chainedName := range android.SortedKeys(partitionVars.ChainedVbmetaPartitions) {
props := partitionVars.ChainedVbmetaPartitions[chainedName]
chainedName = "vbmeta_" + chainedName
if len(props.Partitions) == 0 {
continue
}
+ internalAvbPartitionsInChainedVbmetaImages = append(internalAvbPartitionsInChainedVbmetaImages, props.Partitions...)
if len(props.Key) == 0 {
ctx.ModuleErrorf("No key found for chained avb partition %q", chainedName)
continue
@@ -92,7 +114,6 @@
var partitionModules []string
for _, partition := range props.Partitions {
- partitionTypesHandledByChainedPartitions = append(partitionTypesHandledByChainedPartitions, partition)
if !slices.Contains(generatedPartitionTypes, partition) {
// The partition is probably unsupported.
continue
@@ -100,7 +121,7 @@
partitionModules = append(partitionModules, generatedModuleNameForPartition(ctx.Config(), partition))
}
- name := generatedModuleName(ctx.Config(), chainedName)
+ name := generatedModuleNameForPartition(ctx.Config(), chainedName)
ctx.CreateModuleInDirectory(
filesystem.VbmetaFactory,
".", // Create in the root directory for now so its easy to get the key
@@ -119,15 +140,15 @@
},
).HideFromMake()
- chainedPartitions = append(chainedPartitions, name)
-
result = append(result, vbmetaModuleInfo{
moduleName: name,
partitionName: chainedName,
})
+
+ chainedPartitionTypes = append(chainedPartitionTypes, chainedName)
}
- vbmetaModuleName := generatedModuleName(ctx.Config(), "vbmeta")
+ vbmetaModuleName := generatedModuleNameForPartition(ctx.Config(), "vbmeta")
var algorithm *string
var ri *int64
@@ -148,20 +169,79 @@
ri = &parsedRi
}
- var partitionModules []string
- for _, partitionType := range generatedPartitionTypes {
- if slices.Contains(partitionTypesHandledByChainedPartitions, partitionType) {
- // Already handled by a chained vbmeta partition
+ // --chain_partition argument is only set for partitions that set
+ // `BOARD_AVB_<partition name>_KEY_PATH` value and is not "recovery"
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=4823;drc=62e20f0d218f60bae563b4ee742d88cca1fc1901
+ includeAsChainedPartitionInVbmeta := func(partition string) bool {
+ val, ok := partitionVars.PartitionQualifiedVariables[partition]
+ return ok && len(val.BoardAvbKeyPath) > 0 && partition != "recovery"
+ }
+
+ // --include_descriptors_from_image is passed if both conditions are met:
+ // - `BOARD_AVB_<partition name>_KEY_PATH` value is not set
+ // - not included in INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES
+ // for partitions that set INSTALLED_<partition name>IMAGE_TARGET
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=4827;drc=62e20f0d218f60bae563b4ee742d88cca1fc1901
+ includeAsIncludedPartitionInVbmeta := func(partition string) bool {
+ if android.InList(partition, internalAvbPartitionsInChainedVbmetaImages) {
+ // Already handled by chained vbmeta partitions
+ return false
+ }
+ partitionQualifiedVars := partitionVars.PartitionQualifiedVariables[partition]
+
+ // The return logic in the switch cases below are identical to
+ // ifdef INSTALLED_<partition name>IMAGE_TARGET
+ switch partition {
+ case "boot":
+ return partitionQualifiedVars.BuildingImage || partitionQualifiedVars.PrebuiltImage || partitionVars.BoardUsesRecoveryAsBoot
+ case "vendor_kernel_boot", "dtbo":
+ return partitionQualifiedVars.PrebuiltImage
+ case "system":
+ return partitionQualifiedVars.BuildingImage
+ case "init_boot", "vendor_boot", "vendor", "product", "system_ext", "odm", "vendor_dlkm", "odm_dlkm", "system_dlkm":
+ return partitionQualifiedVars.BuildingImage || partitionQualifiedVars.PrebuiltImage
+ // TODO: Import BOARD_USES_PVMFWIMAGE
+ // ifeq ($(BOARD_USES_PVMFWIMAGE),true)
+ // case "pvmfw":
+ case "recovery":
+ // ifdef INSTALLED_RECOVERYIMAGE_TARGET
+ return !ctx.DeviceConfig().BoardUsesRecoveryAsBoot() && !ctx.DeviceConfig().BoardMoveRecoveryResourcesToVendorBoot()
+ // Technically these partitions are determined based on len(BOARD_AVB_VBMETA_SYSTEM) and
+ // len(BOARD_AVB_VBMETA_VENDOR) but if these are non empty these partitions are
+ // already included in the chained partitions.
+ case "vbmeta_system", "vbmeta_vendor":
+ return false
+ default:
+ return false
+ }
+ }
+
+ var chainedPartitionModules []string
+ var includePartitionModules []string
+ allGeneratedPartitionTypes := append(generatedPartitionTypes,
+ chainedPartitionTypes...,
+ )
+ if len(f.properties.Boot_image) > 0 {
+ allGeneratedPartitionTypes = append(allGeneratedPartitionTypes, "boot")
+ }
+ if len(f.properties.Init_boot_image) > 0 {
+ allGeneratedPartitionTypes = append(allGeneratedPartitionTypes, "init_boot")
+ }
+ if len(f.properties.Vendor_boot_image) > 0 {
+ allGeneratedPartitionTypes = append(allGeneratedPartitionTypes, "vendor_boot")
+ }
+
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=4919;drc=62e20f0d218f60bae563b4ee742d88cca1fc1901
+ for _, partitionType := range android.SortedUniqueStrings(append(avbPartitions, chainedPartitionTypes...)) {
+ if !android.InList(partitionType, allGeneratedPartitionTypes) {
+ // Skip if the partition is not auto generated
continue
}
- if strings.Contains(partitionType, "ramdisk") || strings.Contains(partitionType, "boot") || partitionType == "userdata" || partitionType == "recovery" {
- // ramdisk and userdata are never signed with avb information
- // recovery partition is skipped in adding the partition descriptor into vbmeta.img.
- // boot partitions just have the avb footer, and don't have a corresponding vbmeta
- // partition.
- continue
+ if includeAsChainedPartitionInVbmeta(partitionType) {
+ chainedPartitionModules = append(chainedPartitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
+ } else if includeAsIncludedPartitionInVbmeta(partitionType) {
+ includePartitionModules = append(includePartitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
}
- partitionModules = append(partitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
}
ctx.CreateModuleInDirectory(
@@ -172,8 +252,8 @@
Algorithm: algorithm,
Private_key: key,
Rollback_index: ri,
- Chained_partitions: chainedPartitions,
- Partitions: proptools.NewSimpleConfigurable(partitionModules),
+ Chained_partitions: chainedPartitionModules,
+ Partitions: proptools.NewSimpleConfigurable(includePartitionModules),
Partition_name: proptools.StringPtr("vbmeta"),
}, &struct {
Name *string
diff --git a/scripts/run-soong-tests-with-go-tools.sh b/scripts/run-soong-tests-with-go-tools.sh
index 1fbb1fc..82efaa0 100755
--- a/scripts/run-soong-tests-with-go-tools.sh
+++ b/scripts/run-soong-tests-with-go-tools.sh
@@ -38,6 +38,11 @@
CLANG_VERSION=$(build/soong/scripts/get_clang_version.py)
export CC="${TOP}/prebuilts/clang/host/${OS}-x86/${CLANG_VERSION}/bin/clang"
export CXX="${TOP}/prebuilts/clang/host/${OS}-x86/${CLANG_VERSION}/bin/clang++"
+ glibc_dir="${TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8"
+ export CGO_CFLAGS="--sysroot ${glibc_dir}/sysroot/"
+ export CGO_CPPFLAGS="--sysroot ${glibc_dir}/sysroot/"
+ export CGO_CXXFLAGS="--sysroot ${glibc_dir}/sysroot/"
+ export CGO_LDFLAGS="--sysroot ${glibc_dir}/sysroot/ -B ${glibc_dir}/lib/gcc/x86_64-linux/4.8.3 -L ${glibc_dir}/lib/gcc/x86_64-linux/4.8.3 -L ${glibc_dir}/x86_64-linux/lib64"
fi
# androidmk_test.go gets confused if ANDROID_BUILD_TOP is set.
diff --git a/ui/build/build.go b/ui/build/build.go
index 26f5969..ea86782 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -33,26 +33,13 @@
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "CleanSpec.mk"))
ensureEmptyDirectoriesExist(ctx, config.TempDir())
- // Potentially write a marker file for whether kati is enabled. This is used by soong_build to
- // potentially run the AndroidMk singleton and postinstall commands.
- // Note that the absence of the file does not not preclude running Kati for product
- // configuration purposes.
- katiEnabledMarker := filepath.Join(config.SoongOutDir(), ".soong.kati_enabled")
- if config.SkipKatiNinja() {
- os.Remove(katiEnabledMarker)
- // Note that we can not remove the file for SkipKati builds yet -- some continuous builds
- // --skip-make builds rely on kati targets being defined.
- } else if !config.SkipKati() {
- ensureEmptyFileExists(ctx, katiEnabledMarker)
- }
-
// The ninja_build file is used by our buildbots to understand that the output
// can be parsed as ninja output.
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "ninja_build"))
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), ".out-dir"))
if buildDateTimeFile, ok := config.environ.Get("BUILD_DATETIME_FILE"); ok {
- err := ioutil.WriteFile(buildDateTimeFile, []byte(config.buildDateTime), 0666) // a+rw
+ err := os.WriteFile(buildDateTimeFile, []byte(config.buildDateTime), 0666) // a+rw
if err != nil {
ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
}
@@ -100,6 +87,21 @@
writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_hostname.txt", hostname)
}
+// SetupKatiEnabledMarker creates or delets a file that tells soong_build if we're running with
+// kati.
+func SetupKatiEnabledMarker(ctx Context, config Config) {
+ // Potentially write a marker file for whether kati is enabled. This is used by soong_build to
+ // potentially run the AndroidMk singleton and postinstall commands.
+ // Note that the absence of the file does not preclude running Kati for product
+ // configuration purposes.
+ katiEnabledMarker := filepath.Join(config.SoongOutDir(), ".soong.kati_enabled")
+ if config.SkipKati() || config.SkipKatiNinja() {
+ os.Remove(katiEnabledMarker)
+ } else {
+ ensureEmptyFileExists(ctx, katiEnabledMarker)
+ }
+}
+
var combinedBuildNinjaTemplate = template.Must(template.New("combined").Parse(`
builddir = {{.OutDir}}
{{if .UseRemoteBuild }}pool local_pool
@@ -329,10 +331,16 @@
if what&RunProductConfig != 0 {
runMakeProductConfig(ctx, config)
+
+ // Re-evaluate what to run because there are product variables that control how
+ // soong and make are run.
+ what = evaluateWhatToRun(config, ctx.Verboseln)
}
// Everything below here depends on product config.
+ SetupKatiEnabledMarker(ctx, config)
+
if inList("installclean", config.Arguments()) ||
inList("install-clean", config.Arguments()) {
logArgsOtherThan("installclean", "install-clean")
diff --git a/ui/build/config.go b/ui/build/config.go
index 4f2d213..84e4005 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -63,6 +63,7 @@
NINJA_NINJA
NINJA_N2
NINJA_SISO
+ NINJA_NINJAGO
)
type Config struct{ *configImpl }
@@ -77,26 +78,27 @@
logsPrefix string
// From the arguments
- parallel int
- keepGoing int
- verbose bool
- checkbuild bool
- dist bool
- jsonModuleGraph bool
- reportMkMetrics bool // Collect and report mk2bp migration progress metrics.
- soongDocs bool
- skipConfig bool
- skipKati bool
- skipKatiNinja bool
- skipSoong bool
- skipNinja bool
- skipSoongTests bool
- searchApiDir bool // Scan the Android.bp files generated in out/api_surfaces
- skipMetricsUpload bool
- buildStartedTime int64 // For metrics-upload-only - manually specify a build-started time
- buildFromSourceStub bool
- incrementalBuildActions bool
- ensureAllowlistIntegrity bool // For CI builds - make sure modules are mixed-built
+ parallel int
+ keepGoing int
+ verbose bool
+ checkbuild bool
+ dist bool
+ jsonModuleGraph bool
+ reportMkMetrics bool // Collect and report mk2bp migration progress metrics.
+ soongDocs bool
+ skipConfig bool
+ skipKati bool
+ skipKatiControlledByFlags bool
+ skipKatiNinja bool
+ skipSoong bool
+ skipNinja bool
+ skipSoongTests bool
+ searchApiDir bool // Scan the Android.bp files generated in out/api_surfaces
+ skipMetricsUpload bool
+ buildStartedTime int64 // For metrics-upload-only - manually specify a build-started time
+ buildFromSourceStub bool
+ incrementalBuildActions bool
+ ensureAllowlistIntegrity bool // For CI builds - make sure modules are mixed-built
// From the product config
katiArgs []string
@@ -323,6 +325,8 @@
ret.ninjaCommand = NINJA_N2
case "siso":
ret.ninjaCommand = NINJA_SISO
+ case "ninjago":
+ ret.ninjaCommand = NINJA_NINJAGO
default:
if os.Getenv("SOONG_USE_N2") == "true" {
ret.ninjaCommand = NINJA_N2
@@ -843,15 +847,20 @@
c.emptyNinjaFile = true
} else if arg == "--skip-ninja" {
c.skipNinja = true
- } else if arg == "--skip-make" {
- // TODO(ccross): deprecate this, it has confusing behaviors. It doesn't run kati,
- // but it does run a Kati ninja file if the .kati_enabled marker file was created
- // by a previous build.
- c.skipConfig = true
- c.skipKati = true
} else if arg == "--soong-only" {
+ if c.skipKatiControlledByFlags {
+ ctx.Fatalf("Cannot specify both --soong-only and --no-soong-only")
+ }
+ c.skipKatiControlledByFlags = true
c.skipKati = true
c.skipKatiNinja = true
+ } else if arg == "--no-soong-only" {
+ if c.skipKatiControlledByFlags {
+ ctx.Fatalf("Cannot specify both --soong-only and --no-soong-only")
+ }
+ c.skipKatiControlledByFlags = true
+ c.skipKati = false
+ c.skipKatiNinja = false
} else if arg == "--config-only" {
c.skipKati = true
c.skipKatiNinja = true
@@ -1339,6 +1348,10 @@
}
func (c *configImpl) UseABFS() bool {
+ if c.ninjaCommand == NINJA_NINJAGO {
+ return true
+ }
+
if v, ok := c.environ.Get("NO_ABFS"); ok {
v = strings.ToLower(strings.TrimSpace(v))
if v == "true" || v == "1" {
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index b592f11..d5aab54 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -246,6 +246,8 @@
// `true` will relegate missing outputs to warnings.
"BUILD_BROKEN_MISSING_OUTPUTS",
+ "PRODUCT_SOONG_ONLY",
+
// Not used, but useful to be in the soong.log
"TARGET_BUILD_TYPE",
"HOST_ARCH",
@@ -314,4 +316,11 @@
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))
config.SetSourceRootDirs(strings.Fields(makeVars["PRODUCT_SOURCE_ROOT_DIRS"]))
config.SetBuildBrokenMissingOutputs(makeVars["BUILD_BROKEN_MISSING_OUTPUTS"] == "true")
+
+ if !config.skipKatiControlledByFlags {
+ if makeVars["PRODUCT_SOONG_ONLY"] == "true" {
+ config.skipKati = true
+ config.skipKatiNinja = true
+ }
+ }
}
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index b0c9c07..1d4285f 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -76,7 +76,7 @@
//"--frontend-file", fifo,
}
default:
- // NINJA_NINJA is the default.
+ // NINJA_NINJA or NINJA_NINJAGO.
executable = config.NinjaBin()
args = []string{
"-d", "keepdepfile",
@@ -351,12 +351,18 @@
}
// Constructs and runs the Ninja command line to get the inputs of a goal.
-// For now, this will always run ninja, because ninjago, n2 and siso don't have the
+// For n2 and siso, this will always run ninja, because they don't have the
// `-t inputs` command. This command will use the inputs command's -d option,
// to use the dep file iff ninja was the executor. For other executors, the
// results will be wrong.
func runNinjaInputs(ctx Context, config Config, goal string) ([]string, error) {
- executable := config.PrebuiltBuildTool("ninja")
+ var executable string
+ switch config.ninjaCommand {
+ case NINJA_N2, NINJA_SISO:
+ executable = config.PrebuiltBuildTool("ninja")
+ default:
+ executable = config.NinjaBin()
+ }
args := []string{
"-f",