Make java_sdk_library implement Dependency

dexpreopting boot jars is going to need to visit both java_library
and java_sdk_library modules.  Since java_sdk_library is already
a java_library module, move the SdkLibraryDependency methods out
of the way so that it will implement Dependency.  Also requries
re-ording some of the type switches to check for the more-specific
SdkLibraryDependency first.

Test: TestJavaSdkLibrary
Change-Id: I155c9ffaf31689dd150a4d99e07e432ff770b4a7
This commit is contained in:
Colin Cross
2019-02-11 14:03:51 -08:00
parent c7e40aa578
commit 897d2ed92f
3 changed files with 18 additions and 15 deletions

View File

@@ -338,8 +338,8 @@ type Dependency interface {
}
type SdkLibraryDependency interface {
HeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths
ImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths
SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths
SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths
}
type SrcDependency interface {
@@ -698,6 +698,15 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
}
switch dep := module.(type) {
case SdkLibraryDependency:
switch tag {
case libTag:
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
// names of sdk libs that are directly depended are exported
j.exportedSdkLibs = append(j.exportedSdkLibs, otherName)
default:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
case Dependency:
switch tag {
case bootClasspathTag:
@@ -748,15 +757,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
case SdkLibraryDependency:
switch tag {
case libTag:
deps.classpath = append(deps.classpath, dep.HeaderJars(ctx, j.sdkVersion())...)
// names of sdk libs that are directly depended are exported
j.exportedSdkLibs = append(j.exportedSdkLibs, otherName)
default:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
case android.SourceFileProducer:
switch tag {
case libTag: