From ff71556a53283c6df0df6dce36c944d1df1b3e87 Mon Sep 17 00:00:00 2001 From: JaeMan Park Date: Mon, 19 Oct 2020 17:25:58 +0900 Subject: Add java sdk library enforcement flag Add java sdk library enforcement for inter-partition library dependency, for ensuring backward-compatible libraries for inter-partition dependencies. Test: m nothing Bug: 168180538 Change-Id: I6bfac54c3499b03003a3bc6c2bb62b165b4ce5f9 --- java/java.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 7cf04fa35..808c3896d 100644 --- a/java/java.go +++ b/java/java.go @@ -756,6 +756,37 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { libDeps := ctx.AddVariationDependencies(nil, libTag, rewriteSyspropLibs(j.properties.Libs, "libs")...) ctx.AddVariationDependencies(nil, staticLibTag, rewriteSyspropLibs(j.properties.Static_libs, "static_libs")...) + if ctx.DeviceConfig().VndkVersion() != "" && ctx.Config().EnforceInterPartitionJavaSdkLibrary() { + // Require java_sdk_library at inter-partition java dependency to ensure stable + // interface between partitions. If inter-partition java_library dependency is detected, + // raise build error because java_library doesn't have a stable interface. + // + // Inputs: + // PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY + // if true, enable enforcement + // PRODUCT_INTER_PARTITION_JAVA_LIBRARY_ALLOWLIST + // exception list of java_library names to allow inter-partition dependency + for idx, lib := range j.properties.Libs { + if libDeps[idx] == nil { + continue + } + + if _, ok := syspropPublicStubs[lib]; ok { + continue + } + + if javaDep, ok := libDeps[idx].(javaSdkLibraryEnforceContext); ok { + // java_sdk_library is always allowed at inter-partition dependency. + // So, skip check. + if _, ok := javaDep.(*SdkLibrary); ok { + continue + } + + j.checkPartitionsForJavaDependency(ctx, "libs", javaDep) + } + } + } + // For library dependencies that are component libraries (like stubs), add the implementation // as a dependency (dexpreopt needs to be against the implementation library, not stubs). for _, dep := range libDeps { -- cgit v1.2.3-59-g8ed1b