Use correct module name for java_import in shouldConvertWithBp2build verification
This change makes sure that prebuilt module has correct module name prefix("prebuilt_") inside method shouldConvertWithBp2build, to avoid the bp2build conflict issue when a normal module and a prebuilt module with the same name are both allowlisted. Test: CI, added unit tests and the steps to reproduce in b/303376793 Bug: 303376793 Bug: 303868211 Change-Id: I4f1126182ec1f52ae6a08046a77204939230edef
This commit is contained in:
@@ -544,7 +544,17 @@ func (b *BazelModuleBase) shouldConvertWithBp2build(ctx shouldConvertModuleConte
|
||||
}
|
||||
|
||||
moduleName := moduleNameWithPossibleOverride(ctx, module, p.moduleName)
|
||||
// use "prebuilt_" + original module name as the java_import(_host) module name,
|
||||
// to avoid the failure that a normal module and a prebuilt module with
|
||||
// the same name are both allowlisted. This cannot be applied to all the *_import
|
||||
// module types. For example, android_library_import has to use original module
|
||||
// name here otherwise the *-nodeps targets cannot be handled correctly.
|
||||
if strings.HasPrefix(p.moduleType, "java_import") {
|
||||
moduleName = module.Name()
|
||||
}
|
||||
|
||||
allowlist := ctx.Config().Bp2buildPackageConfig
|
||||
|
||||
moduleNameAllowed := allowlist.moduleAlwaysConvert[moduleName]
|
||||
moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[p.moduleType]
|
||||
allowlistConvert := moduleNameAllowed || moduleTypeAllowed
|
||||
|
Reference in New Issue
Block a user