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 {
|
||||||
defaultsList = append(defaultsList, defaults)
|
if !seen[defaults] {
|
||||||
return len(defaults.defaults().Defaults) > 0
|
seen[defaults] = true
|
||||||
|
defaultsList = append(defaultsList, defaults)
|
||||||
|
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,24 +454,6 @@ 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) {
|
|
||||||
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:
|
case SdkLibraryDependency:
|
||||||
sdkVersion := String(j.properties.Sdk_version)
|
sdkVersion := String(j.properties.Sdk_version)
|
||||||
linkType := javaSdk
|
linkType := javaSdk
|
||||||
@@ -480,6 +469,28 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
default:
|
default:
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
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:
|
case systemModulesTag:
|
||||||
if deps.systemModules != nil {
|
if deps.systemModules != nil {
|
||||||
panic("Found two system module dependencies")
|
panic("Found two system module dependencies")
|
||||||
|
Reference in New Issue
Block a user