diff options
-rw-r--r-- | android/neverallow.go | 1 | ||||
-rw-r--r-- | cc/config/arm64_device.go | 2 | ||||
-rw-r--r-- | etc/prebuilt_etc.go | 11 | ||||
-rw-r--r-- | filesystem/android_device.go | 25 | ||||
-rw-r--r-- | filesystem/bootimg.go | 41 | ||||
-rw-r--r-- | filesystem/filesystem.go | 80 | ||||
-rw-r--r-- | fsgen/boot_imgs.go | 1 | ||||
-rw-r--r-- | fsgen/prebuilt_etc_modules_gen.go | 1 | ||||
-rw-r--r-- | java/ravenwood.go | 2 | ||||
-rw-r--r-- | java/ravenwood_test.go | 11 | ||||
-rw-r--r-- | java/robolectric.go | 8 | ||||
-rw-r--r-- | java/robolectric_test.go | 11 |
12 files changed, 144 insertions, 50 deletions
diff --git a/android/neverallow.go b/android/neverallow.go index d90186a08..5c90501d7 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -387,6 +387,7 @@ func createPrebuiltEtcBpDefineRule() Rule { "prebuilt_first_stage_ramdisk", "prebuilt_radio", "prebuilt_gpu", + "prebuilt_vendor_overlay", ). DefinedInBpFile(). Because("module type not allowed to be defined in bp file") diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index 0dcf2cfd4..45b15809f 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -44,7 +44,7 @@ var ( // On ARMv9 and later, Pointer Authentication Codes (PAC) are mandatory, // so -fstack-protector is unnecessary. "armv9-a": []string{ - "-march=armv8.2-a+dotprod", + "-march=armv9-a", "-mbranch-protection=standard", "-fno-stack-protector", }, diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index 6b581bcd3..3b0c0329d 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -81,6 +81,7 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory) ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory) ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory) + ctx.RegisterModuleType("prebuilt_vendor_overlay", PrebuiltVendorOverlayFactory) ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory) ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory) ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory) @@ -1079,6 +1080,16 @@ func PrebuiltVendorFactory() android.Module { return module } +// prebuilt_vendor_overlay is for a prebuilt artifact in <partition>/vendor_overlay directory. +func PrebuiltVendorOverlayFactory() android.Module { + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "vendor_overlay") + // This module is device-only + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + android.InitDefaultableModule(module) + return module +} + // prebuilt_sbin installs files in <partition>/sbin directory. func PrebuiltSbinFactory() android.Module { module := &PrebuiltEtc{} diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 45a8620c5..3f6348dbf 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -780,6 +780,31 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo) } + if a.partitionProps.Super_partition_name != nil { + superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag) + if info, ok := android.OtherModuleProvider(ctx, superPartition, SuperImageProvider); ok { + // cat dynamic_partition_info.txt + builder.Command().Text("cat").Input(info.DynamicPartitionsInfo).Textf(" >> %s", miscInfo) + } else { + ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name()) + } + } + bootImgNames := []*string{ + a.partitionProps.Boot_partition_name, + a.partitionProps.Init_boot_partition_name, + a.partitionProps.Vendor_boot_partition_name, + } + for _, bootImgName := range bootImgNames { + if bootImgName == nil { + continue + } + + bootImg := ctx.GetDirectDepProxyWithTag(proptools.String(bootImgName), filesystemDepTag) + bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider) + // cat avb_ metadata of the boot images + builder.Command().Text("cat").Input(bootImgInfo.PropFileForMiscInfo).Textf(" >> %s", miscInfo) + } + builder.Build("misc_info", "Building misc_info") return miscInfo diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index c06c20048..7959365e8 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -238,11 +238,12 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Set BootimgInfo for building target_files.zip dtbPath := b.getDtbPath(ctx) android.SetProvider(ctx, BootimgInfoProvider, BootimgInfo{ - Cmdline: b.properties.Cmdline, - Kernel: kernelPath, - Dtb: dtbPath, - Bootconfig: b.getBootconfigPath(ctx), - Output: output, + Cmdline: b.properties.Cmdline, + Kernel: kernelPath, + Dtb: dtbPath, + Bootconfig: b.getBootconfigPath(ctx), + Output: output, + PropFileForMiscInfo: b.buildPropFileForMiscInfo(ctx), }) extractedPublicKey := android.PathForModuleOut(ctx, b.partitionName()+".avbpubkey") @@ -285,11 +286,12 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { var BootimgInfoProvider = blueprint.NewProvider[BootimgInfo]() type BootimgInfo struct { - Cmdline []string - Kernel android.Path - Dtb android.Path - Bootconfig android.Path - Output android.Path + Cmdline []string + Kernel android.Path + Dtb android.Path + Bootconfig android.Path + Output android.Path + PropFileForMiscInfo android.Path } func (b *bootimg) getKernelPath(ctx android.ModuleContext) android.Path { @@ -508,6 +510,25 @@ func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, androi return propFile, deps } +func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path { + var sb strings.Builder + addStr := func(name string, value string) { + fmt.Fprintf(&sb, "%s=%s\n", name, value) + } + + bootImgType := proptools.String(b.properties.Boot_image_type) + addStr("avb_"+bootImgType+"_add_hash_footer_args", "TODO(b/398036609)") + if b.properties.Avb_private_key != nil { + addStr("avb_"+bootImgType+"_algorithm", proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096")) + addStr("avb_"+bootImgType+"_key_path", android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)).String()) + addStr("avb_"+bootImgType+"_rollback_index_location", strconv.Itoa(proptools.Int(b.properties.Avb_rollback_index_location))) + } + + propFile := android.PathForModuleOut(ctx, "prop_for_misc_info") + android.WriteFileRuleVerbatim(ctx, propFile, sb.String()) + return propFile +} + var _ android.AndroidMkEntriesProvider = (*bootimg)(nil) // Implements android.AndroidMkEntriesProvider diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index d5188d7c2..e44f2722e 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -375,6 +375,20 @@ func (fs fsType) IsUnknown() bool { return fs == unknown } +// Type string that build_image.py accepts. +func (t fsType) String() string { + switch t { + // TODO(372522486): add more types like f2fs, erofs, etc. + case ext4Type: + return "ext4" + case erofsType: + return "erofs" + case f2fsType: + return "f2fs" + } + panic(fmt.Errorf("unsupported fs type %d", t)) +} + type InstalledFilesStruct struct { Txt android.Path Json android.Path @@ -1031,21 +1045,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and deps = append(deps, path) } - // Type string that build_image.py accepts. - fsTypeStr := func(t fsType) string { - switch t { - // TODO(372522486): add more types like f2fs, erofs, etc. - case ext4Type: - return "ext4" - case erofsType: - return "erofs" - case f2fsType: - return "f2fs" - } - panic(fmt.Errorf("unsupported fs type %v", t)) - } - - addStr("fs_type", fsTypeStr(f.fsType(ctx))) + addStr("fs_type", f.fsType(ctx).String()) addStr("mount_point", proptools.StringDefault(f.properties.Mount_point, "/")) addStr("use_dynamic_partition_size", "true") addPath("ext_mkuserimg", ctx.Config().HostToolPath(ctx, "mkuserimg_mke2fs")) @@ -1064,28 +1064,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and addPath("avb_key_path", key) } addStr("partition_name", f.partitionName()) - avb_add_hashtree_footer_args := "" - if !proptools.BoolDefault(f.properties.Use_fec, true) { - avb_add_hashtree_footer_args += " --do_not_generate_fec" - } - hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256") - avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm - if f.properties.Rollback_index != nil { - rollbackIndex := proptools.Int(f.properties.Rollback_index) - if rollbackIndex < 0 { - ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative") - } - avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex) - } - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable()) - // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because - // the build number changed, and we don't want to trigger rebuilds solely based on the build - // number. - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx)) - if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" { - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch)) - } - addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args) + addStr("avb_add_hashtree_footer_args", f.getAvbAddHashtreeFooterArgs(ctx)) } if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil { @@ -1134,7 +1113,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and addStr("f2fs_sparse_flag", "-S") } } - f.checkFsTypePropertyError(ctx, fst, fsTypeStr(fst)) + f.checkFsTypePropertyError(ctx, fst, fst.String()) if f.properties.Partition_size != nil { addStr("partition_size", strconv.FormatInt(*f.properties.Partition_size, 10)) @@ -1165,6 +1144,31 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and return propFile, deps } +func (f *filesystem) getAvbAddHashtreeFooterArgs(ctx android.ModuleContext) string { + avb_add_hashtree_footer_args := "" + if !proptools.BoolDefault(f.properties.Use_fec, true) { + avb_add_hashtree_footer_args += " --do_not_generate_fec" + } + hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256") + avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm + if f.properties.Rollback_index != nil { + rollbackIndex := proptools.Int(f.properties.Rollback_index) + if rollbackIndex < 0 { + ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative") + } + avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex) + } + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable()) + // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because + // the build number changed, and we don't want to trigger rebuilds solely based on the build + // number. + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx)) + if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" { + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch)) + } + return avb_add_hashtree_footer_args +} + // This method checks if there is any property set for the fstype(s) other than // the current fstype. func (f *filesystem) checkFsTypePropertyError(ctx android.ModuleContext, t fsType, fs string) { diff --git a/fsgen/boot_imgs.go b/fsgen/boot_imgs.go index 58ebcc4ba..0ba0a90dd 100644 --- a/fsgen/boot_imgs.go +++ b/fsgen/boot_imgs.go @@ -69,6 +69,7 @@ func createBootImage(ctx android.LoadHookContext, dtbImg dtbImg) bool { ctx.CreateModule( filesystem.BootimgFactory, &filesystem.BootimgProperties{ + Boot_image_type: proptools.StringPtr("boot"), Kernel_prebuilt: proptools.StringPtr(":" + kernelFilegroupName), Header_version: proptools.StringPtr(partitionVariables.BoardBootHeaderVersion), Partition_size: partitionSize, diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go index a0b019597..df361976e 100644 --- a/fsgen/prebuilt_etc_modules_gen.go +++ b/fsgen/prebuilt_etc_modules_gen.go @@ -226,6 +226,7 @@ var ( "usr/idc": etc.PrebuiltUserIdcFactory, "vendor": etc.PrebuiltVendorFactory, "vendor_dlkm": etc.PrebuiltVendorDlkmFactory, + "vendor_overlay": etc.PrebuiltVendorOverlayFactory, "wallpaper": etc.PrebuiltWallpaperFactory, "wlc_upt": etc.PrebuiltWlcUptFactory, } diff --git a/java/ravenwood.go b/java/ravenwood.go index c4078c587..a942dc653 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -117,6 +117,8 @@ func ravenwoodTestFactory() android.Module { "ravenwood-tests", } module.testProperties.Test_options.Unit_test = proptools.BoolPtr(false) + module.Module.sourceProperties.Test_only = proptools.BoolPtr(true) + module.Module.sourceProperties.Top_level_test_target = true InitJavaModule(module, android.DeviceSupported) android.InitDefaultableModule(module) diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index 24a02bbdc..d6493bcfa 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -230,4 +230,15 @@ func TestRavenwoodTest(t *testing.T) { android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/libred.so") android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so") android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar") + + // Ensure they are listed as "test" modules for code coverage + expectedTestOnlyModules := []string{ + "ravenwood-test", + "ravenwood-test-empty", + } + expectedTopLevelTests := []string{ + "ravenwood-test", + "ravenwood-test-empty", + } + assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests) } diff --git a/java/robolectric.go b/java/robolectric.go index be369f780..1d204a4e0 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -284,6 +284,11 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{ TestSuites: r.TestSuites(), }) + + android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{ + TestOnly: Bool(r.sourceProperties.Test_only), + TopLevelTarget: r.sourceProperties.Top_level_test_target, + }) } func generateSameDirRoboTestConfigJar(ctx android.ModuleContext, outputFile android.ModuleOutPath) { @@ -335,7 +340,8 @@ func RobolectricTestFactory() android.Module { module.Module.dexpreopter.isTest = true module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true) - + module.Module.sourceProperties.Test_only = proptools.BoolPtr(true) + module.Module.sourceProperties.Top_level_test_target = true module.testProperties.Test_suites = []string{"robolectric-tests"} InitJavaModule(module, android.DeviceSupported) diff --git a/java/robolectric_test.go b/java/robolectric_test.go index 4bf224b4f..cc16c6a26 100644 --- a/java/robolectric_test.go +++ b/java/robolectric_test.go @@ -107,4 +107,15 @@ func TestRobolectricJniTest(t *testing.T) { // Check that the .so files make it into the output. module := ctx.ModuleForTests(t, "robo-test", "android_common") module.Output(installPathPrefix + "/robo-test/lib64/jni-lib1.so") + + // Ensure they are listed as "test" modules for code coverage + expectedTestOnlyModules := []string{ + "robo-test", + } + + expectedTopLevelTests := []string{ + "robo-test", + } + assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests) + } |