Loading java/java_test.go +64 −0 Original line number Diff line number Diff line Loading @@ -2643,6 +2643,70 @@ func TestMultiplePrebuilts(t *testing.T) { } } func TestMultiplePlatformCompatConfigPrebuilts(t *testing.T) { bp := ` // multiple variations of platform_compat_config // source platform_compat_config { name: "myconfig", } // prebuilt "v1" prebuilt_platform_compat_config { name: "myconfig", metadata: "myconfig.xml", } // prebuilt "v2" prebuilt_platform_compat_config { name: "myconfig.v2", source_module_name: "myconfig", // without source_module_name, the singleton will merge two .xml files metadata: "myconfig.v2.xml", } // selectors apex_contributions { name: "myapex_contributions", contents: ["%v"], } ` testCases := []struct { desc string selectedDependencyName string expectedPlatformCompatConfigXml string }{ { desc: "Source platform_compat_config is selected using apex_contributions", selectedDependencyName: "myconfig", expectedPlatformCompatConfigXml: "out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml", }, { desc: "Prebuilt platform_compat_config v1 is selected using apex_contributions", selectedDependencyName: "prebuilt_myconfig", expectedPlatformCompatConfigXml: "myconfig.xml", }, { desc: "Prebuilt platform_compat_config v2 is selected using apex_contributions", selectedDependencyName: "prebuilt_myconfig.v2", expectedPlatformCompatConfigXml: "myconfig.v2.xml", }, } for _, tc := range testCases { ctx := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithPlatformCompatConfig, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.BuildFlags = map[string]string{ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", } }), ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName)) mergedGlobalConfig := ctx.SingletonForTests("platform_compat_config_singleton").Output("compat_config/merged_compat_config.xml") android.AssertIntEquals(t, "The merged compat config file should only have a single dependency", 1, len(mergedGlobalConfig.Implicits)) android.AssertStringEquals(t, "The merged compat config file is missing the appropriate platform compat config", mergedGlobalConfig.Implicits[0].String(), tc.expectedPlatformCompatConfigXml) } } func TestApiLibraryAconfigDeclarations(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, Loading java/platform_compat_config.go +10 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "android/soong/android" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) func init() { Loading Loading @@ -184,6 +185,11 @@ type prebuiltCompatConfigModule struct { type prebuiltCompatConfigProperties struct { Metadata *string `android:"path"` // Name of the source soong module that gets shadowed by this prebuilt // If unspecified, follows the naming convention that the source module of // the prebuilt is Name() without "prebuilt_" prefix Source_module_name *string } func (module *prebuiltCompatConfigModule) Prebuilt() *android.Prebuilt { Loading @@ -198,6 +204,10 @@ func (module *prebuiltCompatConfigModule) compatConfigMetadata() android.Path { return module.metadataFile } func (module *prebuiltCompatConfigModule) BaseModuleName() string { return proptools.StringDefault(module.properties.Source_module_name, module.ModuleBase.Name()) } var _ platformCompatConfigMetadataProvider = (*prebuiltCompatConfigModule)(nil) func (module *prebuiltCompatConfigModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading Loading
java/java_test.go +64 −0 Original line number Diff line number Diff line Loading @@ -2643,6 +2643,70 @@ func TestMultiplePrebuilts(t *testing.T) { } } func TestMultiplePlatformCompatConfigPrebuilts(t *testing.T) { bp := ` // multiple variations of platform_compat_config // source platform_compat_config { name: "myconfig", } // prebuilt "v1" prebuilt_platform_compat_config { name: "myconfig", metadata: "myconfig.xml", } // prebuilt "v2" prebuilt_platform_compat_config { name: "myconfig.v2", source_module_name: "myconfig", // without source_module_name, the singleton will merge two .xml files metadata: "myconfig.v2.xml", } // selectors apex_contributions { name: "myapex_contributions", contents: ["%v"], } ` testCases := []struct { desc string selectedDependencyName string expectedPlatformCompatConfigXml string }{ { desc: "Source platform_compat_config is selected using apex_contributions", selectedDependencyName: "myconfig", expectedPlatformCompatConfigXml: "out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml", }, { desc: "Prebuilt platform_compat_config v1 is selected using apex_contributions", selectedDependencyName: "prebuilt_myconfig", expectedPlatformCompatConfigXml: "myconfig.xml", }, { desc: "Prebuilt platform_compat_config v2 is selected using apex_contributions", selectedDependencyName: "prebuilt_myconfig.v2", expectedPlatformCompatConfigXml: "myconfig.v2.xml", }, } for _, tc := range testCases { ctx := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithPlatformCompatConfig, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.BuildFlags = map[string]string{ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions", } }), ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName)) mergedGlobalConfig := ctx.SingletonForTests("platform_compat_config_singleton").Output("compat_config/merged_compat_config.xml") android.AssertIntEquals(t, "The merged compat config file should only have a single dependency", 1, len(mergedGlobalConfig.Implicits)) android.AssertStringEquals(t, "The merged compat config file is missing the appropriate platform compat config", mergedGlobalConfig.Implicits[0].String(), tc.expectedPlatformCompatConfigXml) } } func TestApiLibraryAconfigDeclarations(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, Loading
java/platform_compat_config.go +10 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "android/soong/android" "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) func init() { Loading Loading @@ -184,6 +185,11 @@ type prebuiltCompatConfigModule struct { type prebuiltCompatConfigProperties struct { Metadata *string `android:"path"` // Name of the source soong module that gets shadowed by this prebuilt // If unspecified, follows the naming convention that the source module of // the prebuilt is Name() without "prebuilt_" prefix Source_module_name *string } func (module *prebuiltCompatConfigModule) Prebuilt() *android.Prebuilt { Loading @@ -198,6 +204,10 @@ func (module *prebuiltCompatConfigModule) compatConfigMetadata() android.Path { return module.metadataFile } func (module *prebuiltCompatConfigModule) BaseModuleName() string { return proptools.StringDefault(module.properties.Source_module_name, module.ModuleBase.Name()) } var _ platformCompatConfigMetadataProvider = (*prebuiltCompatConfigModule)(nil) func (module *prebuiltCompatConfigModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { Loading