Delete trim_against support
trim_against is never set in Android.bp files, and PRODUCT_TRIMMED_APEX
is never set to set the TrimmedApex config variable. Delete all the
dead code that is never reached.
Test: builds
Flag: EXEMPT dead code removal
Change-Id: I1dd2e2a5bcb1c38148149264776c718e02291649
diff --git a/android/config.go b/android/config.go
index feed22f..380cd1c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1786,10 +1786,6 @@
return Bool(c.productVariables.CompressedApex) && !c.UnbundledBuildApps()
}
-func (c *config) ApexTrimEnabled() bool {
- return Bool(c.productVariables.TrimmedApex)
-}
-
func (c *config) UseSoongSystemImage() bool {
return Bool(c.productVariables.UseSoongSystemImage)
}
diff --git a/android/testing.go b/android/testing.go
index 23aadda..f243e81 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1132,11 +1132,6 @@
config.katiEnabled = true
}
-func SetTrimmedApexEnabledForTests(config Config) {
- config.productVariables.TrimmedApex = new(bool)
- *config.productVariables.TrimmedApex = true
-}
-
func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod blueprint.Module) []AndroidMkEntries {
t.Helper()
var p AndroidMkEntriesProvider
diff --git a/android/variable.go b/android/variable.go
index 6693d91..2969f97 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -401,7 +401,6 @@
Ndk_abis *bool `json:",omitempty"`
- TrimmedApex *bool `json:",omitempty"`
ForceApexSymlinkOptimization *bool `json:",omitempty"`
CompressedApex *bool `json:",omitempty"`
Aml_abis *bool `json:",omitempty"`
@@ -645,7 +644,6 @@
Malloc_zero_contents: boolPtr(true),
Malloc_pattern_fill_contents: boolPtr(false),
Safestack: boolPtr(false),
- TrimmedApex: boolPtr(false),
Build_from_text_stub: boolPtr(false),
BootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}},
diff --git a/apex/apex.go b/apex/apex.go
index 7ea5e0d..a1879f5 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -68,7 +68,6 @@
ctx.BottomUp("mark_platform_availability", markPlatformAvailability)
ctx.Transition("apex", &apexTransitionMutator{})
ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).MutatesDependencies()
- ctx.BottomUp("apex_dcla_deps", apexDCLADepsMutator)
}
type apexBundleProperties struct {
@@ -732,7 +731,6 @@
androidAppTag = &dependencyTag{name: "androidApp", payload: true}
bpfTag = &dependencyTag{name: "bpf", payload: true}
certificateTag = &dependencyTag{name: "certificate"}
- dclaTag = &dependencyTag{name: "dcla"}
executableTag = &dependencyTag{name: "executable", payload: true}
fsTag = &dependencyTag{name: "filesystem", payload: true}
bcpfTag = &dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true, memberType: java.BootclasspathFragmentSdkMemberType}
@@ -949,33 +947,6 @@
}
}
-func apexDCLADepsMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Config().ApexTrimEnabled() {
- return
- }
- if a, ok := mctx.Module().(*apexBundle); ok && a.overridableProperties.Trim_against != nil {
- commonVariation := mctx.Config().AndroidCommonTarget.Variations()
- mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(a.overridableProperties.Trim_against))
- } else if o, ok := mctx.Module().(*OverrideApex); ok {
- for _, p := range o.GetProperties() {
- properties, ok := p.(*overridableProperties)
- if !ok {
- continue
- }
- if properties.Trim_against != nil {
- commonVariation := mctx.Config().AndroidCommonTarget.Variations()
- mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(properties.Trim_against))
- }
- }
- }
-}
-
-type DCLAInfo struct {
- ProvidedLibs []string
-}
-
-var DCLAInfoProvider = blueprint.NewMutatorProvider[DCLAInfo]("apex_info")
-
var _ ApexInfoMutator = (*apexBundle)(nil)
func (a *apexBundle) ApexVariationName() string {
@@ -1084,12 +1055,6 @@
child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark!
return true
})
-
- if a.dynamic_common_lib_apex() {
- android.SetProvider(mctx, DCLAInfoProvider, DCLAInfo{
- ProvidedLibs: a.properties.Native_shared_libs.GetOrDefault(mctx, nil),
- })
- }
}
type ApexInfoMutator interface {
@@ -1405,19 +1370,6 @@
return proptools.BoolDefault(a.properties.Dynamic_common_lib_apex, false)
}
-// See the list of libs to trim
-func (a *apexBundle) libs_to_trim(ctx android.ModuleContext) []string {
- dclaModules := ctx.GetDirectDepsWithTag(dclaTag)
- if len(dclaModules) > 1 {
- panic(fmt.Errorf("expected exactly at most one dcla dependency, got %d", len(dclaModules)))
- }
- if len(dclaModules) > 0 {
- DCLAInfo, _ := android.OtherModuleProvider(ctx, dclaModules[0], DCLAInfoProvider)
- return DCLAInfo.ProvidedLibs
- }
- return []string{}
-}
-
// These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its
// members) can be sanitized, either forcibly, or by the global configuration. For some of the
// sanitizers, extra dependencies can be forcibly added as well.
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 4e6aa13..8c17afe 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -10053,61 +10053,6 @@
RunTestWithBp(t, bp)
}
-func TestTrimmedApex(t *testing.T) {
- t.Parallel()
- bp := `
- apex {
- name: "myapex",
- key: "myapex.key",
- native_shared_libs: ["libfoo","libbaz"],
- min_sdk_version: "29",
- trim_against: "mydcla",
- }
- apex {
- name: "mydcla",
- key: "myapex.key",
- native_shared_libs: ["libfoo","libbar"],
- min_sdk_version: "29",
- file_contexts: ":myapex-file_contexts",
- dynamic_common_lib_apex: true,
- }
- apex_key {
- name: "myapex.key",
- }
- cc_library {
- name: "libfoo",
- shared_libs: ["libc"],
- apex_available: ["myapex","mydcla"],
- min_sdk_version: "29",
- }
- cc_library {
- name: "libbar",
- shared_libs: ["libc"],
- apex_available: ["myapex","mydcla"],
- min_sdk_version: "29",
- }
- cc_library {
- name: "libbaz",
- shared_libs: ["libc"],
- apex_available: ["myapex","mydcla"],
- min_sdk_version: "29",
- }
- `
- ctx := testApex(t, bp)
- module := ctx.ModuleForTests("myapex", "android_common_myapex")
- apexRule := module.MaybeRule("apexRule")
- if apexRule.Rule == nil {
- t.Errorf("Expecting regular apex rule but a non regular apex rule found")
- }
-
- ctx = testApex(t, bp, android.FixtureModifyConfig(android.SetTrimmedApexEnabledForTests))
- trimmedApexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("TrimmedApexRule")
- libs_to_trim := trimmedApexRule.Args["libs_to_trim"]
- android.AssertStringDoesContain(t, "missing lib to trim", libs_to_trim, "libfoo")
- android.AssertStringDoesContain(t, "missing lib to trim", libs_to_trim, "libbar")
- android.AssertStringDoesNotContain(t, "unexpected libs in the libs to trim", libs_to_trim, "libbaz")
-}
-
func TestCannedFsConfig(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
diff --git a/apex/builder.go b/apex/builder.go
index 20b4dbe..305d509 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -43,7 +43,6 @@
pctx.Import("android/soong/java")
pctx.HostBinToolVariable("apexer", "apexer")
pctx.HostBinToolVariable("apexer_with_DCLA_preprocessing", "apexer_with_DCLA_preprocessing")
- pctx.HostBinToolVariable("apexer_with_trim_preprocessing", "apexer_with_trim_preprocessing")
// ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
// projects, and hence cannot build 'aapt2'. Use the SDK prebuilt instead.
@@ -173,34 +172,6 @@
}, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key",
"opt_flags", "manifest", "is_DCLA")
- TrimmedApexRule = pctx.StaticRule("TrimmedApexRule", blueprint.RuleParams{
- Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
- `(. ${out}.copy_commands) && ` +
- `APEXER_TOOL_PATH=${tool_path} ` +
- `${apexer_with_trim_preprocessing} ` +
- `--apexer ${apexer} ` +
- `--canned_fs_config ${canned_fs_config} ` +
- `--manifest ${manifest} ` +
- `--libs_to_trim ${libs_to_trim} ` +
- `${image_dir} ` +
- `${out} ` +
- `-- ` +
- `--include_build_info ` +
- `--force ` +
- `--payload_type image ` +
- `--key ${key} ` +
- `--file_contexts ${file_contexts} ` +
- `${opt_flags} `,
- CommandDeps: []string{"${apexer_with_trim_preprocessing}", "${apexer}", "${avbtool}", "${e2fsdroid}",
- "${merge_zips}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${make_f2fs}",
- "${sload_f2fs}", "${make_erofs}", "${soong_zip}", "${zipalign}", "${aapt2}",
- "prebuilts/sdk/current/public/android.jar"},
- Rspfile: "${out}.copy_commands",
- RspfileContent: "${copy_commands}",
- Description: "APEX ${image_dir} => ${out}",
- }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key",
- "opt_flags", "manifest", "libs_to_trim")
-
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
blueprint.RuleParams{
Command: `${aapt2} convert --output-format proto $in -o $out`,
@@ -831,24 +802,6 @@
"opt_flags": strings.Join(optFlags, " "),
},
})
- } else if ctx.Config().ApexTrimEnabled() && len(a.libs_to_trim(ctx)) > 0 {
- ctx.Build(pctx, android.BuildParams{
- Rule: TrimmedApexRule,
- Implicits: implicitInputs,
- Output: unsignedOutputFile,
- Description: "apex",
- Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": imageDir.String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
- "file_contexts": fileContexts.String(),
- "canned_fs_config": cannedFsConfig.String(),
- "key": a.privateKeyFile.String(),
- "opt_flags": strings.Join(optFlags, " "),
- "libs_to_trim": strings.Join(a.libs_to_trim(ctx), ","),
- },
- })
} else {
ctx.Build(pctx, android.BuildParams{
Rule: apexRule,