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:
parent
1be9691910
commit
a1ce2a0071
2 changed files with 36 additions and 20 deletions
|
@ -131,11 +131,16 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) {
|
|||
func defaultsMutator(ctx TopDownMutatorContext) {
|
||||
if defaultable, ok := ctx.Module().(Defaultable); ok && len(defaultable.defaults().Defaults) > 0 {
|
||||
var defaultsList []Defaults
|
||||
seen := make(map[Defaults]bool)
|
||||
|
||||
ctx.WalkDeps(func(module, parent Module) bool {
|
||||
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
|
||||
if defaults, ok := module.(Defaults); ok {
|
||||
defaultsList = append(defaultsList, defaults)
|
||||
return len(defaults.defaults().Defaults) > 0
|
||||
if !seen[defaults] {
|
||||
seen[defaults] = true
|
||||
defaultsList = append(defaultsList, defaults)
|
||||
return len(defaults.defaults().Defaults) > 0
|
||||
}
|
||||
} else {
|
||||
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
|
||||
ctx.OtherModuleName(module))
|
||||
|
|
|
@ -99,6 +99,10 @@ func init() {
|
|||
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
||||
}
|
||||
|
||||
var (
|
||||
srcsLibTag = dependencyTag{name: "sources from javalib"}
|
||||
)
|
||||
|
||||
type JavadocProperties struct {
|
||||
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
||||
// or .aidl files.
|
||||
|
@ -348,6 +352,9 @@ func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
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)
|
||||
|
||||
|
@ -447,24 +454,6 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||
switch dep := module.(type) {
|
||||
case Dependency:
|
||||
deps.classpath = append(deps.classpath, dep.ImplementationJars()...)
|
||||
if otherName == String(j.properties.Srcs_lib) {
|
||||
srcs := dep.(SrcDependency).CompiledSrcs()
|
||||
whitelistPathPrefixes := make(map[string]bool)
|
||||
j.genWhitelistPathPrefixes(whitelistPathPrefixes)
|
||||
for _, src := range srcs {
|
||||
if _, ok := src.(android.WritablePath); ok { // generated sources
|
||||
deps.srcs = append(deps.srcs, src)
|
||||
} else { // select source path for documentation based on whitelist path prefixs.
|
||||
for k, _ := range whitelistPathPrefixes {
|
||||
if strings.HasPrefix(src.Rel(), k) {
|
||||
deps.srcs = append(deps.srcs, src)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
|
||||
}
|
||||
case SdkLibraryDependency:
|
||||
sdkVersion := String(j.properties.Sdk_version)
|
||||
linkType := javaSdk
|
||||
|
@ -480,6 +469,28 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||
default:
|
||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||
}
|
||||
case srcsLibTag:
|
||||
switch dep := module.(type) {
|
||||
case Dependency:
|
||||
srcs := dep.(SrcDependency).CompiledSrcs()
|
||||
whitelistPathPrefixes := make(map[string]bool)
|
||||
j.genWhitelistPathPrefixes(whitelistPathPrefixes)
|
||||
for _, src := range srcs {
|
||||
if _, ok := src.(android.WritablePath); ok { // generated sources
|
||||
deps.srcs = append(deps.srcs, src)
|
||||
} else { // select source path for documentation based on whitelist path prefixs.
|
||||
for k, _ := range whitelistPathPrefixes {
|
||||
if strings.HasPrefix(src.Rel(), k) {
|
||||
deps.srcs = append(deps.srcs, src)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
|
||||
default:
|
||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||
}
|
||||
case systemModulesTag:
|
||||
if deps.systemModules != nil {
|
||||
panic("Found two system module dependencies")
|
||||
|
|
Loading…
Reference in a new issue