Merge "Add compliance metadata of crt libs and header libs of cc modules" into main
diff --git a/android/variable.go b/android/variable.go
index d5b731a..08bcedf 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -654,6 +654,10 @@
BoardSuperPartitionGroups map[string]BoardSuperPartitionGroupProps `json:",omitempty"`
ProductVirtualAbOta bool `json:",omitempty"`
ProductVirtualAbOtaRetrofit bool `json:",omitempty"`
+ ProductVirtualAbCompression bool `json:",omitempty"`
+ ProductVirtualAbCompressionMethod string `json:",omitempty"`
+ ProductVirtualAbCompressionFactor string `json:",omitempty"`
+ ProductVirtualAbCowVersion string `json:",omitempty"`
AbOtaUpdater bool `json:",omitempty"`
// Avb (android verified boot) stuff
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index e340602..eb2e036 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -68,6 +68,8 @@
// one will be determined based on the lunch product. TODO: Figure out how to make this
// blueprint:"mutated" and still set it from filesystem_creator
Main_device *bool
+
+ Ab_ota_updater *bool
}
type androidDevice struct {
@@ -94,9 +96,13 @@
type superPartitionDepTagType struct {
blueprint.BaseDependencyTag
}
+type targetFilesMetadataDepTagType struct {
+ blueprint.BaseDependencyTag
+}
var superPartitionDepTag superPartitionDepTagType
var filesystemDepTag partitionDepTagType
+var targetFilesMetadataDepTag targetFilesMetadataDepTagType
func (a *androidDevice) DepsMutator(ctx android.BottomUpMutatorContext) {
addDependencyIfDefined := func(dep *string) {
@@ -124,6 +130,11 @@
for _, vbmetaPartition := range a.partitionProps.Vbmeta_partitions {
ctx.AddDependency(ctx.Module(), filesystemDepTag, vbmetaPartition)
}
+ a.addDepsForTargetFilesMetadata(ctx)
+}
+
+func (a *androidDevice) addDepsForTargetFilesMetadata(ctx android.BottomUpMutatorContext) {
+ ctx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), targetFilesMetadataDepTag, "liblz4") // host variant
}
func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -326,6 +337,7 @@
}
a.copyImagesToTargetZip(ctx, builder, targetFilesDir)
+ a.copyMetadataToTargetZip(ctx, builder, targetFilesDir)
builder.Command().
BuiltTool("soong_zip").
@@ -373,6 +385,19 @@
}
}
+func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath) {
+ // Create a META/ subdirectory
+ builder.Command().Textf("mkdir -p %s/META", targetFilesDir.String())
+ if proptools.Bool(a.deviceProps.Ab_ota_updater) {
+ ctx.VisitDirectDepsProxyWithTag(targetFilesMetadataDepTag, func(child android.ModuleProxy) {
+ info, _ := android.OtherModuleProvider(ctx, child, android.OutputFilesProvider)
+ builder.Command().Textf("cp").Inputs(info.DefaultOutputFiles).Textf(" %s/META/", targetFilesDir.String())
+ })
+ }
+ builder.Command().Textf("cp").Input(android.PathForSource(ctx, "external/zucchini/version_info.h")).Textf(" %s/META/zucchini_config.txt", targetFilesDir.String())
+ builder.Command().Textf("cp").Input(android.PathForSource(ctx, "system/update_engine/update_engine.conf")).Textf(" %s/META/update_engine_config.txt", targetFilesDir.String())
+}
+
func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName string) FilesystemInfo {
fsMod := ctx.GetDirectDepProxyWithTag(depName, filesystemDepTag)
fsInfo, ok := android.OtherModuleProvider(ctx, fsMod, FilesystemProvider)
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 306710c..ad19cc6 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -173,12 +173,6 @@
// Mount point for this image. Default is "/"
Mount_point *string
- // If set to the name of a partition ("system", "vendor", etc), this filesystem module
- // will also include the contents of the make-built staging directories. If any soong
- // modules would be installed to the same location as a make module, they will overwrite
- // 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
@@ -470,18 +464,34 @@
ctx.PropertyErrorf("include_files_of", "include_files_of is only supported for cpio and compressed cpio filesystem types.")
}
- var rootDir android.OutputPath
- var rebasedDir android.OutputPath
+ rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
+ rebasedDir := rootDir
+ if f.properties.Base_dir != nil {
+ rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
+ }
+ builder := android.NewRuleBuilder(pctx, ctx)
+
+ // Wipe the root dir to get rid of leftover files from prior builds
+ builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
+ specs := f.gatherFilteredPackagingSpecs(ctx)
+ f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
+
+ f.buildNonDepsFiles(ctx, builder, rootDir)
+ f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
+ f.buildEventLogtagsFile(ctx, builder, rebasedDir)
+ f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
+ f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir)
+
var mapFile android.Path
var outputHermetic android.Path
switch f.fsType(ctx) {
case ext4Type, erofsType, f2fsType:
- f.output, outputHermetic, rootDir, rebasedDir = f.buildImageUsingBuildImage(ctx)
+ f.output, outputHermetic = f.buildImageUsingBuildImage(ctx, builder, rootDir, rebasedDir)
mapFile = f.getMapFile(ctx)
case compressedCpioType:
- f.output, rootDir, rebasedDir = f.buildCpioImage(ctx, true)
+ f.output = f.buildCpioImage(ctx, builder, rootDir, true)
case cpioType:
- f.output, rootDir, rebasedDir = f.buildCpioImage(ctx, false)
+ f.output = f.buildCpioImage(ctx, builder, rootDir, false)
default:
return
}
@@ -655,25 +665,12 @@
return f.partitionName()
}
-func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (android.Path, android.Path, android.OutputPath, android.OutputPath) {
- rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
- rebasedDir := rootDir
- if f.properties.Base_dir != nil {
- rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
- }
- builder := android.NewRuleBuilder(pctx, ctx)
- // Wipe the root dir to get rid of leftover files from prior builds
- builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
- specs := f.gatherFilteredPackagingSpecs(ctx)
- f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
-
- f.buildNonDepsFiles(ctx, builder, rootDir)
- f.addMakeBuiltFiles(ctx, builder, rootDir)
- f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
- f.buildEventLogtagsFile(ctx, builder, rebasedDir)
- f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
- f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir)
-
+func (f *filesystem) buildImageUsingBuildImage(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rootDir android.OutputPath,
+ rebasedDir android.OutputPath,
+) (android.Path, android.Path) {
// run host_init_verifier
// Ideally we should have a concept of pluggable linters that verify the generated image.
// While such concept is not implement this will do.
@@ -724,7 +721,7 @@
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
- return output, outputHermetic, rootDir, rebasedDir
+ return output, outputHermetic
}
func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path {
@@ -918,7 +915,12 @@
return rootDirs, partitions
}
-func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) (android.Path, android.OutputPath, android.OutputPath) {
+func (f *filesystem) buildCpioImage(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rootDir android.OutputPath,
+ compressed bool,
+) android.Path {
if proptools.Bool(f.properties.Use_avb) {
ctx.PropertyErrorf("use_avb", "signing compresed cpio image using avbtool is not supported."+
"Consider adding this to bootimg module and signing the entire boot image.")
@@ -928,27 +930,6 @@
ctx.PropertyErrorf("file_contexts", "file_contexts is not supported for compressed cpio image.")
}
- if f.properties.Include_make_built_files != "" {
- ctx.PropertyErrorf("include_make_built_files", "include_make_built_files is not supported for compressed cpio image.")
- }
-
- rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
- rebasedDir := rootDir
- if f.properties.Base_dir != nil {
- rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
- }
- builder := android.NewRuleBuilder(pctx, ctx)
- // Wipe the root dir to get rid of leftover files from prior builds
- builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
- specs := f.gatherFilteredPackagingSpecs(ctx)
- f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
-
- f.buildNonDepsFiles(ctx, builder, rootDir)
- f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
- f.buildEventLogtagsFile(ctx, builder, rebasedDir)
- f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
- f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir)
-
rootDirs, partitions := includeFilesRootDir(ctx)
output := android.PathForModuleOut(ctx, f.installFileName())
@@ -978,7 +959,7 @@
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_cpio_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
- return output, rootDir, rebasedDir
+ return output
}
var validPartitions = []string{
@@ -998,27 +979,6 @@
"recovery",
}
-func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.Path) {
- partition := f.properties.Include_make_built_files
- if partition == "" {
- return
- }
- if !slices.Contains(validPartitions, partition) {
- ctx.PropertyErrorf("include_make_built_files", "Expected one of %#v, found %q", validPartitions, partition)
- return
- }
- stampFile := fmt.Sprintf("target/product/%s/obj/PACKAGING/%s_intermediates/staging_dir.stamp", ctx.Config().DeviceName(), partition)
- fileListFile := fmt.Sprintf("target/product/%s/obj/PACKAGING/%s_intermediates/file_list.txt", ctx.Config().DeviceName(), partition)
- stagingDir := fmt.Sprintf("target/product/%s/%s", ctx.Config().DeviceName(), partition)
-
- builder.Command().BuiltTool("merge_directories").
- Implicit(android.PathForArbitraryOutput(ctx, stampFile)).
- Text("--ignore-duplicates").
- FlagWithInput("--file-list", android.PathForArbitraryOutput(ctx, fileListFile)).
- Text(rootDir.String()).
- 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
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 47d06f6..d9bf242 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -136,22 +136,6 @@
}
}
-func TestIncludeMakeBuiltFiles(t *testing.T) {
- result := fixture.RunTestWithBp(t, `
- android_filesystem {
- name: "myfilesystem",
- include_make_built_files: "system",
- }
- `)
-
- output := result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img")
-
- stampFile := "out/target/product/test_device/obj/PACKAGING/system_intermediates/staging_dir.stamp"
- fileListFile := "out/target/product/test_device/obj/PACKAGING/system_intermediates/file_list.txt"
- android.AssertStringListContains(t, "deps of filesystem must include the staging dir stamp file", output.Implicits.Strings(), stampFile)
- android.AssertStringListContains(t, "deps of filesystem must include the staging dir file list", output.Implicits.Strings(), fileListFile)
-}
-
func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) {
result := fixture.RunTestWithBp(t, `
android_system_image {
diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go
index 91b8c57..c3f1936 100644
--- a/filesystem/fsverity_metadata.go
+++ b/filesystem/fsverity_metadata.go
@@ -20,6 +20,8 @@
"strings"
"android/soong/android"
+
+ "github.com/google/blueprint/proptools"
)
type fsverityProperties struct {
@@ -27,10 +29,10 @@
// will be generated and included to the filesystem image.
// etc/security/fsverity/BuildManifest.apk will also be generated which contains information
// about generated .fsv_meta files.
- Inputs []string
+ Inputs proptools.Configurable[[]string]
// APK libraries to link against, for etc/security/fsverity/BuildManifest.apk
- Libs []string `android:"path"`
+ Libs proptools.Configurable[[]string] `android:"path"`
}
func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, outputPath android.WritablePath, matchedSpecs []android.PackagingSpec, rebasedDir android.OutputPath) {
@@ -44,7 +46,7 @@
func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir android.OutputPath, rebasedDir android.OutputPath) {
match := func(path string) bool {
- for _, pattern := range f.properties.Fsverity.Inputs {
+ for _, pattern := range f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) {
if matched, err := filepath.Match(pattern, path); matched {
return true
} else if err != nil {
@@ -124,7 +126,7 @@
apkPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", fmt.Sprintf("BuildManifest%s.apk", apkNameSuffix))
idsigPath := rebasedDir.Join(ctx, "etc", "security", "fsverity", fmt.Sprintf("BuildManifest%s.apk.idsig", apkNameSuffix))
manifestTemplatePath := android.PathForSource(ctx, "system/security/fsverity/AndroidManifest.xml")
- libs := android.PathsForModuleSrc(ctx, f.properties.Fsverity.Libs)
+ libs := android.PathsForModuleSrc(ctx, f.properties.Fsverity.Libs.GetOrDefault(ctx, nil))
minSdkVersion := ctx.Config().PlatformSdkCodename()
if minSdkVersion == "REL" {
diff --git a/filesystem/super_image.go b/filesystem/super_image.go
index d8c7345..4419a2f 100644
--- a/filesystem/super_image.go
+++ b/filesystem/super_image.go
@@ -17,6 +17,7 @@
import (
"fmt"
"path/filepath"
+ "regexp"
"strconv"
"strings"
@@ -50,16 +51,29 @@
Ab_update *bool
// whether dynamic partitions is enabled on devices that were launched without this support
Retrofit *bool
- // whether virtual A/B seamless update is enabled
- Virtual_ab *bool
- // whether retrofitting virtual A/B seamless update is enabled
- Virtual_ab_retrofit *bool
// whether the output is a sparse image
Sparse *bool
// information about how partitions within the super partition are grouped together
Partition_groups []PartitionGroupsInfo
// whether dynamic partitions is used
Use_dynamic_partitions *bool
+ Virtual_ab struct {
+ // whether virtual A/B seamless update is enabled
+ Enable *bool
+ // whether retrofitting virtual A/B seamless update is enabled
+ Retrofit *bool
+ // If set, device uses virtual A/B Compression
+ Compression *bool
+ // This value controls the compression algorithm used for VABC.
+ // Valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
+ // e.g. "none", "gz", "brotli"
+ Compression_method *string
+ // Specifies maximum bytes to be compressed at once during ota. Options: 4096, 8192, 16384, 32768, 65536, 131072, 262144.
+ Compression_factor *int64
+ // Specifies COW version to be used by update_engine and libsnapshot. If this value is not
+ // specified we default to COW version 2 in update_engine for backwards compatibility
+ Cow_version *int64
+ }
}
type PartitionGroupsInfo struct {
@@ -166,13 +180,18 @@
miscInfoString.WriteRune('\n')
}
+ addStr("build_super_partition", "true")
addStr("use_dynamic_partitions", strconv.FormatBool(proptools.Bool(s.properties.Use_dynamic_partitions)))
- addStr("dynamic_partition_retrofit", strconv.FormatBool(proptools.Bool(s.properties.Retrofit)))
+ if proptools.Bool(s.properties.Retrofit) {
+ addStr("dynamic_partition_retrofit", "true")
+ }
addStr("lpmake", "lpmake")
addStr("super_metadata_device", proptools.String(s.properties.Metadata_device))
if len(s.properties.Block_devices) > 0 {
addStr("super_block_devices", strings.Join(s.properties.Block_devices, " "))
}
+ addStr("super_partition_size", strconv.Itoa(proptools.Int(s.properties.Size)))
+ // TODO: In make, there's more complicated logic than just this surrounding super_*_device_size
addStr("super_super_device_size", strconv.Itoa(proptools.Int(s.properties.Size)))
var groups, partitionList []string
for _, groupInfo := range s.properties.Partition_groups {
@@ -189,10 +208,42 @@
addStr("super_partition_groups", strings.Join(groups, " "))
addStr("dynamic_partition_list", strings.Join(partitionList, " "))
- addStr("virtual_ab", strconv.FormatBool(proptools.Bool(s.properties.Virtual_ab)))
- addStr("virtual_ab_retrofit", strconv.FormatBool(proptools.Bool(s.properties.Virtual_ab_retrofit)))
addStr("ab_update", strconv.FormatBool(proptools.Bool(s.properties.Ab_update)))
- addStr("build_non_sparse_super_partition", strconv.FormatBool(!proptools.Bool(s.properties.Sparse)))
+
+ if proptools.Bool(s.properties.Virtual_ab.Enable) {
+ addStr("virtual_ab", "true")
+ if proptools.Bool(s.properties.Virtual_ab.Retrofit) {
+ addStr("virtual_ab_retrofit", "true")
+ }
+ addStr("virtual_ab_compression", strconv.FormatBool(proptools.Bool(s.properties.Virtual_ab.Compression)))
+ if s.properties.Virtual_ab.Compression_method != nil {
+ matched, _ := regexp.MatchString("^[a-zA-Z0-9_-]+$", *s.properties.Virtual_ab.Compression_method)
+ if !matched {
+ ctx.PropertyErrorf("virtual_ab.compression_method", "compression_method cannot have special characters")
+ }
+ addStr("virtual_ab_compression_method", *s.properties.Virtual_ab.Compression_method)
+ }
+ if s.properties.Virtual_ab.Compression_factor != nil {
+ addStr("virtual_ab_compression_factor", strconv.FormatInt(*s.properties.Virtual_ab.Compression_factor, 10))
+ }
+ if s.properties.Virtual_ab.Cow_version != nil {
+ addStr("virtual_ab_cow_version", strconv.FormatInt(*s.properties.Virtual_ab.Cow_version, 10))
+ }
+
+ } else {
+ if s.properties.Virtual_ab.Retrofit != nil {
+ ctx.PropertyErrorf("virtual_ab.retrofit", "This property cannot be set when virtual_ab is disabled")
+ }
+ if s.properties.Virtual_ab.Compression != nil {
+ ctx.PropertyErrorf("virtual_ab.compression", "This property cannot be set when virtual_ab is disabled")
+ }
+ if s.properties.Virtual_ab.Compression_method != nil {
+ ctx.PropertyErrorf("virtual_ab.compression_method", "This property cannot be set when virtual_ab is disabled")
+ }
+ if s.properties.Virtual_ab.Compression_factor != nil {
+ ctx.PropertyErrorf("virtual_ab.compression_factor", "This property cannot be set when virtual_ab is disabled")
+ }
+ }
subImageInfo := make(map[string]FilesystemInfo)
var deps android.Paths
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index fb76687..b7f312c 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -173,13 +173,14 @@
algorithm := proptools.StringDefault(v.properties.Algorithm, "SHA256_RSA4096")
cmd.FlagWithArg("--algorithm ", algorithm)
+ cmd.FlagWithArg("--padding_size ", "4096")
+
cmd.FlagWithArg("--rollback_index ", v.rollbackIndexCommand(ctx))
ril := proptools.IntDefault(v.properties.Rollback_index_location, 0)
if ril < 0 {
ctx.PropertyErrorf("rollback_index_location", "must be 0, 1, 2, ...")
return
}
- cmd.FlagWithArg("--rollback_index_location ", strconv.Itoa(ril))
for _, avb_prop := range v.properties.Avb_properties {
key := proptools.String(avb_prop.Key)
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index fbe9078..7f5a068 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -264,7 +264,8 @@
partitionProps.Vbmeta_partitions = vbmetaPartitions
deviceProps := &filesystem.DeviceProperties{
- Main_device: proptools.BoolPtr(true),
+ Main_device: proptools.BoolPtr(true),
+ Ab_ota_updater: proptools.BoolPtr(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaUpdater),
}
if bootloader, ok := f.createBootloaderFilegroup(ctx); ok {
deviceProps.Bootloader = proptools.StringPtr(":" + bootloader)
@@ -281,7 +282,7 @@
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
// Identical to that of the aosp_shared_system_image
if partitionVars.ProductFsverityGenerateMetadata {
- fsProps.Fsverity.Inputs = []string{
+ fsProps.Fsverity.Inputs = proptools.NewSimpleConfigurable([]string{
"etc/boot-image.prof",
"etc/dirty-image-objects",
"etc/preloaded-classes",
@@ -289,8 +290,8 @@
"framework/*",
"framework/*/*", // framework/{arch}
"framework/oat/*/*", // framework/oat/{arch}
- }
- fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
+ })
+ fsProps.Fsverity.Libs = proptools.NewSimpleConfigurable([]string{":framework-res{.export-package.apk}"})
}
fsProps.Symlinks = commonSymlinksFromRoot
fsProps.Symlinks = append(fsProps.Symlinks,
@@ -331,12 +332,12 @@
fsProps.Stem = proptools.StringPtr("system.img")
case "system_ext":
if partitionVars.ProductFsverityGenerateMetadata {
- fsProps.Fsverity.Inputs = []string{
+ fsProps.Fsverity.Inputs = proptools.NewSimpleConfigurable([]string{
"framework/*",
"framework/*/*", // framework/{arch}
"framework/oat/*/*", // framework/oat/{arch}
- }
- fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
+ })
+ fsProps.Fsverity.Libs = proptools.NewSimpleConfigurable([]string{":framework-res{.export-package.apk}"})
}
fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
fsProps.Stem = proptools.StringPtr("system_ext.img")
diff --git a/fsgen/super_img.go b/fsgen/super_img.go
index 5994fb6..5c23868 100644
--- a/fsgen/super_img.go
+++ b/fsgen/super_img.go
@@ -39,10 +39,30 @@
Block_devices: partitionVars.BoardSuperPartitionBlockDevices,
Ab_update: proptools.BoolPtr(partitionVars.AbOtaUpdater),
Retrofit: proptools.BoolPtr(partitionVars.ProductRetrofitDynamicPartitions),
- Virtual_ab: proptools.BoolPtr(partitionVars.ProductVirtualAbOta),
- Virtual_ab_retrofit: proptools.BoolPtr(partitionVars.ProductVirtualAbOtaRetrofit),
Use_dynamic_partitions: proptools.BoolPtr(partitionVars.ProductUseDynamicPartitions),
}
+ if partitionVars.ProductVirtualAbOta {
+ superImageProps.Virtual_ab.Enable = proptools.BoolPtr(true)
+ superImageProps.Virtual_ab.Retrofit = proptools.BoolPtr(partitionVars.ProductVirtualAbOtaRetrofit)
+ superImageProps.Virtual_ab.Compression = proptools.BoolPtr(partitionVars.ProductVirtualAbCompression)
+ if partitionVars.ProductVirtualAbCompressionMethod != "" {
+ superImageProps.Virtual_ab.Compression_method = proptools.StringPtr(partitionVars.ProductVirtualAbCompressionMethod)
+ }
+ if partitionVars.ProductVirtualAbCompressionFactor != "" {
+ factor, err := strconv.ParseInt(partitionVars.ProductVirtualAbCompressionFactor, 10, 32)
+ if err != nil {
+ ctx.ModuleErrorf("Compression factor must be an int, got %q", partitionVars.ProductVirtualAbCompressionFactor)
+ }
+ superImageProps.Virtual_ab.Compression_factor = proptools.Int64Ptr(factor)
+ }
+ if partitionVars.ProductVirtualAbCowVersion != "" {
+ version, err := strconv.ParseInt(partitionVars.ProductVirtualAbCowVersion, 10, 32)
+ if err != nil {
+ ctx.ModuleErrorf("COW version must be an int, got %q", partitionVars.ProductVirtualAbCowVersion)
+ }
+ superImageProps.Virtual_ab.Cow_version = proptools.Int64Ptr(version)
+ }
+ }
size, _ := strconv.ParseInt(partitionVars.BoardSuperPartitionSize, 10, 64)
superImageProps.Size = proptools.Int64Ptr(size)
sparse := !partitionVars.TargetUserimagesSparseExtDisabled && !partitionVars.TargetUserimagesSparseF2fsDisabled
diff --git a/java/aar.go b/java/aar.go
index b982b95..3479f93 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1040,7 +1040,7 @@
}
prebuiltJniPackages := android.Paths{}
- ctx.VisitDirectDeps(func(module android.Module) {
+ ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) {
if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok {
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
diff --git a/java/app.go b/java/app.go
index f4c658c..34a172e 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1171,6 +1171,9 @@
seenModulePaths := make(map[string]bool)
ctx.WalkDepsProxy(func(module, parent android.ModuleProxy) bool {
+ if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled {
+ return false
+ }
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
diff --git a/java/app_import.go b/java/app_import.go
index b77e31a..a997e35 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -67,6 +67,13 @@
Command: "unzip -p $in $extract_apk > $out",
Description: "Extract specific sub apk",
}, "extract_apk")
+
+ gzipRule = pctx.AndroidStaticRule("gzip",
+ blueprint.RuleParams{
+ Command: "prebuilts/build-tools/path/linux-x86/gzip -9 -c $in > $out",
+ CommandDeps: []string{"prebuilts/build-tools/path/linux-x86/gzip"},
+ Description: "gzip $out",
+ })
)
func RegisterAppImportBuildComponents(ctx android.RegistrationContext) {
@@ -171,6 +178,9 @@
// Path of extracted apk which is extracted from prebuilt apk. Use this extracted to import.
Extract_apk *string
+
+ // Compress the output APK using gzip. Defaults to false.
+ Compress_apk proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
}
func (a *AndroidAppImport) IsInstallable() bool {
@@ -427,7 +437,9 @@
a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries(ctx)
a.dexpreopter.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
- if a.usesLibrary.shouldDisableDexpreopt {
+
+ // Disable Dexpreopt if Compress_apk is true. It follows the build/make/core/app_prebuilt_internal.mk
+ if a.usesLibrary.shouldDisableDexpreopt || a.properties.Compress_apk.GetOrDefault(ctx, false) {
a.dexpreopter.disableDexpreopt()
}
@@ -446,7 +458,13 @@
jnisUncompressed = dexUncompressed
}
- apkFilename := proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+".apk")
+ defaultApkFilename := a.BaseModuleName()
+ if a.properties.Compress_apk.GetOrDefault(ctx, false) {
+ defaultApkFilename += ".apk.gz"
+ } else {
+ defaultApkFilename += ".apk"
+ }
+ apkFilename := proptools.StringDefault(a.properties.Filename, defaultApkFilename)
// TODO: Handle EXTERNAL
@@ -486,7 +504,16 @@
a.certificate = PresignedCertificate
}
- // TODO: Optionally compress the output apk.
+ if a.properties.Compress_apk.GetOrDefault(ctx, false) {
+ outputFile := android.PathForModuleOut(ctx, "compressed_apk", apkFilename)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: gzipRule,
+ Input: a.outputFile,
+ Output: outputFile,
+ Description: "Compressing " + a.outputFile.Base(),
+ })
+ a.outputFile = outputFile
+ }
if apexInfo.IsForPlatform() {
a.installPath = ctx.InstallFile(installDir, apkFilename, a.outputFile)
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 408d376..a28c28b 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -325,10 +325,25 @@
}
android_app_import {
+ name: "foo_compressed",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ compress_apk: true,
+ }
+
+ android_app_import {
name: "bar",
apk: "prebuilts/apk/app.apk",
presigned: true,
- filename: "bar_sample.apk"
+ filename: "bar_sample.apk",
+ }
+
+ android_app_import {
+ name: "compressed_bar",
+ apk: "prebuilts/apk/app.apk",
+ presigned: true,
+ filename: "bar_sample.apk",
+ compress_apk: true,
}
`)
@@ -347,12 +362,26 @@
expectedMetaDataPath: "out/soong/.intermediates/provenance_metadata/foo/provenance_metadata.textproto",
},
{
+ name: "foo_compressed",
+ expected: "foo_compressed.apk.gz",
+ onDevice: "/system/app/foo_compressed/foo_compressed.apk.gz",
+ expectedArtifactPath: "prebuilts/apk/app.apk",
+ expectedMetaDataPath: "out/soong/.intermediates/provenance_metadata/foo_compressed/provenance_metadata.textproto",
+ },
+ {
name: "bar",
expected: "bar_sample.apk",
onDevice: "/system/app/bar/bar_sample.apk",
expectedArtifactPath: "prebuilts/apk/app.apk",
expectedMetaDataPath: "out/soong/.intermediates/provenance_metadata/bar/provenance_metadata.textproto",
},
+ {
+ name: "compressed_bar",
+ expected: "bar_sample.apk",
+ onDevice: "/system/app/compressed_bar/bar_sample.apk",
+ expectedArtifactPath: "prebuilts/apk/app.apk",
+ expectedMetaDataPath: "out/soong/.intermediates/provenance_metadata/compressed_bar/provenance_metadata.textproto",
+ },
}
for _, test := range testCases {
diff --git a/java/base.go b/java/base.go
index 8e013b9..0b896d8 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1978,7 +1978,7 @@
}
func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []depset.DepSet[android.Path]) {
- ctx.VisitDirectDeps(func(m android.Module) {
+ ctx.VisitDirectDepsProxy(func(m android.ModuleProxy) {
depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
depTag := ctx.OtherModuleDependencyTag(m)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 49674b9..225f201 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -19,6 +19,7 @@
"path/filepath"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -874,6 +875,13 @@
Path *string
}
+type ExportedDroiddocDirInfo struct {
+ Deps android.Paths
+ Dir android.Path
+}
+
+var ExportedDroiddocDirInfoProvider = blueprint.NewProvider[ExportedDroiddocDirInfo]()
+
type ExportedDroiddocDir struct {
android.ModuleBase
@@ -897,6 +905,11 @@
path := String(d.properties.Path)
d.dir = android.PathForModuleSrc(ctx, path)
d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
+
+ android.SetProvider(ctx, ExportedDroiddocDirInfoProvider, ExportedDroiddocDirInfo{
+ Dir: d.dir,
+ Deps: d.deps,
+ })
}
// Defaults
diff --git a/java/droidstubs.go b/java/droidstubs.go
index fa1fb86..ac1a007 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -20,6 +20,7 @@
"regexp"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -27,6 +28,18 @@
"android/soong/remoteexec"
)
+type StubsArtifactsInfo struct {
+ ApiVersionsXml android.WritablePath
+}
+
+type DroidStubsInfo struct {
+ CurrentApiTimestamp android.Path
+ EverythingArtifacts StubsArtifactsInfo
+ ExportableArtifacts StubsArtifactsInfo
+}
+
+var DroidStubsInfoProvider = blueprint.NewProvider[DroidStubsInfo]()
+
// The values allowed for Droidstubs' Api_levels_sdk_type
var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"}
@@ -498,9 +511,9 @@
}
func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
- ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) {
- if t, ok := m.(*ExportedDroiddocDir); ok {
- cmd.FlagWithArg("--merge-qualifier-annotations ", t.dir.String()).Implicits(t.deps)
+ ctx.VisitDirectDepsProxyWithTag(metalavaMergeAnnotationsDirTag, func(m android.ModuleProxy) {
+ if t, ok := android.OtherModuleProvider(ctx, m, ExportedDroiddocDirInfoProvider); ok {
+ cmd.FlagWithArg("--merge-qualifier-annotations ", t.Dir.String()).Implicits(t.Deps)
} else {
ctx.PropertyErrorf("merge_annotations_dirs",
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
@@ -509,9 +522,9 @@
}
func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
- ctx.VisitDirectDepsWithTag(metalavaMergeInclusionAnnotationsDirTag, func(m android.Module) {
- if t, ok := m.(*ExportedDroiddocDir); ok {
- cmd.FlagWithArg("--merge-inclusion-annotations ", t.dir.String()).Implicits(t.deps)
+ ctx.VisitDirectDepsProxyWithTag(metalavaMergeInclusionAnnotationsDirTag, func(m android.ModuleProxy) {
+ if t, ok := android.OtherModuleProvider(ctx, m, ExportedDroiddocDirInfoProvider); ok {
+ cmd.FlagWithArg("--merge-inclusion-annotations ", t.Dir.String()).Implicits(t.Deps)
} else {
ctx.PropertyErrorf("merge_inclusion_annotations_dirs",
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
@@ -525,12 +538,12 @@
d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
apiVersions = apiVersionsXml
} else {
- ctx.VisitDirectDepsWithTag(metalavaAPILevelsModuleTag, func(m android.Module) {
- if s, ok := m.(*Droidstubs); ok {
+ ctx.VisitDirectDepsProxyWithTag(metalavaAPILevelsModuleTag, func(m android.ModuleProxy) {
+ if s, ok := android.OtherModuleProvider(ctx, m, DroidStubsInfoProvider); ok {
if stubsType == Everything {
- apiVersions = s.everythingArtifacts.apiVersionsXml
+ apiVersions = s.EverythingArtifacts.ApiVersionsXml
} else if stubsType == Exportable {
- apiVersions = s.exportableArtifacts.apiVersionsXml
+ apiVersions = s.ExportableArtifacts.ApiVersionsXml
} else {
ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String())
}
@@ -603,18 +616,18 @@
var dirs []string
var extensions_dir string
- ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
- if t, ok := m.(*ExportedDroiddocDir); ok {
- extRegex := regexp.MustCompile(t.dir.String() + extensionsPattern)
+ ctx.VisitDirectDepsProxyWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.ModuleProxy) {
+ if t, ok := android.OtherModuleProvider(ctx, m, ExportedDroiddocDirInfoProvider); ok {
+ extRegex := regexp.MustCompile(t.Dir.String() + extensionsPattern)
// Grab the first extensions_dir and we find while scanning ExportedDroiddocDir.deps;
// ideally this should be read from prebuiltApis.properties.Extensions_*
- for _, dep := range t.deps {
+ for _, dep := range t.Deps {
// Check to see if it matches an extension first.
depBase := dep.Base()
if extRegex.MatchString(dep.String()) && d.properties.Extensions_info_file != nil {
if extensions_dir == "" {
- extensions_dir = t.dir.String() + "/extensions"
+ extensions_dir = t.Dir.String() + "/extensions"
}
cmd.Implicit(dep)
} else if depBase == filename {
@@ -638,7 +651,7 @@
}
}
- dirs = append(dirs, t.dir.String())
+ dirs = append(dirs, t.Dir.String())
} else {
ctx.PropertyErrorf("api_levels_annotations_dirs",
"module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m))
@@ -1340,6 +1353,16 @@
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
+ android.SetProvider(ctx, DroidStubsInfoProvider, DroidStubsInfo{
+ CurrentApiTimestamp: d.CurrentApiTimestamp(),
+ EverythingArtifacts: StubsArtifactsInfo{
+ ApiVersionsXml: d.everythingArtifacts.apiVersionsXml,
+ },
+ ExportableArtifacts: StubsArtifactsInfo{
+ ApiVersionsXml: d.exportableArtifacts.apiVersionsXml,
+ },
+ })
+
d.setOutputFiles(ctx)
}
diff --git a/java/java.go b/java/java.go
index 0a9381d..b2d8b72 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1958,13 +1958,13 @@
// Set the jniLibs of this binary.
// These will be added to `LOCAL_REQUIRED_MODULES`, and the kati packaging system will
// install these alongside the java binary.
- ctx.VisitDirectDepsWithTag(jniInstallTag, func(jni android.Module) {
+ ctx.VisitDirectDepsProxyWithTag(jniInstallTag, func(jni android.ModuleProxy) {
// Use the BaseModuleName of the dependency (without any prebuilt_ prefix)
- bmn, _ := jni.(interface{ BaseModuleName() string })
- j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, bmn.BaseModuleName()+":"+jni.Target().Arch.ArchType.Bitness())
+ commonInfo, _ := android.OtherModuleProvider(ctx, jni, android.CommonModuleInfoKey)
+ j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, commonInfo.BaseModuleName+":"+commonInfo.Target.Arch.ArchType.Bitness())
})
// Check that native libraries are not listed in `required`. Prompt users to use `jni_libs` instead.
- ctx.VisitDirectDepsWithTag(android.RequiredDepTag, func(dep android.Module) {
+ ctx.VisitDirectDepsProxyWithTag(android.RequiredDepTag, func(dep android.ModuleProxy) {
if _, hasSharedLibraryInfo := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider); hasSharedLibraryInfo {
ctx.ModuleErrorf("cc_library %s is no longer supported in `required` of java_binary modules. Please use jni_libs instead.", dep.Name())
}
@@ -2355,7 +2355,7 @@
var bootclassPaths android.Paths
var staticLibs android.Paths
var systemModulesPaths android.Paths
- ctx.VisitDirectDeps(func(dep android.Module) {
+ ctx.VisitDirectDepsProxy(func(dep android.ModuleProxy) {
tag := ctx.OtherModuleDependencyTag(dep)
switch tag {
case javaApiContributionTag:
@@ -2384,8 +2384,8 @@
systemModulesPaths = append(systemModulesPaths, sm.HeaderJars...)
}
case metalavaCurrentApiTimestampTag:
- if currentApiTimestampProvider, ok := dep.(currentApiTimestampProvider); ok {
- al.validationPaths = append(al.validationPaths, currentApiTimestampProvider.CurrentApiTimestamp())
+ if currentApiTimestampProvider, ok := android.OtherModuleProvider(ctx, dep, DroidStubsInfoProvider); ok {
+ al.validationPaths = append(al.validationPaths, currentApiTimestampProvider.CurrentApiTimestamp)
}
case aconfigDeclarationTag:
if provider, ok := android.OtherModuleProvider(ctx, dep, android.AconfigDeclarationsProviderKey); ok {
diff --git a/java/rro.go b/java/rro.go
index ab4fafa..44d5564 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -139,6 +139,25 @@
r.aapt.hasNoCode = true
// Do not remove resources without default values nor dedupe resource configurations with the same value
aaptLinkFlags := []string{"--no-resource-deduping", "--no-resource-removal"}
+
+ // Add TARGET_AAPT_CHARACTERISTICS values to AAPT link flags if they exist and --product flags were not provided.
+ hasProduct := android.PrefixInList(r.aaptProperties.Aaptflags, "--product")
+ if !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
+ aaptLinkFlags = append(aaptLinkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
+ }
+
+ if !Bool(r.aaptProperties.Aapt_include_all_resources) {
+ // Product AAPT config
+ for _, aaptConfig := range ctx.Config().ProductAAPTConfig() {
+ aaptLinkFlags = append(aaptLinkFlags, "-c", aaptConfig)
+ }
+
+ // Product AAPT preferred config
+ if len(ctx.Config().ProductAAPTPreferredConfig()) > 0 {
+ aaptLinkFlags = append(aaptLinkFlags, "--preferred-density", ctx.Config().ProductAAPTPreferredConfig())
+ }
+ }
+
// Allow the override of "package name" and "overlay target package name"
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
if overridden || r.overridableProperties.Package_name != nil {
diff --git a/scripts/Android.bp b/scripts/Android.bp
index d39c84a..94163a5 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -293,14 +293,6 @@
}
python_binary_host {
- name: "merge_directories",
- main: "merge_directories.py",
- srcs: [
- "merge_directories.py",
- ],
-}
-
-python_binary_host {
name: "merge_json",
main: "merge_json.py",
srcs: [
diff --git a/scripts/merge_directories.py b/scripts/merge_directories.py
deleted file mode 100755
index 3f8631b..0000000
--- a/scripts/merge_directories.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python3
-import argparse
-import os
-import shutil
-import sys
-
-def main():
- parser = argparse.ArgumentParser(
- description="Given a list of directories, this script will copy the contents of all of "
- "them into the first directory, erroring out if any duplicate files are found."
- )
- parser.add_argument(
- "--ignore-duplicates",
- action="store_true",
- help="Don't error out on duplicate files, just skip them. The file from the earliest "
- "directory listed on the command line will be the winner."
- )
- parser.add_argument(
- "--file-list",
- help="Path to a text file containing paths relative to in_dir. Only these paths will be "
- "copied out of in_dir."
- )
- parser.add_argument("out_dir")
- parser.add_argument("in_dir")
- args = parser.parse_args()
-
- if not os.path.isdir(args.out_dir):
- sys.exit(f"error: {args.out_dir} must be a directory")
- if not os.path.isdir(args.in_dir):
- sys.exit(f"error: {args.in_dir} must be a directory")
-
- file_list = None
- if args.file_list:
- with open(file_list_file, "r") as f:
- file_list = f.read().strip().splitlines()
-
- in_dir = args.in_dir
- for root, dirs, files in os.walk(in_dir):
- rel_root = os.path.relpath(root, in_dir)
- dst_root = os.path.join(args.out_dir, rel_root)
- made_parent_dirs = False
- for f in files:
- src = os.path.join(root, f)
- dst = os.path.join(dst_root, f)
- p = os.path.normpath(os.path.join(rel_root, f))
- if file_list is not None and p not in file_list:
- continue
- if os.path.lexists(dst):
- if args.ignore_duplicates:
- continue
- sys.exit(f"error: {p} exists in both {args.out_dir} and {in_dir}")
-
- if not made_parent_dirs:
- os.makedirs(dst_root, exist_ok=True)
- made_parent_dirs = True
-
- shutil.copy2(src, dst, follow_symlinks=False)
-
-if __name__ == "__main__":
- main()