Merge changes I45274836,I47268b81 am: de21202bd2
am: 6c9d9bd3b1
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1665746 Change-Id: I54195a9d8abc4fc7b835ea89f20e7e9e643ddb2c
This commit is contained in:
commit
73057c5172
|
@ -82,6 +82,12 @@ func RemoveOptionalPrebuiltPrefix(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prebuilt) Name(name string) string {
|
func (p *Prebuilt) Name(name string) string {
|
||||||
|
return PrebuiltNameFromSource(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrebuiltNameFromSource returns the result of prepending the "prebuilt_" prefix to the supplied
|
||||||
|
// name.
|
||||||
|
func PrebuiltNameFromSource(name string) string {
|
||||||
return "prebuilt_" + name
|
return "prebuilt_" + name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +219,26 @@ type PrebuiltInterface interface {
|
||||||
Prebuilt() *Prebuilt
|
Prebuilt() *Prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsModulePreferred returns true if the given module is preferred.
|
||||||
|
//
|
||||||
|
// A source module is preferred if there is no corresponding prebuilt module or the prebuilt module
|
||||||
|
// does not have "prefer: true".
|
||||||
|
//
|
||||||
|
// A prebuilt module is preferred if there is no corresponding source module or the prebuilt module
|
||||||
|
// has "prefer: true".
|
||||||
|
func IsModulePreferred(module Module) bool {
|
||||||
|
if module.IsReplacedByPrebuilt() {
|
||||||
|
// A source module that has been replaced by a prebuilt counterpart.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if prebuilt, ok := module.(PrebuiltInterface); ok {
|
||||||
|
if p := prebuilt.Prebuilt(); p != nil {
|
||||||
|
return p.UsePrebuilt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPrebuiltsPreArchMutators(ctx RegisterMutatorsContext) {
|
func RegisterPrebuiltsPreArchMutators(ctx RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("prebuilt_rename", PrebuiltRenameMutator).Parallel()
|
ctx.BottomUp("prebuilt_rename", PrebuiltRenameMutator).Parallel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ func prebuiltApexExportedModuleName(ctx android.BottomUpMutatorContext, name str
|
||||||
// the unprefixed name is the one to use. If the unprefixed one turns out to be a source module
|
// the unprefixed name is the one to use. If the unprefixed one turns out to be a source module
|
||||||
// and not a renamed prebuilt module then that will be detected and reported as an error when
|
// and not a renamed prebuilt module then that will be detected and reported as an error when
|
||||||
// processing the dependency in ApexInfoMutator().
|
// processing the dependency in ApexInfoMutator().
|
||||||
prebuiltName := "prebuilt_" + name
|
prebuiltName := android.PrebuiltNameFromSource(name)
|
||||||
if ctx.OtherModuleExists(prebuiltName) {
|
if ctx.OtherModuleExists(prebuiltName) {
|
||||||
name = prebuiltName
|
name = prebuiltName
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,7 @@ func isActiveModule(module android.Module) bool {
|
||||||
if !module.Enabled() {
|
if !module.Enabled() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if module.IsReplacedByPrebuilt() {
|
return android.IsModulePreferred(module)
|
||||||
// A source module that has been replaced by a prebuilt counterpart.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if prebuilt, ok := module.(android.PrebuiltInterface); ok {
|
|
||||||
if p := prebuilt.Prebuilt(); p != nil {
|
|
||||||
return p.UsePrebuilt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
|
|
|
@ -232,15 +232,7 @@ func isModulePreferredByCompatConfig(module android.Module) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A prebuilt module should only be used when it is preferred.
|
return android.IsModulePreferred(module)
|
||||||
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) {
|
||||||
|
|
|
@ -1945,11 +1945,11 @@ func (module *SdkLibraryImport) ComponentDepsMutator(ctx android.BottomUpMutator
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add dependencies to the prebuilt stubs library
|
// Add dependencies to the prebuilt stubs library
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsTag, "prebuilt_"+module.stubsLibraryModuleName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, android.PrebuiltNameFromSource(module.stubsLibraryModuleName(apiScope)))
|
||||||
|
|
||||||
if len(scopeProperties.Stub_srcs) > 0 {
|
if len(scopeProperties.Stub_srcs) > 0 {
|
||||||
// Add dependencies to the prebuilt stubs source library
|
// Add dependencies to the prebuilt stubs source library
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsSourceTag, "prebuilt_"+module.stubsSourceModuleName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.stubsSourceTag, android.PrebuiltNameFromSource(module.stubsSourceModuleName(apiScope)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ func (system *systemModulesImport) Prebuilt() *android.Prebuilt {
|
||||||
// modules.
|
// modules.
|
||||||
func (system *systemModulesImport) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
func (system *systemModulesImport) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for _, lib := range system.properties.Libs {
|
for _, lib := range system.properties.Libs {
|
||||||
ctx.AddVariationDependencies(nil, systemModulesLibsTag, "prebuilt_"+lib)
|
ctx.AddVariationDependencies(nil, systemModulesLibsTag, android.PrebuiltNameFromSource(lib))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue