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

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

Merge "Remove TestApexes from ApexInfo" into main

parents 5c46a815 af4c8562
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -69,9 +69,6 @@ type ApexInfo struct {
	// See Prebuilt.ApexInfoMutator for more information.
	ForPrebuiltApex bool

	// Returns the name of the test apexes that this module is included in.
	TestApexes []string

	// Returns the name of the overridden apex (com.android.foo)
	BaseApexName string

@@ -283,9 +280,6 @@ type ApexProperties struct {

	// See ApexModule.UniqueApexVariants()
	UniqueApexVariationsForDeps bool `blueprint:"mutated"`

	// The test apexes that includes this apex variant
	TestApexes []string `blueprint:"mutated"`
}

// Marker interface that identifies dependencies that are excluded from APEX contents.
@@ -389,11 +383,6 @@ func (m *ApexModuleBase) IsInstallableToApex() bool {
	return false
}

// Returns the test apexes that this module is included in.
func (m *ApexModuleBase) TestApexes() []string {
	return m.ApexProperties.TestApexes
}

// Implements ApexModule
func (m *ApexModuleBase) UniqueApexVariations() bool {
	// If needed, this will bel overridden by concrete types inheriting
@@ -547,12 +536,10 @@ func mergeApexVariations(apexInfos []ApexInfo) (merged []ApexInfo, aliases [][2]
			// Platform APIs is allowed for this module only when all APEXes containing
			// the module are with `use_platform_apis: true`.
			merged[index].UsePlatformApis = merged[index].UsePlatformApis && apexInfo.UsePlatformApis
			merged[index].TestApexes = append(merged[index].TestApexes, apexInfo.TestApexes...)
		} else {
			seen[mergedName] = len(merged)
			apexInfo.ApexVariationName = mergedName
			apexInfo.InApexVariants = CopyOf(apexInfo.InApexVariants)
			apexInfo.TestApexes = CopyOf(apexInfo.TestApexes)
			merged = append(merged, apexInfo)
		}
		aliases = append(aliases, [2]string{variantName, mergedName})
@@ -660,15 +647,6 @@ func MutateApexTransition(ctx BaseModuleContext, variation string) {

		SetProvider(ctx, ApexInfoProvider, thisApexInfo)
	}

	// Set the value of TestApexes in every single apex variant.
	// This allows each apex variant to be aware of the test apexes in the user provided apex_available.
	var testApexes []string
	for _, a := range apexInfos {
		testApexes = append(testApexes, a.TestApexes...)
	}
	base.ApexProperties.TestApexes = testApexes

}

func ApexInfoMutator(ctx TopDownMutatorContext, module ApexModule) {
+0 −5
Original line number Diff line number Diff line
@@ -988,17 +988,12 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
	}

	a.properties.ApexVariationName = apexVariationName
	testApexes := []string{}
	if a.testApex {
		testApexes = []string{apexVariationName}
	}
	apexInfo := android.ApexInfo{
		ApexVariationName: apexVariationName,
		MinSdkVersion:     minSdkVersion,
		Updatable:         a.Updatable(),
		UsePlatformApis:   a.UsePlatformApis(),
		InApexVariants:    []string{apexVariationName},
		TestApexes:        testApexes,
		BaseApexName:      mctx.ModuleName(),
		ApexAvailableName: proptools.String(a.properties.Apex_available_name),
	}
+17 −14
Original line number Diff line number Diff line
@@ -10164,9 +10164,9 @@ func TestStubLibrariesMultipleApexViolation(t *testing.T) {
			expectedError: "Stub libraries should have a single apex_available.*myapex.*otherapex",
		},
		{
			desc:          "stub library can be available to a core apex and a test apex",
			desc:          "stub library can be available to a core apex and a test apex using apex_available_name",
			hasStubs:      true,
			apexAvailable: `["myapex", "test_myapex"]`,
			apexAvailable: `["myapex"]`,
		},
	}
	bpTemplate := `
@@ -10191,12 +10191,14 @@ func TestStubLibrariesMultipleApexViolation(t *testing.T) {
			key: "apex.key",
			updatable: false,
			native_shared_libs: ["libfoo"],
			apex_available_name: "myapex",
		}
		apex_key {
			name: "apex.key",
		}
	`
	for _, tc := range testCases {
		t.Run(tc.desc, func(t *testing.T) {
			stubs := ""
			if tc.hasStubs {
				stubs = `stubs: {symbol_file: "libfoo.map.txt"},`
@@ -10210,6 +10212,7 @@ func TestStubLibrariesMultipleApexViolation(t *testing.T) {
			} else {
				testApexError(t, tc.expectedError, bp, mockFsFixturePreparer)
			}
		})
	}
}

+3 −3
Original line number Diff line number Diff line
@@ -1955,13 +1955,13 @@ func (c *Module) stubLibraryMultipleApexViolation(ctx android.ModuleContext) boo
		return false
	}

	_, aaWithoutTestApexes, _ := android.ListSetDifference(c.ApexAvailable(), c.TestApexes())
	// Stub libraries should not have more than one apex_available
	if len(aaWithoutTestApexes) > 1 {
	apexAvailable := android.FirstUniqueStrings(c.ApexAvailable())
	if len(apexAvailable) > 1 {
		return true
	}
	// Stub libraries should not use the wildcard
	if aaWithoutTestApexes[0] == android.AvailableToAnyApex {
	if apexAvailable[0] == android.AvailableToAnyApex {
		return true
	}
	// Default: no violation
+5 −6
Original line number Diff line number Diff line
@@ -211,20 +211,19 @@ func disableSourceApexVariant(ctx android.BaseModuleContext) bool {
	})

	// Find the apex variant for this module
	apexVariantsWithoutTestApexes := []string{}
	apexVariants := []string{}
	if apexInfo.BaseApexName != "" {
		// This is a transitive dependency of an override_apex
		apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.BaseApexName)
		apexVariants = append(apexVariants, apexInfo.BaseApexName)
	} else {
		_, variants, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
		apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, variants...)
		apexVariants = append(apexVariants, apexInfo.InApexVariants...)
	}
	if apexInfo.ApexAvailableName != "" {
		apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.ApexAvailableName)
		apexVariants = append(apexVariants, apexInfo.ApexAvailableName)
	}
	disableSource := false
	// find the selected apexes
	for _, apexVariant := range apexVariantsWithoutTestApexes {
	for _, apexVariant := range apexVariants {
		if len(psi.GetSelectedModulesForApiDomain(apexVariant)) > 0 {
			// If the apex_contribution for this api domain is non-empty, disable the source variant
			disableSource = true