Merge "Filter duplicate modules in platform_compat_config_singleton"
This commit is contained in:
@@ -221,12 +221,40 @@ type platformCompatConfigSingleton struct {
|
|||||||
metadata android.Path
|
metadata android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isModulePreferredByCompatConfig checks to see whether the module is preferred for use by
|
||||||
|
// platform compat config.
|
||||||
|
func isModulePreferredByCompatConfig(module android.Module) bool {
|
||||||
|
// A versioned prebuilt_platform_compat_config, i.e. foo-platform-compat-config@current should be
|
||||||
|
// ignored.
|
||||||
|
if s, ok := module.(android.SdkAware); ok {
|
||||||
|
if !s.ContainingSdk().Unversioned() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A prebuilt module should only be used when it is preferred.
|
||||||
|
if pi, ok := module.(android.PrebuiltInterface); ok {
|
||||||
|
if p := pi.Prebuilt(); p != nil {
|
||||||
|
return p.UsePrebuilt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, a module should only be used if it has not been replaced by a prebuilt.
|
||||||
|
return !module.IsReplacedByPrebuilt()
|
||||||
|
}
|
||||||
|
|
||||||
func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
|
|
||||||
var compatConfigMetadata android.Paths
|
var compatConfigMetadata android.Paths
|
||||||
|
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
|
if !module.Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if c, ok := module.(platformCompatConfigMetadataProvider); ok {
|
if c, ok := module.(platformCompatConfigMetadataProvider); ok {
|
||||||
|
if !isModulePreferredByCompatConfig(module) {
|
||||||
|
return
|
||||||
|
}
|
||||||
metadata := c.compatConfigMetadata()
|
metadata := c.compatConfigMetadata()
|
||||||
compatConfigMetadata = append(compatConfigMetadata, metadata)
|
compatConfigMetadata = append(compatConfigMetadata, metadata)
|
||||||
}
|
}
|
||||||
|
@@ -77,8 +77,6 @@ prebuilt_platform_compat_config {
|
|||||||
// Make sure that the snapshot metadata is collated by the platform compat config singleton.
|
// Make sure that the snapshot metadata is collated by the platform compat config singleton.
|
||||||
java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
|
java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
|
||||||
"out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
|
"out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
|
||||||
// TODO(b/182402754): Remove this as only the config file from the preferred module should be used.
|
|
||||||
"snapshot/compat_configs/myconfig/myconfig_meta.xml",
|
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -86,8 +84,6 @@ prebuilt_platform_compat_config {
|
|||||||
func(t *testing.T, result *android.TestResult) {
|
func(t *testing.T, result *android.TestResult) {
|
||||||
// Make sure that the snapshot metadata is collated by the platform compat config singleton.
|
// Make sure that the snapshot metadata is collated by the platform compat config singleton.
|
||||||
java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
|
java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
|
||||||
"out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
|
|
||||||
// TODO(b/182402754): Remove this as only the config file from the preferred module should be used.
|
|
||||||
"snapshot/compat_configs/myconfig/myconfig_meta.xml",
|
"snapshot/compat_configs/myconfig/myconfig_meta.xml",
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user