Merge "Add prebuilt_platform_compat_config"

This commit is contained in:
Paul Duffin 2021-03-18 12:28:00 +00:00 committed by Gerrit Code Review
commit d5065cfc66
3 changed files with 52 additions and 1 deletions

View File

@ -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"}

View File

@ -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{

View File

@ -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