diff options
| author | 2018-03-26 14:42:44 -0700 | |
|---|---|---|
| committer | 2018-04-10 17:06:21 +0000 | |
| commit | f19b9bb9819fbe36a05c31e193135a9b3b2e8388 (patch) | |
| tree | 9de2ef5106c63448cd73283fb77926fe7be815ec /java/java.go | |
| parent | 559795114dbb9c8ff3210745c4c78aaf163ceab8 (diff) | |
Use built SDK stubs
Now that the SDK stubs are built in Soong, undo the hack that
uses the prebuilt stubs.
Fix the linktype checks to treat the various stubs libraries as
the correct type, since they can't be annotated with sdk_version.
Bug: 70351683
Bug: 77285514
Test: m checkbuild
Change-Id: I5e870c34dd0ebc8ae3f888ec627da590c846a76f
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/java/java.go b/java/java.go index de78f2819..866568109 100644 --- a/java/java.go +++ b/java/java.go @@ -19,6 +19,7 @@ package java // is handled in builder.go import ( + "fmt" "path/filepath" "strconv" "strings" @@ -420,13 +421,17 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { } } - //toModule := func(m string) sdkDep { - // return sdkDep{ - // useModule: true, - // module: m, - // systemModules: m + "_system_modules", - // } - //} + toModule := func(m string) sdkDep { + ret := sdkDep{ + useModule: true, + module: m, + systemModules: m + "_system_modules", + } + if m == "core.current.stubs" { + ret.systemModules = "core-system-modules" + } + return ret + } if ctx.Config().UnbundledBuild() && v != "" { return toFile(v) @@ -437,14 +442,14 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { return sdkDep{ useDefaultLibs: true, } - // TODO(ccross): re-enable these once we generate stubs, until then - // use the stubs in prebuilts/sdk/*current - //case "current": - // return toModule("android_stubs_current") - //case "system_current": - // return toModule("android_system_stubs_current") - //case "test_current": - // return toModule("android_test_stubs_current") + case "current": + return toModule("android_stubs_current") + case "system_current": + return toModule("android_system_stubs_current") + case "test_current": + return toModule("android_test_stubs_current") + case "core_current": + return toModule("core.current.stubs") default: return toFile(v) } @@ -600,23 +605,34 @@ const ( javaPlatform ) -func getLinkType(m *Module) linkType { +func getLinkType(m *Module, name string) linkType { ver := String(m.deviceProperties.Sdk_version) - if strings.HasPrefix(ver, "core_") { + switch { + case name == "core.current.stubs" || ver == "core_current": return javaCore - } else if strings.HasPrefix(ver, "system_") { + case name == "android_system_stubs_current" || strings.HasPrefix(ver, "system_"): return javaSystem - } else if _, err := strconv.Atoi(ver); err == nil || ver == "current" { + case name == "android_test_stubs_current" || strings.HasPrefix(ver, "test_"): + return javaPlatform + case name == "android_stubs_current" || ver == "current": return javaSdk - } else { - // test_current falls back here as well + case ver == "": return javaPlatform + default: + if _, err := strconv.Atoi(ver); err != nil { + panic(fmt.Errorf("expected sdk_version to be a number, got %q", ver)) + } + return javaSdk } } func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) { - myLinkType := getLinkType(from) - otherLinkType := getLinkType(&to.Module) + if ctx.Host() { + return + } + + myLinkType := getLinkType(from, ctx.ModuleName()) + otherLinkType := getLinkType(&to.Module, 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." switch myLinkType { @@ -909,13 +925,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path j.properties.Javac_shard_size) } } - // If sdk jar is java module, then directly return classesJar as header.jar - if j.Name() != "android_stubs_current" && j.Name() != "android_system_stubs_current" && - j.Name() != "android_test_stubs_current" { - j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName) - if ctx.Failed() { - return - } + j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName) + if ctx.Failed() { + return } } if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 { |