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

Commit d5065cfc authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Add prebuilt_platform_compat_config"

parents 4b9bb5c0 1b29e003
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ var (
	executableTag   = dependencyTag{name: "executable", payload: true}
	fsTag           = dependencyTag{name: "filesystem", payload: true}
	bootImageTag    = dependencyTag{name: "bootImage", payload: true}
	compatConfigTag = dependencyTag{name: "compatConfig", payload: true}
	compatConfigTag = dependencyTag{name: "compatConfig", payload: true, sourceOnly: true}
	javaLibTag      = dependencyTag{name: "javaLib", payload: true}
	jniLibTag       = dependencyTag{name: "jniLib", payload: true}
	keyTag          = dependencyTag{name: "key"}
+7 −0
Original line number Diff line number Diff line
@@ -6018,6 +6018,13 @@ func TestCompatConfig(t *testing.T) {
			system_modules: "none",
			apex_available: [ "myapex" ],
		}

		// Make sure that a preferred prebuilt does not affect the apex contents.
		prebuilt_platform_compat_config {
			name: "myjar-platform-compat-config",
			metadata: "compat-config/metadata.xml",
			prefer: true,
		}
	`)
	ctx := result.TestContext
	ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
+44 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ func init() {
func registerPlatformCompatConfigBuildComponents(ctx android.RegistrationContext) {
	ctx.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
	ctx.RegisterModuleType("platform_compat_config", PlatformCompatConfigFactory)
	ctx.RegisterModuleType("prebuilt_platform_compat_config", prebuiltCompatConfigFactory)
	ctx.RegisterModuleType("global_compat_config", globalCompatConfigFactory)
}

@@ -116,6 +117,49 @@ func PlatformCompatConfigFactory() android.Module {
	return module
}

// A prebuilt version of the platform compat config module.
type prebuiltCompatConfigModule struct {
	android.ModuleBase
	android.SdkBase
	prebuilt android.Prebuilt

	properties prebuiltCompatConfigProperties

	metadataFile android.Path
}

type prebuiltCompatConfigProperties struct {
	Metadata *string `android:"path"`
}

func (module *prebuiltCompatConfigModule) Prebuilt() *android.Prebuilt {
	return &module.prebuilt
}

func (module *prebuiltCompatConfigModule) Name() string {
	return module.prebuilt.Name(module.ModuleBase.Name())
}

func (module *prebuiltCompatConfigModule) compatConfigMetadata() android.Path {
	return module.metadataFile
}

var _ platformCompatConfigMetadataProvider = (*prebuiltCompatConfigModule)(nil)

func (module *prebuiltCompatConfigModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	module.metadataFile = module.prebuilt.SingleSourcePath(ctx)
}

// A prebuilt version of platform_compat_config that provides the metadata.
func prebuiltCompatConfigFactory() android.Module {
	m := &prebuiltCompatConfigModule{}
	m.AddProperties(&m.properties)
	android.InitSingleSourcePrebuiltModule(m, &m.properties, "Metadata")
	android.InitSdkAwareModule(m)
	android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
	return m
}

// compat singleton rules
type platformCompatConfigSingleton struct {
	metadata android.Path