Update soong for blueprint change to allow multiple deps
Blueprint allows multiple dependencies on the same module after https://github.com/google/blueprint/pull/210. Fix defaults, WalkDeps can now find the same defaults module multiple times. Fix droiddoc, if the srcs_lib points to a lib module that is specified multiple times, for example through explicit properties and implicit default libraries, the srcs would be listed on the command line multiple times. Move srcs_lib to use its own dependency tag. Test: m checkbuild Change-Id: Ia30ce83be1382820d76bca5046ad18cbffe8af1a
This commit is contained in:
@@ -131,11 +131,16 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) {
|
|||||||
func defaultsMutator(ctx TopDownMutatorContext) {
|
func defaultsMutator(ctx TopDownMutatorContext) {
|
||||||
if defaultable, ok := ctx.Module().(Defaultable); ok && len(defaultable.defaults().Defaults) > 0 {
|
if defaultable, ok := ctx.Module().(Defaultable); ok && len(defaultable.defaults().Defaults) > 0 {
|
||||||
var defaultsList []Defaults
|
var defaultsList []Defaults
|
||||||
|
seen := make(map[Defaults]bool)
|
||||||
|
|
||||||
ctx.WalkDeps(func(module, parent Module) bool {
|
ctx.WalkDeps(func(module, parent Module) bool {
|
||||||
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
|
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
|
||||||
if defaults, ok := module.(Defaults); ok {
|
if defaults, ok := module.(Defaults); ok {
|
||||||
|
if !seen[defaults] {
|
||||||
|
seen[defaults] = true
|
||||||
defaultsList = append(defaultsList, defaults)
|
defaultsList = append(defaultsList, defaults)
|
||||||
return len(defaults.defaults().Defaults) > 0
|
return len(defaults.defaults().Defaults) > 0
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
|
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
|
||||||
ctx.OtherModuleName(module))
|
ctx.OtherModuleName(module))
|
||||||
|
@@ -99,6 +99,10 @@ func init() {
|
|||||||
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
srcsLibTag = dependencyTag{name: "sources from javalib"}
|
||||||
|
)
|
||||||
|
|
||||||
type JavadocProperties struct {
|
type JavadocProperties struct {
|
||||||
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
||||||
// or .aidl files.
|
// or .aidl files.
|
||||||
@@ -348,6 +352,9 @@ func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||||
|
if j.properties.Srcs_lib != nil {
|
||||||
|
ctx.AddDependency(ctx.Module(), srcsLibTag, *j.properties.Srcs_lib)
|
||||||
|
}
|
||||||
|
|
||||||
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
||||||
|
|
||||||
@@ -447,7 +454,24 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
switch dep := module.(type) {
|
switch dep := module.(type) {
|
||||||
case Dependency:
|
case Dependency:
|
||||||
deps.classpath = append(deps.classpath, dep.ImplementationJars()...)
|
deps.classpath = append(deps.classpath, dep.ImplementationJars()...)
|
||||||
if otherName == String(j.properties.Srcs_lib) {
|
case SdkLibraryDependency:
|
||||||
|
sdkVersion := String(j.properties.Sdk_version)
|
||||||
|
linkType := javaSdk
|
||||||
|
if strings.HasPrefix(sdkVersion, "system_") || strings.HasPrefix(sdkVersion, "test_") {
|
||||||
|
linkType = javaSystem
|
||||||
|
} else if sdkVersion == "" {
|
||||||
|
linkType = javaPlatform
|
||||||
|
}
|
||||||
|
deps.classpath = append(deps.classpath, dep.HeaderJars(linkType)...)
|
||||||
|
case android.SourceFileProducer:
|
||||||
|
checkProducesJars(ctx, dep)
|
||||||
|
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
||||||
|
default:
|
||||||
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
|
}
|
||||||
|
case srcsLibTag:
|
||||||
|
switch dep := module.(type) {
|
||||||
|
case Dependency:
|
||||||
srcs := dep.(SrcDependency).CompiledSrcs()
|
srcs := dep.(SrcDependency).CompiledSrcs()
|
||||||
whitelistPathPrefixes := make(map[string]bool)
|
whitelistPathPrefixes := make(map[string]bool)
|
||||||
j.genWhitelistPathPrefixes(whitelistPathPrefixes)
|
j.genWhitelistPathPrefixes(whitelistPathPrefixes)
|
||||||
@@ -464,19 +488,6 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
|
deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
|
||||||
}
|
|
||||||
case SdkLibraryDependency:
|
|
||||||
sdkVersion := String(j.properties.Sdk_version)
|
|
||||||
linkType := javaSdk
|
|
||||||
if strings.HasPrefix(sdkVersion, "system_") || strings.HasPrefix(sdkVersion, "test_") {
|
|
||||||
linkType = javaSystem
|
|
||||||
} else if sdkVersion == "" {
|
|
||||||
linkType = javaPlatform
|
|
||||||
}
|
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars(linkType)...)
|
|
||||||
case android.SourceFileProducer:
|
|
||||||
checkProducesJars(ctx, dep)
|
|
||||||
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
|
||||||
default:
|
default:
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user