Link type will be check in android_library also
For now, Soong checks link-type in java_library, so it cannot block hidden api usage from android_library that app links with. So we should add check in 'android_library' Test: m nothing Change-Id: Ic040270ec668bdd693b690ac8a88be1048922c3b
This commit is contained in:
@@ -399,18 +399,21 @@ func TestAndroidResources(t *testing.T) {
|
|||||||
|
|
||||||
android_library {
|
android_library {
|
||||||
name: "lib",
|
name: "lib",
|
||||||
|
sdk_version: "current",
|
||||||
resource_dirs: ["lib/res"],
|
resource_dirs: ["lib/res"],
|
||||||
static_libs: ["lib2"],
|
static_libs: ["lib2"],
|
||||||
}
|
}
|
||||||
|
|
||||||
android_library {
|
android_library {
|
||||||
name: "lib2",
|
name: "lib2",
|
||||||
|
sdk_version: "current",
|
||||||
resource_dirs: ["lib2/res"],
|
resource_dirs: ["lib2/res"],
|
||||||
}
|
}
|
||||||
|
|
||||||
// This library has the same resources as lib (should not lead to dupe RROs)
|
// This library has the same resources as lib (should not lead to dupe RROs)
|
||||||
android_library {
|
android_library {
|
||||||
name: "lib3",
|
name: "lib3",
|
||||||
|
sdk_version: "current",
|
||||||
resource_dirs: ["lib/res"]
|
resource_dirs: ["lib/res"]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
20
java/java.go
20
java/java.go
@@ -672,7 +672,12 @@ const (
|
|||||||
javaPlatform
|
javaPlatform
|
||||||
)
|
)
|
||||||
|
|
||||||
func getLinkType(m *Module, name string) (ret linkType, stubs bool) {
|
type linkTypeContext interface {
|
||||||
|
android.Module
|
||||||
|
getLinkType(name string) (ret linkType, stubs bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Module) getLinkType(name string) (ret linkType, stubs bool) {
|
||||||
ver := m.sdkVersion()
|
ver := m.sdkVersion()
|
||||||
switch {
|
switch {
|
||||||
case name == "core.current.stubs" || name == "core.platform.api.stubs" ||
|
case name == "core.current.stubs" || name == "core.platform.api.stubs" ||
|
||||||
@@ -703,16 +708,16 @@ func getLinkType(m *Module, name string) (ret linkType, stubs bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) {
|
func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext, tag dependencyTag) {
|
||||||
if ctx.Host() {
|
if ctx.Host() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
myLinkType, stubs := getLinkType(from, ctx.ModuleName())
|
myLinkType, stubs := from.getLinkType(ctx.ModuleName())
|
||||||
if stubs {
|
if stubs {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
otherLinkType, _ := getLinkType(&to.Module, ctx.OtherModuleName(to))
|
otherLinkType, _ := to.getLinkType(ctx.OtherModuleName(to))
|
||||||
commonMessage := "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source."
|
commonMessage := "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source."
|
||||||
|
|
||||||
switch myLinkType {
|
switch myLinkType {
|
||||||
@@ -769,13 +774,16 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
// Handled by AndroidApp.collectAppDeps
|
// Handled by AndroidApp.collectAppDeps
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
switch module.(type) {
|
||||||
if to, ok := module.(*Library); ok {
|
case *Library:
|
||||||
|
case *AndroidLibrary:
|
||||||
|
if to, ok := module.(linkTypeContext); ok {
|
||||||
switch tag {
|
switch tag {
|
||||||
case bootClasspathTag, libTag, staticLibTag:
|
case bootClasspathTag, libTag, staticLibTag:
|
||||||
checkLinkType(ctx, j, to, tag.(dependencyTag))
|
checkLinkType(ctx, j, to, tag.(dependencyTag))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
switch dep := module.(type) {
|
switch dep := module.(type) {
|
||||||
case SdkLibraryDependency:
|
case SdkLibraryDependency:
|
||||||
switch tag {
|
switch tag {
|
||||||
|
Reference in New Issue
Block a user