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

Commit 5d52666b authored by Colin Cross's avatar Colin Cross
Browse files

Remove no longer used test_for functionality

test_for was only used for stubs resolution magic that has been removed,
remove the rest of the test_for logic.

Bug: 372543712
Test: builds
Flag: EXEMPT refactor
Change-Id: I1428c026613691b1c8bdce8cfa939fbad7272902
parent 3e85da88
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -160,14 +160,6 @@ func (i ApexInfo) Equal(other any) bool {
		reflect.DeepEqual(i.InApexModules, otherApexInfo.InApexModules)
}

// ApexTestForInfo stores the contents of APEXes for which this module is a test - although this
// module is not part of the APEX - and thus has access to APEX internals.
type ApexTestForInfo struct {
	ApexContents []*ApexContents
}

var ApexTestForInfoProvider = blueprint.NewMutatorProvider[ApexTestForInfo]("apex_test_for")

// ApexBundleInfo contains information about the dependencies of an apex
type ApexBundleInfo struct {
	Contents *ApexContents
@@ -269,12 +261,6 @@ type ApexModule interface {
	// check-platform-availability mutator in the apex package.
	SetNotAvailableForPlatform()

	// Returns the list of APEXes that this module is a test for. The module has access to the
	// private part of the listed APEXes even when it is not included in the APEXes. This by
	// default returns nil. A module type should override the default implementation. For
	// example, cc_test module type returns the value of test_for here.
	TestFor() []string

	// Returns nil (success) if this module should support the given sdk version. Returns an
	// error if not. No default implementation is provided for this method. A module type
	// implementing this interface should provide an implementation. A module supports an sdk
@@ -457,13 +443,6 @@ func (m *ApexModuleBase) IsInstallableToApex() bool {
	return false
}

// Implements ApexModule
func (m *ApexModuleBase) TestFor() []string {
	// If needed, this will be overridden by concrete types inheriting
	// ApexModuleBase
	return nil
}

// Returns the test apexes that this module is included in.
func (m *ApexModuleBase) TestApexes() []string {
	return m.ApexProperties.TestApexes
@@ -1062,12 +1041,6 @@ func MinSdkVersionFromValue(ctx EarlyModuleContext, value string) ApiLevel {
	return apiLevel
}

// Implemented by apexBundle.
type ApexTestInterface interface {
	// Return true if the apex bundle is an apex_test
	IsTestApex() bool
}

var ApexExportsInfoProvider = blueprint.NewProvider[ApexExportsInfo]()

// ApexExportsInfo contains information about the artifacts provided by apexes to dexpreopt and hiddenapi
+0 −41
Original line number Diff line number Diff line
@@ -63,8 +63,6 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
	ctx.TopDown("apex_info", apexInfoMutator)
	ctx.BottomUp("apex_unique", apexUniqueVariationsMutator)
	ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator)
	ctx.BottomUp("apex_test_for", apexTestForMutator)
	// Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether
	// it should create a platform variant.
	ctx.BottomUp("mark_platform_availability", markPlatformAvailability)
@@ -747,7 +745,6 @@ var (
	prebuiltTag     = &dependencyTag{name: "prebuilt", payload: true}
	rroTag          = &dependencyTag{name: "rro", payload: true}
	sharedLibTag    = &dependencyTag{name: "sharedLib", payload: true}
	testForTag      = &dependencyTag{name: "test for"}
	testTag         = &dependencyTag{name: "test", payload: true}
	shBinaryTag     = &dependencyTag{name: "shBinary", payload: true}
)
@@ -1185,40 +1182,6 @@ func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
	}
}

// apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on
// the apex in order to retrieve its contents later.
// TODO(jiyong): move this to android/apex.go?
func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
	if !mctx.Module().Enabled(mctx) {
		return
	}
	if am, ok := mctx.Module().(android.ApexModule); ok {
		if testFor := am.TestFor(); len(testFor) > 0 {
			mctx.AddFarVariationDependencies([]blueprint.Variation{
				{Mutator: "os", Variation: am.Target().OsVariation()},
				{"arch", "common"},
			}, testForTag, testFor...)
		}
	}
}

// TODO(jiyong): move this to android/apex.go?
func apexTestForMutator(mctx android.BottomUpMutatorContext) {
	if !mctx.Module().Enabled(mctx) {
		return
	}
	if _, ok := mctx.Module().(android.ApexModule); ok {
		var contents []*android.ApexContents
		for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) {
			abInfo, _ := android.OtherModuleProvider(mctx, testFor, android.ApexBundleInfoProvider)
			contents = append(contents, abInfo.Contents)
		}
		android.SetProvider(mctx, android.ApexTestForInfoProvider, android.ApexTestForInfo{
			ApexContents: contents,
		})
	}
}

// markPlatformAvailability marks whether or not a module can be available to platform. A module
// cannot be available to platform if 1) it is explicitly marked as not available (i.e.
// "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't
@@ -2941,10 +2904,6 @@ func rBcpPackages() map[string][]string {
	}
}

func (a *apexBundle) IsTestApex() bool {
	return a.testApex
}

// verifyNativeImplementationLibs compares the list of transitive implementation libraries used to link native
// libraries in the apex against the list of implementation libraries in the apex, ensuring that none of the
// libraries in the apex have references to private APIs from outside the apex.
+0 −10
Original line number Diff line number Diff line
@@ -394,11 +394,6 @@ type BaseProperties struct {
	// variant to have a ".sdk" suffix.
	SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"`

	// List of APEXes that this module has private access to for testing purpose. The module
	// can depend on libraries that are not exported by the APEXes and use private symbols
	// from the exported libraries.
	Test_for []string `android:"arch_variant"`

	Target struct {
		Platform struct {
			// List of modules required by the core variant.
@@ -949,7 +944,6 @@ func (c *Module) AddJSONData(d *map[string]interface{}) {
		"IsLlndk":                c.IsLlndk(),
		"IsVendorPublicLibrary":  c.IsVendorPublicLibrary(),
		"ApexSdkVersion":         c.apexSdkVersion,
		"TestFor":                c.TestFor(),
		"AidlSrcs":               c.hasAidl,
		"LexSrcs":                c.hasLex,
		"ProtoSrcs":              c.hasProto,
@@ -3652,10 +3646,6 @@ func (c *Module) AvailableFor(what string) bool {
	}
}

func (c *Module) TestFor() []string {
	return c.Properties.Test_for
}

func (c *Module) EverInstallable() bool {
	return c.installer != nil &&
		// Check to see whether the module is actually ever installable.