diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-12-19 03:23:01 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-12-19 03:23:01 +0000 |
commit | 0cbb31e9e775d0ee71c7b5e627f010966f50adaa (patch) | |
tree | ffe3e102aaf92334fdffcab0b0fb8479c62daa96 /java/java.go | |
parent | a03edbeddca9c68a15605ad02d405be462360e30 (diff) | |
parent | ac1e986c55f1ed98d36a267bef5bc22c3bbd1716 (diff) |
Merge "Create public stub for platform's sysprop_library"
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/java/java.go b/java/java.go index 9745da45e..052e06f6f 100644 --- a/java/java.go +++ b/java/java.go @@ -594,8 +594,36 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { } } - ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) - ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...) + syspropPublicStubs := syspropPublicStubs(ctx.Config()) + + // rewriteSyspropLibs validates if a java module can link against platform's sysprop_library, + // and redirects dependency to public stub depending on the link type. + rewriteSyspropLibs := func(libs []string, prop string) []string { + // make a copy + ret := android.CopyOf(libs) + + for idx, lib := range libs { + stub, ok := syspropPublicStubs[lib] + + if !ok { + continue + } + + linkType, _ := j.getLinkType(ctx.ModuleName()) + if linkType == javaSystem { + ret[idx] = stub + } else if linkType != javaPlatform { + ctx.PropertyErrorf("sdk_version", + "can't link against sysprop_library %q from a module using public or core API", + lib) + } + } + + return ret + } + + ctx.AddVariationDependencies(nil, libTag, rewriteSyspropLibs(j.properties.Libs, "libs")...) + ctx.AddVariationDependencies(nil, staticLibTag, rewriteSyspropLibs(j.properties.Static_libs, "static_libs")...) ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), pluginTag, j.properties.Plugins...) ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), exportedPluginTag, j.properties.Exported_plugins...) |