Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85fced17 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge "Delete trim_against support" into main

parents 327a5f0b cc27a84f
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1834,10 +1834,6 @@ func (c *config) ApexCompressionEnabled() bool {
	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)
}
+0 −5
Original line number Diff line number Diff line
@@ -1132,11 +1132,6 @@ func SetKatiEnabledForTests(config Config) {
	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
+0 −2
Original line number Diff line number Diff line
@@ -408,7 +408,6 @@ type ProductVariables struct {

	Ndk_abis *bool `json:",omitempty"`

	TrimmedApex                  *bool `json:",omitempty"`
	ForceApexSymlinkOptimization *bool `json:",omitempty"`
	CompressedApex               *bool `json:",omitempty"`
	Aml_abis                     *bool `json:",omitempty"`
@@ -680,7 +679,6 @@ func (v *ProductVariables) SetDefaultConfig() {
		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{}},
+0 −48
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
	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 @@ var (
	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 (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato
	}
}

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 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
		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 @@ func (a *apexBundle) dynamic_common_lib_apex() bool {
	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.
+0 −55
Original line number Diff line number Diff line
@@ -10053,61 +10053,6 @@ func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {
		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, `
Loading