Merge "Simplify cc.IncomingDepIsInSameApex" into main
diff --git a/Android.bp b/Android.bp
index 434ee9f..d78379a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -179,6 +179,7 @@
visibility: [
"//build/make/target/product/generic",
"//build/make/target/product/gsi",
+ "//build/soong/fsgen",
"//packages/modules/Virtualization/build/microdroid",
"//frameworks/base/ravenwood",
],
@@ -190,7 +191,10 @@
system_ext_specific: true,
product_config: ":product_config",
relative_install_path: "etc", // system_ext/etc/build.prop
- visibility: ["//build/make/target/product/gsi"],
+ visibility: [
+ "//build/make/target/product/gsi",
+ "//build/soong/fsgen",
+ ],
}
build_prop {
@@ -199,7 +203,10 @@
product_specific: true,
product_config: ":product_config",
relative_install_path: "etc", // product/etc/build.prop
- visibility: ["//build/make/target/product/gsi"],
+ visibility: [
+ "//build/make/target/product/gsi",
+ "//build/soong/fsgen",
+ ],
}
build_prop {
@@ -208,7 +215,7 @@
device_specific: true,
product_config: ":product_config",
relative_install_path: "etc", // odm/etc/build.prop
- visibility: ["//visibility:private"],
+ visibility: ["//build/soong/fsgen"],
}
build_prop {
diff --git a/android/Android.bp b/android/Android.bp
index 20cd28b..79969a8 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -95,6 +95,7 @@
"proto.go",
"provider.go",
"raw_files.go",
+ "recovery_build_prop.go",
"register.go",
"rule_builder.go",
"sandbox.go",
diff --git a/android/config.go b/android/config.go
index b811c55..d78bbf7 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1320,6 +1320,10 @@
return c.IsEnvTrue("RUN_ERROR_PRONE")
}
+func (c *config) RunErrorProneInline() bool {
+ return c.IsEnvTrue("RUN_ERROR_PRONE_INLINE")
+}
+
// XrefCorpusName returns the Kythe cross-reference corpus name.
func (c *config) XrefCorpusName() string {
return c.Getenv("XREF_CORPUS")
diff --git a/android/container.go b/android/container.go
index 27b17ed..99e6a30 100644
--- a/android/container.go
+++ b/android/container.go
@@ -197,7 +197,10 @@
func determineUnstableModule(mctx ModuleContext) bool {
module := mctx.Module()
- unstableModule := module.Name() == "framework-minus-apex"
+
+ // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once
+ // we remove this module.
+ unstableModule := module.Name() == "framework-minus-apex" || module.Name() == "framework-minus-apex_jarjar-sharded"
if installable, ok := module.(InstallableModule); ok {
for _, staticDepTag := range installable.StaticDependencyTags() {
mctx.VisitDirectDepsWithTag(staticDepTag, func(dep Module) {
diff --git a/android/logtags.go b/android/logtags.go
index 1e92dad..abc37f9 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -14,10 +14,56 @@
package android
-import "github.com/google/blueprint"
+import (
+ "strings"
+
+ "github.com/google/blueprint"
+)
+
+func init() {
+ RegisterParallelSingletonType("logtags", LogtagsSingleton)
+}
type LogtagsInfo struct {
Logtags Paths
}
var LogtagsProviderKey = blueprint.NewProvider[*LogtagsInfo]()
+
+func LogtagsSingleton() Singleton {
+ return &logtagsSingleton{}
+}
+
+type logtagsSingleton struct{}
+
+func MergedLogtagsPath(ctx PathContext) OutputPath {
+ return PathForIntermediates(ctx, "all-event-log-tags.txt")
+}
+
+func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) {
+ var allLogtags Paths
+ ctx.VisitAllModules(func(module Module) {
+ if !module.ExportedToMake() {
+ return
+ }
+ if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok {
+ allLogtags = append(allLogtags, logtagsInfo.Logtags...)
+ }
+ })
+ allLogtags = SortedUniquePaths(allLogtags)
+ filteredLogTags := make([]Path, 0, len(allLogtags))
+ for _, p := range allLogtags {
+ // Logic copied from make:
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=987;drc=0585bb1bcf4c89065adaf709f48acc8b869fd3ce
+ if !strings.HasPrefix(p.String(), "vendor/") && !strings.HasPrefix(p.String(), "device/") && !strings.HasPrefix(p.String(), "out/") {
+ filteredLogTags = append(filteredLogTags, p)
+ }
+ }
+
+ builder := NewRuleBuilder(pctx, ctx)
+ builder.Command().
+ BuiltTool("merge-event-log-tags").
+ FlagWithOutput("-o ", MergedLogtagsPath(ctx)).
+ Inputs(filteredLogTags)
+ builder.Build("all-event-log-tags.txt", "merge logtags")
+}
diff --git a/android/module_context.go b/android/module_context.go
index ae7b54f..b097117 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -623,8 +623,10 @@
if m.requiresFullInstall() {
deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...)
- deps = append(deps, m.installedInitRcPaths...)
- deps = append(deps, m.installedVintfFragmentsPaths...)
+ if m.config.KatiEnabled() {
+ deps = append(deps, m.installedInitRcPaths...)
+ deps = append(deps, m.installedVintfFragmentsPaths...)
+ }
var implicitDeps, orderOnlyDeps Paths
diff --git a/android/recovery_build_prop.go b/android/recovery_build_prop.go
new file mode 100644
index 0000000..91d1904
--- /dev/null
+++ b/android/recovery_build_prop.go
@@ -0,0 +1,111 @@
+// Copyright 2024 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package android
+
+import "github.com/google/blueprint/proptools"
+
+func init() {
+ RegisterModuleType("recovery_build_prop", RecoveryBuildPropModuleFactory)
+}
+
+type recoveryBuildPropProperties struct {
+ // Path to the system build.prop file
+ System_build_prop *string `android:"path"`
+
+ // Path to the vendor build.prop file
+ Vendor_build_prop *string `android:"path"`
+
+ // Path to the odm build.prop file
+ Odm_build_prop *string `android:"path"`
+
+ // Path to the product build.prop file
+ Product_build_prop *string `android:"path"`
+
+ // Path to the system_ext build.prop file
+ System_ext_build_prop *string `android:"path"`
+}
+
+type recoveryBuildPropModule struct {
+ ModuleBase
+ properties recoveryBuildPropProperties
+
+ outputFilePath ModuleOutPath
+
+ installPath InstallPath
+}
+
+func RecoveryBuildPropModuleFactory() Module {
+ module := &recoveryBuildPropModule{}
+ module.AddProperties(&module.properties)
+ InitAndroidArchModule(module, DeviceSupported, MultilibCommon)
+ return module
+}
+
+// Overrides ctx.Module().InstallInRoot().
+// recovery_build_prop module always installs in root so that the prop.default
+// file is installed in recovery/root instead of recovery/root/system
+func (r *recoveryBuildPropModule) InstallInRoot() bool {
+ return true
+}
+
+func (r *recoveryBuildPropModule) appendRecoveryUIProperties(ctx ModuleContext, rule *RuleBuilder) {
+ rule.Command().Text("echo '#' >>").Output(r.outputFilePath)
+ rule.Command().Text("echo '# RECOVERY UI BUILD PROPERTIES' >>").Output(r.outputFilePath)
+ rule.Command().Text("echo '#' >>").Output(r.outputFilePath)
+
+ for propName, val := range ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.PrivateRecoveryUiProperties {
+ if len(val) > 0 {
+ rule.Command().
+ Textf("echo ro.recovery.ui.%s=%s >>", propName, val).
+ Output(r.outputFilePath)
+ }
+ }
+}
+
+func (r *recoveryBuildPropModule) getBuildProps(ctx ModuleContext) Paths {
+ var buildProps Paths
+ for _, buildProp := range []*string{
+ r.properties.System_build_prop,
+ r.properties.Vendor_build_prop,
+ r.properties.Odm_build_prop,
+ r.properties.Product_build_prop,
+ r.properties.System_ext_build_prop,
+ } {
+ if buildPropPath := PathForModuleSrc(ctx, proptools.String(buildProp)); buildPropPath != nil {
+ buildProps = append(buildProps, buildPropPath)
+ }
+ }
+ return buildProps
+}
+
+func (r *recoveryBuildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ if !r.InstallInRecovery() {
+ ctx.ModuleErrorf("recovery_build_prop module must set `recovery` property to true")
+ }
+ r.outputFilePath = PathForModuleOut(ctx, ctx.ModuleName(), "prop.default")
+
+ // Replicates the logic in https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2733;drc=0585bb1bcf4c89065adaf709f48acc8b869fd3ce
+ rule := NewRuleBuilder(pctx, ctx)
+ rule.Command().Text("rm").FlagWithOutput("-f ", r.outputFilePath)
+ rule.Command().Text("cat").
+ Inputs(r.getBuildProps(ctx)).
+ Text(">>").
+ Output(r.outputFilePath)
+ r.appendRecoveryUIProperties(ctx, rule)
+
+ rule.Build(ctx.ModuleName(), "generating recovery prop.default")
+ r.installPath = PathForModuleInstall(ctx)
+ ctx.InstallFile(r.installPath, "prop.default", r.outputFilePath)
+}
diff --git a/android/variable.go b/android/variable.go
index 19f63e3..3cf66ea 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -617,7 +617,11 @@
ProductUseDynamicPartitionSize bool `json:",omitempty"`
CopyImagesForTargetFilesZip bool `json:",omitempty"`
- VendorSecurityPatch string `json:",omitempty"`
+ VendorSecurityPatch string `json:",omitempty"`
+ OdmSecurityPatch string `json:",omitempty"`
+ SystemDlkmSecurityPatch string `json:",omitempty"`
+ VendorDlkmSecurityPatch string `json:",omitempty"`
+ OdmDlkmSecurityPatch string `json:",omitempty"`
// Boot image stuff
BuildingRamdiskImage bool `json:",omitempty"`
@@ -688,6 +692,8 @@
ProductFsverityGenerateMetadata bool `json:",omitempty"`
TargetScreenDensity string `json:",omitempty"`
+
+ PrivateRecoveryUiProperties map[string]string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/apex/builder.go b/apex/builder.go
index 45608c9..7e66644 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -544,7 +544,7 @@
imageDir := android.PathForModuleOut(ctx, "image"+suffix)
- installSymbolFiles := (!ctx.Config().KatiEnabled() || a.ExportedToMake()) && a.installable()
+ installSymbolFiles := (ctx.Config().KatiEnabled() && a.ExportedToMake()) && a.installable()
// set of dependency module:location mappings
installMapSet := make(map[string]bool)
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index a4d43b9..1f6cf23 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -106,6 +106,8 @@
}
windowsAvailableLibraries = addPrefix([]string{
+ "bcrypt",
+ "dbghelp",
"gdi32",
"imagehlp",
"iphlpapi",
diff --git a/cc/library.go b/cc/library.go
index ebc65ef..a3a2f5c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -34,6 +34,8 @@
// LibraryProperties is a collection of properties shared by cc library rules/cc.
type LibraryProperties struct {
+ // local file name to pass to the linker as -exported_symbols_list
+ Exported_symbols_list *string `android:"path,arch_variant"`
// local file name to pass to the linker as -unexported_symbols_list
Unexported_symbols_list *string `android:"path,arch_variant"`
// local file name to pass to the linker as -force_symbols_not_weak_list
@@ -1049,10 +1051,14 @@
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
linkerDeps = append(linkerDeps, ndkSharedLibDeps(ctx)...)
+ exportedSymbols := ctx.ExpandOptionalSource(library.Properties.Exported_symbols_list, "exported_symbols_list")
unexportedSymbols := ctx.ExpandOptionalSource(library.Properties.Unexported_symbols_list, "unexported_symbols_list")
forceNotWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_not_weak_list, "force_symbols_not_weak_list")
forceWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_weak_list, "force_symbols_weak_list")
if !ctx.Darwin() {
+ if exportedSymbols.Valid() {
+ ctx.PropertyErrorf("exported_symbols_list", "Only supported on Darwin")
+ }
if unexportedSymbols.Valid() {
ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
}
@@ -1063,6 +1069,10 @@
ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
}
} else {
+ if exportedSymbols.Valid() {
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-exported_symbols_list,"+exportedSymbols.String())
+ linkerDeps = append(linkerDeps, exportedSymbols.Path())
+ }
if unexportedSymbols.Valid() {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
linkerDeps = append(linkerDeps, unexportedSymbols.Path())
diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go
index d06b2b7..7013d6b 100644
--- a/cmd/release_config/release_config/main.go
+++ b/cmd/release_config/release_config/main.go
@@ -95,7 +95,7 @@
if allMake {
// Write one makefile per release config, using the canonical release name.
for _, c := range configs.GetSortedReleaseConfigs() {
- if c.Name != targetRelease {
+ if c.Name != targetRelease && !c.DisallowLunchUse {
makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name))
err = config.WriteMakefile(makefilePath, c.Name, configs)
if err != nil {
diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go
index 719ddc0..873f2fc 100644
--- a/cmd/release_config/release_config_lib/release_config.go
+++ b/cmd/release_config/release_config_lib/release_config.go
@@ -67,6 +67,9 @@
// overrides. Build flag value overrides are an error.
AconfigFlagsOnly bool
+ // True if this release config is not allowed as TARGET_RELEASE.
+ DisallowLunchUse bool
+
// Unmarshalled flag artifacts
FlagArtifacts FlagArtifacts
@@ -93,6 +96,11 @@
// If true, this is a proper release config that can be used in "lunch".
func (config *ReleaseConfig) isConfigListable() bool {
+ // Do not list disallowed release configs.
+ if config.DisallowLunchUse {
+ return false
+ }
+ // Logic based on ReleaseConfigType.
switch config.ReleaseConfigType {
case rc_proto.ReleaseConfigType_RELEASE_CONFIG:
return true
@@ -405,6 +413,7 @@
ValueDirectories: valueDirectories,
PriorStages: SortedMapKeys(config.PriorStagesMap),
ReleaseConfigType: config.ReleaseConfigType.Enum(),
+ DisallowLunchUse: proto.Bool(config.DisallowLunchUse),
}
config.compileInProgress = false
@@ -481,6 +490,9 @@
}
// As it stands this list is not per-product, but conceptually it is, and will be.
data += fmt.Sprintf("ALL_RELEASE_CONFIGS_FOR_PRODUCT :=$= %s\n", strings.Join(configs.GetAllReleaseNames(), " "))
+ if config.DisallowLunchUse {
+ data += fmt.Sprintf("_disallow_lunch_use :=$= true\n")
+ }
data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " "))
data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " "))
for _, pName := range pNames {
diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go
index 4f621c7..b0f8cb7 100644
--- a/cmd/release_config/release_config_lib/release_configs.go
+++ b/cmd/release_config/release_config_lib/release_configs.go
@@ -378,6 +378,7 @@
return fmt.Errorf("%s mismatching ReleaseConfigType value %s", path, *releaseConfigType)
}
config.FilesUsedMap[path] = true
+ config.DisallowLunchUse = config.DisallowLunchUse || releaseConfigContribution.proto.GetDisallowLunchUse()
inheritNames := make(map[string]bool)
for _, inh := range config.InheritNames {
inheritNames[inh] = true
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 0ffec26..36b1a18 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -391,15 +391,6 @@
return output
}
-// Calculates avb_salt from some input for deterministic output.
-func (b *bootimg) salt() string {
- var input []string
- input = append(input, b.properties.Cmdline...)
- input = append(input, proptools.StringDefault(b.properties.Partition_name, b.Name()))
- input = append(input, proptools.String(b.properties.Header_version))
- return sha1sum(input)
-}
-
func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) {
var sb strings.Builder
var deps android.Paths
@@ -420,7 +411,6 @@
addStr("avb_add_hash_footer_args", "") // TODO(jiyong): add --rollback_index
partitionName := proptools.StringDefault(b.properties.Partition_name, b.Name())
addStr("partition_name", partitionName)
- addStr("avb_salt", b.salt())
propFile := android.PathForModuleOut(ctx, "prop")
android.WriteFileRule(ctx, propFile, sb.String())
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 1d32b8f..bff0a10 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -121,6 +121,9 @@
// avbtool. Default used by avbtool is sha1.
Avb_hash_algorithm *string
+ // The security patch passed to as the com.android.build.<type>.security_patch avb property.
+ Security_patch *string
+
// Whether or not to use forward-error-correction codes when signing with AVB. Defaults to true.
Use_fec *bool
@@ -465,7 +468,7 @@
}
func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.Path) {
- partitionBaseDir := android.PathForModuleOut(ctx, "root", proptools.String(f.properties.Base_dir)).String() + "/"
+ partitionBaseDir := android.PathForModuleOut(ctx, f.rootDirString(), proptools.String(f.properties.Base_dir)).String() + "/"
relPath, inTargetPartition := strings.CutPrefix(installedFile.String(), partitionBaseDir)
if inTargetPartition {
@@ -555,8 +558,12 @@
builder.Command().Textf("cp -prf %s/* %s", rebasedDir, installPath)
}
+func (f *filesystem) rootDirString() string {
+ return f.partitionName()
+}
+
func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.Path {
- rootDir := android.PathForModuleOut(ctx, "root").OutputPath
+ rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
rebasedDir := rootDir
if f.properties.Base_dir != nil {
rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
@@ -599,6 +606,7 @@
Input(propFile).
Implicits(toolDeps).
Implicit(fec).
+ FlagWithArg("--build_datetime_file ", ctx.Config().Getenv("BUILD_DATETIME_FILE")).
Output(output).
Text(rootDir.String()) // directory where to find fs_config_files|dirs
@@ -618,11 +626,6 @@
return fcBin
}
-// Calculates avb_salt from entry list (sorted) for deterministic output.
-func (f *filesystem) salt() string {
- return sha1sum(f.entries)
-}
-
func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) {
var deps android.Paths
var propFileString strings.Builder
@@ -686,9 +689,10 @@
}
avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable())
avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx))
- avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), ctx.Config().PlatformSecurityPatch())
+ 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_salt", f.salt())
}
if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil {
@@ -783,7 +787,7 @@
ctx.PropertyErrorf("include_make_built_files", "include_make_built_files is not supported for compressed cpio image.")
}
- rootDir := android.PathForModuleOut(ctx, "root").OutputPath
+ rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath
rebasedDir := rootDir
if f.properties.Base_dir != nil {
rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir)
@@ -868,29 +872,10 @@
return
}
- logtagsFilePaths := make(map[string]bool)
- ctx.WalkDeps(func(child, parent android.Module) bool {
- if logtagsInfo, ok := android.OtherModuleProvider(ctx, child, android.LogtagsProviderKey); ok {
- for _, path := range logtagsInfo.Logtags {
- logtagsFilePaths[path.String()] = true
- }
- }
- return true
- })
-
- if len(logtagsFilePaths) == 0 {
- return
- }
-
etcPath := rebasedDir.Join(ctx, "etc")
eventLogtagsPath := etcPath.Join(ctx, "event-log-tags")
builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String())
- cmd := builder.Command().BuiltTool("merge-event-log-tags").
- FlagWithArg("-o ", eventLogtagsPath.String())
-
- for _, path := range android.SortedKeys(logtagsFilePaths) {
- cmd.Text(path)
- }
+ builder.Command().Text("cp").Input(android.MergedLogtagsPath(ctx)).Text(eventLogtagsPath.String())
f.appendToEntry(ctx, eventLogtagsPath)
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 0ed3870..2dcb23d 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -181,7 +181,7 @@
`)
module := result.ModuleForTests("myfilesystem", "android_common")
- output := module.Output("out/soong/.intermediates/myfilesystem/android_common/root/system/etc/linker.config.pb")
+ output := module.Output("out/soong/.intermediates/myfilesystem/android_common/myfilesystem/system/etc/linker.config.pb")
fullCommand := output.RuleParams.Command
startIndex := strings.Index(fullCommand, "conv_linker_config")
diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go
index 6372c5e..91b8c57 100644
--- a/filesystem/fsverity_metadata.go
+++ b/filesystem/fsverity_metadata.go
@@ -85,6 +85,18 @@
f.appendToEntry(ctx, destPath)
}
+ fsVerityBaseDir := rootDir.String()
+ if f.PartitionType() == "system_ext" {
+ // Use the equivalent of $PRODUCT_OUT as the base dir.
+ // This ensures that the paths in build_manifest.pb contain on-device paths
+ // e.g. system_ext/framework/javalib.jar
+ // and not framework/javalib.jar.
+ //
+ // Although base-dir is outside the rootdir provided for packaging, this action
+ // is hermetic since it uses `manifestGeneratorListPath` to filter the files to be written to build_manifest.pb
+ fsVerityBaseDir = filepath.Dir(rootDir.String())
+ }
+
// STEP 2: generate signed BuildManifest.apk
// STEP 2-1: generate build_manifest.pb
manifestGeneratorListPath := android.PathForModuleOut(ctx, "fsverity_manifest.list")
@@ -96,7 +108,7 @@
builder.Command().
BuiltTool("fsverity_manifest_generator").
FlagWithInput("--fsverity-path ", fsverityPath).
- FlagWithArg("--base-dir ", rootDir.String()).
+ FlagWithArg("--base-dir ", fsVerityBaseDir).
FlagWithArg("--output ", manifestPbPath.String()).
FlagWithInput("@", manifestGeneratorListPath)
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index b9fddca..765b28f 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -266,6 +266,7 @@
)
fsProps.Base_dir = proptools.StringPtr("system")
fsProps.Dirs = proptools.NewSimpleConfigurable(commonPartitionDirs)
+ fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
case "system_ext":
if partitionVars.ProductFsverityGenerateMetadata {
fsProps.Fsverity.Inputs = []string{
@@ -275,12 +276,14 @@
}
fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
}
+ fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
case "product":
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
fsProps.Android_filesystem_deps.System = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system"))
if ctx.DeviceConfig().SystemExtPath() == "system_ext" {
fsProps.Android_filesystem_deps.System_ext = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
}
+ fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
case "vendor":
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
fsProps.Symlinks = []filesystem.SymlinkDefinition{
@@ -297,6 +300,7 @@
if ctx.DeviceConfig().SystemExtPath() == "system_ext" {
fsProps.Android_filesystem_deps.System_ext = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
}
+ fsProps.Security_patch = proptools.StringPtr(partitionVars.VendorSecurityPatch)
case "odm":
fsProps.Symlinks = []filesystem.SymlinkDefinition{
filesystem.SymlinkDefinition{
@@ -304,6 +308,7 @@
Name: proptools.StringPtr("lib/modules"),
},
}
+ fsProps.Security_patch = proptools.StringPtr(partitionVars.OdmSecurityPatch)
case "userdata":
fsProps.Base_dir = proptools.StringPtr("data")
case "ramdisk":
@@ -358,6 +363,12 @@
Target: proptools.StringPtr("prop.default"),
Name: proptools.StringPtr("default.prop"),
}), "root")
+ case "system_dlkm":
+ fsProps.Security_patch = proptools.StringPtr(partitionVars.SystemDlkmSecurityPatch)
+ case "vendor_dlkm":
+ fsProps.Security_patch = proptools.StringPtr(partitionVars.VendorDlkmSecurityPatch)
+ case "odm_dlkm":
+ fsProps.Security_patch = proptools.StringPtr(partitionVars.OdmDlkmSecurityPatch)
}
}
@@ -596,6 +607,43 @@
vendorBuildProp.HideFromMake()
}
+func createRecoveryBuildProp(ctx android.LoadHookContext) string {
+ moduleName := generatedModuleName(ctx.Config(), "recovery-prop.default")
+
+ var vendorBuildProp *string
+ if android.InList("vendor", generatedPartitions(ctx)) {
+ vendorBuildProp = proptools.StringPtr(":" + generatedModuleName(ctx.Config(), "vendor-build.prop"))
+ }
+
+ recoveryBuildProps := &struct {
+ Name *string
+ System_build_prop *string
+ Vendor_build_prop *string
+ Odm_build_prop *string
+ Product_build_prop *string
+ System_ext_build_prop *string
+
+ Recovery *bool
+ No_full_install *bool
+ Visibility []string
+ }{
+ Name: proptools.StringPtr(moduleName),
+ System_build_prop: proptools.StringPtr(":system-build.prop"),
+ Vendor_build_prop: vendorBuildProp,
+ Odm_build_prop: proptools.StringPtr(":odm-build.prop"),
+ Product_build_prop: proptools.StringPtr(":product-build.prop"),
+ System_ext_build_prop: proptools.StringPtr(":system_ext-build.prop"),
+
+ Recovery: proptools.BoolPtr(true),
+ No_full_install: proptools.BoolPtr(true),
+ Visibility: []string{"//visibility:public"},
+ }
+
+ ctx.CreateModule(android.RecoveryBuildPropModuleFactory, recoveryBuildProps)
+
+ return moduleName
+}
+
// createLinkerConfigSourceFilegroups creates filegroup modules to generate linker.config.pb for the following partitions
// 1. vendor: Using PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS (space separated file list)
// 1. product: Using PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS (space separated file list)
@@ -709,6 +757,8 @@
}
fsProps.Is_auto_generated = proptools.BoolPtr(true)
+ // TODO(b/381120092): Verify mount_point for system partition
+ fsProps.Mount_point = proptools.StringPtr(partitionType)
partitionSpecificFsProps(ctx, fsProps, partitionVars, partitionType)
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index 20e4c3e..de0a1cb 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -165,6 +165,7 @@
// Add common resources `prebuilt_res` module as dep of recovery partition
(*fsGenState.fsDeps["recovery"])[fmt.Sprintf("recovery-resources-common-%s", getDpi(ctx))] = defaultDepCandidateProps(ctx.Config())
(*fsGenState.fsDeps["recovery"])[getRecoveryFontModuleName(ctx)] = defaultDepCandidateProps(ctx.Config())
+ (*fsGenState.fsDeps["recovery"])[createRecoveryBuildProp(ctx)] = defaultDepCandidateProps(ctx.Config())
return &fsGenState
}).(*FsGenState)
diff --git a/java/base.go b/java/base.go
index 215285f..18a875b 100644
--- a/java/base.go
+++ b/java/base.go
@@ -109,6 +109,10 @@
// if not blank, used as prefix to generate repackage rule
Jarjar_prefix *string
+ // Number of shards for jarjar. It needs to be an integer represented as a string.
+ // TODO(b/383559945) change it to int, once Configurable supports the type.
+ Jarjar_shards proptools.Configurable[string]
+
// If not blank, set the java version passed to javac as -source and -target
Java_version *string
@@ -1273,7 +1277,7 @@
localHeaderJars, combinedHeaderJarFile := j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName,
extraCombinedJars)
- combinedHeaderJarFile, jarjared := j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine")
+ combinedHeaderJarFile, jarjared := j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine", false)
if jarjared {
localHeaderJars = android.Paths{combinedHeaderJarFile}
transitiveStaticLibsHeaderJars = nil
@@ -1409,7 +1413,7 @@
shardingHeaderJars = localHeaderJars
var jarjared bool
- j.headerJarFile, jarjared = j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine")
+ j.headerJarFile, jarjared = j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine", false)
if jarjared {
// jarjar modifies transitive static dependencies, use the combined header jar and drop the transitive
// static libs header jars.
@@ -1442,20 +1446,27 @@
// build.
flags = enableErrorproneFlags(flags)
} else if hasErrorproneableFiles && ctx.Config().RunErrorProne() && j.properties.Errorprone.Enabled == nil {
- // Otherwise, if the RUN_ERROR_PRONE environment variable is set, create
- // a new jar file just for compiling with the errorprone compiler to.
- // This is because we don't want to cause the java files to get completely
- // rebuilt every time the state of the RUN_ERROR_PRONE variable changes.
- // We also don't want to run this if errorprone is enabled by default for
- // this module, or else we could have duplicated errorprone messages.
- errorproneFlags := enableErrorproneFlags(flags)
- errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
- errorproneAnnoSrcJar := android.PathForModuleOut(ctx, "errorprone", "anno.srcjar")
+ if ctx.Config().RunErrorProneInline() {
+ // On CI, we're not going to toggle back/forth between errorprone and non-errorprone
+ // builds, so it's faster if we don't compile the module twice and instead always
+ // compile the module with errorprone.
+ flags = enableErrorproneFlags(flags)
+ } else {
+ // Otherwise, if the RUN_ERROR_PRONE environment variable is set, create
+ // a new jar file just for compiling with the errorprone compiler to.
+ // This is because we don't want to cause the java files to get completely
+ // rebuilt every time the state of the RUN_ERROR_PRONE variable changes.
+ // We also don't want to run this if errorprone is enabled by default for
+ // this module, or else we could have duplicated errorprone messages.
+ errorproneFlags := enableErrorproneFlags(flags)
+ errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
+ errorproneAnnoSrcJar := android.PathForModuleOut(ctx, "errorprone", "anno.srcjar")
- transformJavaToClasses(ctx, errorprone, -1, uniqueJavaFiles, srcJars, errorproneAnnoSrcJar, errorproneFlags, nil,
- "errorprone", "errorprone")
+ transformJavaToClasses(ctx, errorprone, -1, uniqueJavaFiles, srcJars, errorproneAnnoSrcJar, errorproneFlags, nil,
+ "errorprone", "errorprone")
- extraJarDeps = append(extraJarDeps, errorprone)
+ extraJarDeps = append(extraJarDeps, errorprone)
+ }
}
if enableSharding {
@@ -1636,7 +1647,7 @@
}
// jarjar implementation jar if necessary
- jarjarFile, jarjarred := j.jarjarIfNecessary(ctx, outputFile, jarName, "")
+ jarjarFile, jarjarred := j.jarjarIfNecessary(ctx, outputFile, jarName, "", true)
if jarjarred {
localImplementationJars = android.Paths{jarjarFile}
completeStaticLibsImplementationJars = depset.New(depset.PREORDER, localImplementationJars, nil)
@@ -1645,7 +1656,7 @@
// jarjar resource jar if necessary
if combinedResourceJar != nil {
- resourceJarJarFile, jarjarred := j.jarjarIfNecessary(ctx, combinedResourceJar, jarName, "resource")
+ resourceJarJarFile, jarjarred := j.jarjarIfNecessary(ctx, combinedResourceJar, jarName, "resource", false)
combinedResourceJar = resourceJarJarFile
if jarjarred {
localResourceJars = android.Paths{resourceJarJarFile}
@@ -2934,12 +2945,23 @@
return repackagedJarjarFile, true
}
-func (j *Module) jarjarIfNecessary(ctx android.ModuleContext, infile android.Path, jarName, info string) (android.Path, bool) {
+func (j *Module) jarjarIfNecessary(ctx android.ModuleContext, infile android.Path, jarName, info string, useShards bool) (android.Path, bool) {
if j.expandJarjarRules == nil {
return infile, false
}
jarjarFile := android.PathForModuleOut(ctx, "jarjar", info, jarName)
- TransformJarJar(ctx, jarjarFile, infile, j.expandJarjarRules)
+
+ totalShards := 1
+ if useShards {
+ totalShardsStr := j.properties.Jarjar_shards.GetOrDefault(ctx, "1")
+ ts, err := strconv.Atoi(totalShardsStr)
+ if err != nil {
+ ctx.PropertyErrorf("jarjar_shards", "jarjar_shards must be an integer represented as a string")
+ return infile, false
+ }
+ totalShards = ts
+ }
+ TransformJarJarWithShards(ctx, jarjarFile, infile, j.expandJarjarRules, totalShards)
return jarjarFile, true
}
diff --git a/java/builder.go b/java/builder.go
index 01fbbdd..f25798d 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -238,12 +238,12 @@
// for newly repackaged classes. Dropping @UnsupportedAppUsage on repackaged classes
// avoids adding new hiddenapis after jarjar'ing.
" -DremoveAndroidCompatAnnotations=true" +
- " -jar ${config.JarjarCmd} process $rulesFile $in $out && " +
+ " -jar ${config.JarjarCmd} process $rulesFile $in $out $total_shards $shard_index && " +
// Turn a missing output file into a ninja error
`[ -e ${out} ] || (echo "Missing output file"; exit 1)`,
CommandDeps: []string{"${config.JavaCmd}", "${config.JarjarCmd}", "$rulesFile"},
},
- "rulesFile")
+ "rulesFile", "total_shards", "shard_index")
packageCheck = pctx.AndroidStaticRule("packageCheck",
blueprint.RuleParams{
@@ -750,16 +750,58 @@
func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath,
classesJar android.Path, rulesFile android.Path) {
+ TransformJarJarWithShards(ctx, outputFile, classesJar, rulesFile, 1)
+}
+
+func TransformJarJarWithShards(ctx android.ModuleContext, outputFile android.WritablePath,
+ classesJar android.Path, rulesFile android.Path, totalShards int) {
+
+ // If the total number of shards is 1, just run jarjar as-is, with `total_shards` = 1
+ // and `shard_index` == 0, which effectively disables sharding
+ if totalShards == 1 {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: jarjar,
+ Description: "jarjar",
+ Output: outputFile,
+ Input: classesJar,
+ Implicit: rulesFile,
+ Args: map[string]string{
+ "rulesFile": rulesFile.String(),
+ "total_shards": "1",
+ "shard_index": "0",
+ },
+ })
+ return
+ }
+
+ // Otherwise, run multiple jarjar instances and use merge_zips to combine the output.
+ tempJars := make([]android.Path, 0)
+ totalStr := strconv.Itoa(totalShards)
+ for i := 0; i < totalShards; i++ {
+ iStr := strconv.Itoa(i)
+ tempOut := android.PathForOutput(ctx, outputFile.String()+"-"+iStr+".jar")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: jarjar,
+ Description: "jarjar (" + iStr + "/" + totalStr + ")",
+ Output: tempOut,
+ Input: classesJar,
+ Implicit: rulesFile,
+ Args: map[string]string{
+ "rulesFile": rulesFile.String(),
+ "total_shards": totalStr,
+ "shard_index": iStr,
+ },
+ })
+ tempJars = append(tempJars, tempOut)
+ }
+
ctx.Build(pctx, android.BuildParams{
- Rule: jarjar,
- Description: "jarjar",
+ Rule: combineJar,
+ Description: "merge jarjar shards",
Output: outputFile,
- Input: classesJar,
- Implicit: rulesFile,
- Args: map[string]string{
- "rulesFile": rulesFile.String(),
- },
+ Inputs: tempJars,
})
+
}
func CheckJarPackages(ctx android.ModuleContext, outputFile android.WritablePath,
diff --git a/java/config/config.go b/java/config/config.go
index 7c29722..19d6952 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -42,6 +42,9 @@
InstrumentFrameworkModules = []string{
"framework",
"framework-minus-apex",
+ // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once
+ // we remove this module.
+ "framework-minus-apex_jarjar-sharded",
"ims-common",
"telephony-common",
"services",
diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go
index 4be7d04..6128ce3 100644
--- a/java/legacy_core_platform_api_usage.go
+++ b/java/legacy_core_platform_api_usage.go
@@ -28,6 +28,9 @@
"FloralClocks",
"framework-jobscheduler",
"framework-minus-apex",
+ // TODO(b/383559945) Remove "framework-minus-apex_jarjar-sharded" once
+ // we remove this module.
+ "framework-minus-apex_jarjar-sharded",
"framework-minus-apex-headers",
"framework-minus-apex-intdefs",
"FrameworksCoreTests",
diff --git a/rust/proc_macro.go b/rust/proc_macro.go
index 1ff6637..28ed68b 100644
--- a/rust/proc_macro.go
+++ b/rust/proc_macro.go
@@ -67,6 +67,7 @@
func (procMacro *procMacroDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = procMacro.baseCompiler.compilerFlags(ctx, flags)
flags.RustFlags = append(flags.RustFlags, "--extern proc_macro")
+ flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName())
return flags
}
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 84f20c5..77d5853 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -680,7 +680,7 @@
Sysprop_srcs: m.properties.Srcs,
Scope: scope,
Check_api: proptools.StringPtr(ctx.ModuleName()),
- Installable: proptools.BoolPtr(false),
+ Installable: m.properties.Installable,
Crate_name: m.rustCrateName(),
Rustlibs: []string{
"liblog_rust",