diff options
| -rw-r--r-- | android/apex.go | 9 | ||||
| -rw-r--r-- | android/arch.go | 2 | ||||
| -rw-r--r-- | android/arch_list.go | 1 | ||||
| -rw-r--r-- | android/util.go | 10 | ||||
| -rw-r--r-- | apex/allowed_deps.txt | 8 | ||||
| -rw-r--r-- | cc/config/arm64_device.go | 7 | ||||
| -rw-r--r-- | cc/config/tidy.go | 24 | ||||
| -rw-r--r-- | cc/tidy.go | 15 | ||||
| -rw-r--r-- | filesystem/filesystem.go | 104 | ||||
| -rw-r--r-- | rust/config/arm64_device.go | 7 | ||||
| -rw-r--r-- | scripts/hiddenapi/Android.bp | 4 |
11 files changed, 146 insertions, 45 deletions
diff --git a/android/apex.go b/android/apex.go index 6bb0751d7..463794245 100644 --- a/android/apex.go +++ b/android/apex.go @@ -757,7 +757,6 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel { "captiveportal-lib": 28, "flatbuffer_headers": 30, "framework-permission": 30, - "framework-statsd": 30, "gemmlowp_headers": 30, "ike-internals": 30, "kotlinx-coroutines-android": 28, @@ -790,11 +789,6 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel { "libprotobuf-java-lite": 30, "libprotoutil": 30, "libqemu_pipe": 30, - "libstats_jni": 30, - "libstatslog_statsd": 30, - "libstatsmetadata": 30, - "libstatspull": 30, - "libstatssocket": 30, "libsync": 30, "libtextclassifier_hash_headers": 30, "libtextclassifier_hash_static": 30, @@ -807,9 +801,6 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel { "philox_random_headers": 30, "philox_random": 30, "service-permission": 30, - "service-statsd": 30, - "statsd-aidl-ndk_platform": 30, - "statsd": 30, "tensorflow_headers": 30, "xz-java": 29, }) diff --git a/android/arch.go b/android/arch.go index b2773810b..2decea8a5 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1442,7 +1442,7 @@ type archConfig struct { func getNdkAbisConfig() []archConfig { return []archConfig{ {"arm", "armv7-a", "", []string{"armeabi-v7a"}}, - {"arm64", "armv8-a", "", []string{"arm64-v8a"}}, + {"arm64", "armv8-a-branchprot", "", []string{"arm64-v8a"}}, {"x86", "", "", []string{"x86"}}, {"x86_64", "", "", []string{"x86_64"}}, } diff --git a/android/arch_list.go b/android/arch_list.go index 0c33b9d34..d68a0d1d1 100644 --- a/android/arch_list.go +++ b/android/arch_list.go @@ -41,6 +41,7 @@ var archVariants = map[ArchType][]string{ }, Arm64: { "armv8_a", + "armv8_a_branchprot", "armv8_2a", "armv8-2a-dotprod", "cortex-a53", diff --git a/android/util.go b/android/util.go index 0f940fa40..506f8f7b7 100644 --- a/android/util.go +++ b/android/util.go @@ -137,6 +137,16 @@ func HasAnyPrefix(s string, prefixList []string) bool { return false } +// Returns true if any string in the given list has the given substring. +func SubstringInList(list []string, substr string) bool { + for _, s := range list { + if strings.Contains(s, substr) { + return true + } + } + return false +} + // Returns true if any string in the given list has the given prefix. func PrefixInList(list []string, prefix string) bool { for _, s := range list { diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt index aee3fc496..add0e1ed7 100644 --- a/apex/allowed_deps.txt +++ b/apex/allowed_deps.txt @@ -182,6 +182,7 @@ framework-permission-s(minSdkVersion:30) framework-permission-s-shared(minSdkVersion:30) framework-sdkextensions(minSdkVersion:30) framework-sdkextensions(minSdkVersion:current) +framework-statsd(minSdkVersion:30) framework-statsd(minSdkVersion:current) framework-tethering(minSdkVersion:30) framework-tethering(minSdkVersion:current) @@ -425,11 +426,15 @@ libstagefright_mp3dec_headers(minSdkVersion:29) libstagefright_mpeg2extractor(minSdkVersion:29) libstagefright_mpeg2support_nocrypto(minSdkVersion:29) libstats_jni(minSdkVersion:(no version)) +libstats_jni(minSdkVersion:30) libstatslog_resolv(minSdkVersion:29) libstatslog_statsd(minSdkVersion:(no version)) +libstatslog_statsd(minSdkVersion:30) libstatspull(minSdkVersion:(no version)) +libstatspull(minSdkVersion:30) libstatspush_compat(minSdkVersion:29) libstatssocket(minSdkVersion:(no version)) +libstatssocket(minSdkVersion:30) libstatssocket_headers(minSdkVersion:29) libstd(minSdkVersion:29) libsystem_headers(minSdkVersion:apex_inherit) @@ -592,6 +597,7 @@ service-media-s(minSdkVersion:29) service-permission(minSdkVersion:30) service-permission(minSdkVersion:current) service-permission-shared(minSdkVersion:30) +service-statsd(minSdkVersion:30) service-statsd(minSdkVersion:current) SettingsLibActionBarShadow(minSdkVersion:21) SettingsLibAppPreference(minSdkVersion:21) @@ -605,7 +611,9 @@ SettingsLibSettingsTheme(minSdkVersion:21) SettingsLibUtils(minSdkVersion:21) stats_proto(minSdkVersion:29) statsd(minSdkVersion:(no version)) +statsd(minSdkVersion:30) statsd-aidl-ndk_platform(minSdkVersion:(no version)) +statsd-aidl-ndk_platform(minSdkVersion:30) statsprotos(minSdkVersion:29) tensorflow_headers(minSdkVersion:(no version)) Tethering(minSdkVersion:30) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index e6024aa45..d083d2a0b 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -31,6 +31,10 @@ var ( "armv8-a": []string{ "-march=armv8-a", }, + "armv8-a-branchprot": []string{ + "-march=armv8-a", + "-mbranch-protection=standard", + }, "armv8-2a": []string{ "-march=armv8.2-a", }, @@ -102,6 +106,7 @@ func init() { pctx.StaticVariable("Arm64ClangCppflags", strings.Join(ClangFilterUnknownCflags(arm64Cppflags), " ")) pctx.StaticVariable("Arm64ClangArmv8ACflags", strings.Join(arm64ArchVariantCflags["armv8-a"], " ")) + pctx.StaticVariable("Arm64ClangArmv8ABranchProtCflags", strings.Join(arm64ArchVariantCflags["armv8-a-branchprot"], " ")) pctx.StaticVariable("Arm64ClangArmv82ACflags", strings.Join(arm64ArchVariantCflags["armv8-2a"], " ")) pctx.StaticVariable("Arm64ClangArmv82ADotprodCflags", strings.Join(arm64ArchVariantCflags["armv8-2a-dotprod"], " ")) @@ -124,6 +129,7 @@ func init() { var ( arm64ClangArchVariantCflagsVar = map[string]string{ "armv8-a": "${config.Arm64ClangArmv8ACflags}", + "armv8-a-branchprot": "${config.Arm64ClangArmv8ABranchProtCflags}", "armv8-2a": "${config.Arm64ClangArmv82ACflags}", "armv8-2a-dotprod": "${config.Arm64ClangArmv82ADotprodCflags}", } @@ -202,6 +208,7 @@ func (toolchainArm64) LibclangRuntimeLibraryArch() string { func arm64ToolchainFactory(arch android.Arch) Toolchain { switch arch.ArchVariant { case "armv8-a": + case "armv8-a-branchprot": case "armv8-2a": case "armv8-2a-dotprod": // Nothing extra for armv8-a/armv8-2a diff --git a/cc/config/tidy.go b/cc/config/tidy.go index 7cc9f438c..7c20dd543 100644 --- a/cc/config/tidy.go +++ b/cc/config/tidy.go @@ -87,27 +87,11 @@ func init() { }, ",") }) - // Give warnings to header files only in selected directories. - // Do not give warnings to external or vendor header files, which contain too - // many warnings. + // To reduce duplicate warnings from the same header files, + // header-filter will contain only the module directory and + // those specified by DEFAULT_TIDY_HEADER_DIRS. pctx.VariableFunc("TidyDefaultHeaderDirs", func(ctx android.PackageVarContext) string { - if override := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS"); override != "" { - return override - } - return strings.Join([]string{ - "art/", - "bionic/", - "bootable/", - "build/", - "cts/", - "dalvik/", - "developers/", - "development/", - "frameworks/", - "libcore/", - "libnativehelper/", - "system/", - }, "|") + return ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS") }) // Use WTIH_TIDY_FLAGS to pass extra global default clang-tidy flags. diff --git a/cc/tidy.go b/cc/tidy.go index 972ad7bc7..251c67b07 100644 --- a/cc/tidy.go +++ b/cc/tidy.go @@ -20,6 +20,7 @@ import ( "github.com/google/blueprint/proptools" + "android/soong/android" "android/soong/cc/config" ) @@ -75,9 +76,17 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags { } esc := proptools.NinjaAndShellEscapeList flags.TidyFlags = append(flags.TidyFlags, esc(tidy.Properties.Tidy_flags)...) - // If TidyFlags is empty, add default header filter. - if len(flags.TidyFlags) == 0 { - headerFilter := "-header-filter=\"(" + ctx.ModuleDir() + "|${config.TidyDefaultHeaderDirs})\"" + // If TidyFlags does not contain -header-filter, add default header filter. + // Find the substring because the flag could also appear as --header-filter=... + // and with or without single or double quotes. + if !android.SubstringInList(flags.TidyFlags, "-header-filter=") { + defaultDirs := ctx.Config().Getenv("DEFAULT_TIDY_HEADER_DIRS") + headerFilter := "-header-filter=" + if defaultDirs == "" { + headerFilter += ctx.ModuleDir() + "/" + } else { + headerFilter += "\"(" + ctx.ModuleDir() + "/|" + defaultDirs + ")\"" + } flags.TidyFlags = append(flags.TidyFlags, headerFilter) } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 76581548e..3bccde9eb 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -16,6 +16,8 @@ package filesystem import ( "fmt" + "path/filepath" + "strings" "android/soong/android" @@ -37,6 +39,11 @@ type filesystem struct { installDir android.InstallPath } +type symlinkDefinition struct { + Target *string + Name *string +} + type filesystemProperties struct { // When set to true, sign the image with avbtool. Default is false. Use_avb *bool @@ -54,6 +61,16 @@ type filesystemProperties struct { // file_contexts file to make image. Currently, only ext4 is supported. File_contexts *string `android:"path"` + + // Base directory relative to root, to which deps are installed, e.g. "system". Default is "." + // (root). + Base_dir *string + + // Directories to be created under root. e.g. /dev, /proc, etc. + Dirs []string + + // Symbolic links to be created under root with "ln -sf <target> <name>". + Symlinks []symlinkDefinition } // android_filesystem packages a set of modules and their transitive dependencies into a filesystem @@ -124,16 +141,75 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.InstallFile(f.installDir, f.installFileName(), f.output) } +// root zip will contain stuffs like dirs or symlinks. +func (f *filesystem) buildRootZip(ctx android.ModuleContext) android.OutputPath { + rootDir := android.PathForModuleGen(ctx, "root").OutputPath + builder := android.NewRuleBuilder(pctx, ctx) + builder.Command().Text("rm -rf").Text(rootDir.String()) + builder.Command().Text("mkdir -p").Text(rootDir.String()) + + // create dirs and symlinks + for _, dir := range f.properties.Dirs { + // OutputPath.Join verifies dir + builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, dir).String()) + } + + for _, symlink := range f.properties.Symlinks { + name := strings.TrimSpace(proptools.String(symlink.Name)) + target := strings.TrimSpace(proptools.String(symlink.Target)) + + if name == "" { + ctx.PropertyErrorf("symlinks", "Name can't be empty") + continue + } + + if target == "" { + ctx.PropertyErrorf("symlinks", "Target can't be empty") + continue + } + + // OutputPath.Join verifies name. don't need to verify target. + dst := rootDir.Join(ctx, name) + + builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String())) + builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String()) + } + + zipOut := android.PathForModuleGen(ctx, "root.zip").OutputPath + + builder.Command(). + BuiltTool("soong_zip"). + FlagWithOutput("-o ", zipOut). + FlagWithArg("-C ", rootDir.String()). + Flag("-L 0"). // no compression because this will be unzipped soon + FlagWithArg("-D ", rootDir.String()). + Flag("-d") // include empty directories + builder.Command().Text("rm -rf").Text(rootDir.String()) + + builder.Build("zip_root", fmt.Sprintf("zipping root contents for %s", ctx.ModuleName())) + return zipOut +} + func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.OutputPath { - zipFile := android.PathForModuleOut(ctx, "temp.zip").OutputPath - f.CopyDepsToZip(ctx, zipFile) + depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath + f.CopyDepsToZip(ctx, depsZipFile) - rootDir := android.PathForModuleOut(ctx, "root").OutputPath builder := android.NewRuleBuilder(pctx, ctx) + depsBase := proptools.StringDefault(f.properties.Base_dir, ".") + rebasedDepsZip := android.PathForModuleOut(ctx, "rebased_deps.zip").OutputPath + builder.Command(). + BuiltTool("zip2zip"). + FlagWithInput("-i ", depsZipFile). + FlagWithOutput("-o ", rebasedDepsZip). + Text("**/*:" + proptools.ShellEscape(depsBase)) // zip2zip verifies depsBase + + rootDir := android.PathForModuleOut(ctx, "root").OutputPath + rootZip := f.buildRootZip(ctx) builder.Command(). BuiltTool("zipsync"). FlagWithArg("-d ", rootDir.String()). // zipsync wipes this. No need to clear. - Input(zipFile) + Input(rootZip). + Input(rebasedDepsZip) propFile, toolDeps := f.buildPropFile(ctx) output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath @@ -187,7 +263,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (propFile android. } addStr("fs_type", fsTypeStr(f.fsType(ctx))) - addStr("mount_point", "system") + addStr("mount_point", "/") addStr("use_dynamic_partition_size", "true") addPath("ext_mkuserimg", ctx.Config().HostToolPath(ctx, "mkuserimg_mke2fs")) // b/177813163 deps of the host tools have to be added. Remove this. @@ -233,15 +309,25 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) ctx.PropertyErrorf("file_contexts", "file_contexts is not supported for compressed cpio image.") } - zipFile := android.PathForModuleOut(ctx, "temp.zip").OutputPath - f.CopyDepsToZip(ctx, zipFile) + depsZipFile := android.PathForModuleOut(ctx, "deps.zip").OutputPath + f.CopyDepsToZip(ctx, depsZipFile) - rootDir := android.PathForModuleOut(ctx, "root").OutputPath builder := android.NewRuleBuilder(pctx, ctx) + depsBase := proptools.StringDefault(f.properties.Base_dir, ".") + rebasedDepsZip := android.PathForModuleOut(ctx, "rebased_deps.zip").OutputPath + builder.Command(). + BuiltTool("zip2zip"). + FlagWithInput("-i ", depsZipFile). + FlagWithOutput("-o ", rebasedDepsZip). + Text("**/*:" + proptools.ShellEscape(depsBase)) // zip2zip verifies depsBase + + rootDir := android.PathForModuleOut(ctx, "root").OutputPath + rootZip := f.buildRootZip(ctx) builder.Command(). BuiltTool("zipsync"). FlagWithArg("-d ", rootDir.String()). // zipsync wipes this. No need to clear. - Input(zipFile) + Input(rootZip). + Input(rebasedDepsZip) output := android.PathForModuleOut(ctx, f.installFileName()).OutputPath cmd := builder.Command(). diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go index 506642861..186e571dd 100644 --- a/rust/config/arm64_device.go +++ b/rust/config/arm64_device.go @@ -26,9 +26,10 @@ var ( Arm64LinkFlags = []string{} Arm64ArchVariantRustFlags = map[string][]string{ - "armv8-a": []string{}, - "armv8-2a": []string{}, - "armv8-2a-dotprod": []string{}, + "armv8-a": []string{}, + "armv8-a-branchprot": []string{}, + "armv8-2a": []string{}, + "armv8-2a-dotprod": []string{}, } ) diff --git a/scripts/hiddenapi/Android.bp b/scripts/hiddenapi/Android.bp index a669cadd4..af7e7fe6b 100644 --- a/scripts/hiddenapi/Android.bp +++ b/scripts/hiddenapi/Android.bp @@ -14,6 +14,10 @@ * limitations under the License. */ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + python_binary_host { name: "merge_csv", main: "merge_csv.py", |