diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 39 | 
1 files changed, 23 insertions, 16 deletions
diff --git a/java/java.go b/java/java.go index 5bf3d79fb..1a052b432 100644 --- a/java/java.go +++ b/java/java.go @@ -248,15 +248,24 @@ type installDependencyTag struct {  type usesLibraryDependencyTag struct {  	dependencyTag -	sdkVersion int  // SDK version in which the library appared as a standalone library. -	optional   bool // If the dependency is optional or required. + +	// SDK version in which the library appared as a standalone library. +	sdkVersion int + +	// If the dependency is optional or required. +	optional bool + +	// Whether this is an implicit dependency inferred by Soong, or an explicit one added via +	// `uses_libs`/`optional_uses_libs` properties. +	implicit bool  } -func makeUsesLibraryDependencyTag(sdkVersion int, optional bool) usesLibraryDependencyTag { +func makeUsesLibraryDependencyTag(sdkVersion int, optional bool, implicit bool) usesLibraryDependencyTag {  	return usesLibraryDependencyTag{  		dependencyTag: dependencyTag{name: fmt.Sprintf("uses-library-%d", sdkVersion)},  		sdkVersion:    sdkVersion,  		optional:      optional, +		implicit:      implicit,  	}  } @@ -285,11 +294,6 @@ var (  	syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"}  	jniInstallTag           = installDependencyTag{name: "jni install"}  	binaryInstallTag        = installDependencyTag{name: "binary install"} -	usesLibReqTag           = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, false) -	usesLibOptTag           = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, true) -	usesLibCompat28OptTag   = makeUsesLibraryDependencyTag(28, true) -	usesLibCompat29ReqTag   = makeUsesLibraryDependencyTag(29, false) -	usesLibCompat30OptTag   = makeUsesLibraryDependencyTag(30, true)  )  func IsLibDepTag(depTag blueprint.DependencyTag) bool { @@ -511,7 +515,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {  		j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))  	}  	j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex -	j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap) +	j.classLoaderContexts = j.usesLibrary.classLoaderContextForUsesLibDeps(ctx)  	j.compile(ctx, nil)  	// Collect the module directory for IDE info in java/jdeps.go. @@ -530,6 +534,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {  func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {  	j.deps(ctx) +	j.usesLibrary.deps(ctx, false)  }  const ( @@ -569,8 +574,8 @@ const (  	copyEverythingToSnapshot = false  ) -func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { -	mctx.AddVariationDependencies(nil, dependencyTag, names...) +func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) { +	ctx.AddVariationDependencies(nil, dependencyTag, names...)  }  func (mt *librarySdkMemberType) IsInstance(module android.Module) bool { @@ -870,8 +875,8 @@ type testSdkMemberType struct {  	android.SdkMemberTypeBase  } -func (mt *testSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { -	mctx.AddVariationDependencies(nil, dependencyTag, names...) +func (mt *testSdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) { +	ctx.AddVariationDependencies(nil, dependencyTag, names...)  }  func (mt *testSdkMemberType) IsInstance(module android.Module) bool { @@ -1812,8 +1817,10 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,  	depTag := ctx.OtherModuleDependencyTag(depModule)  	if depTag == libTag {  		// Ok, propagate <uses-library> through non-static library dependencies. -	} else if tag, ok := depTag.(usesLibraryDependencyTag); ok && tag.sdkVersion == dexpreopt.AnySdkVersion { -		// Ok, propagate <uses-library> through non-compatibility <uses-library> dependencies. +	} else if tag, ok := depTag.(usesLibraryDependencyTag); ok && +		tag.sdkVersion == dexpreopt.AnySdkVersion && tag.implicit { +		// Ok, propagate <uses-library> through non-compatibility implicit <uses-library> +		// dependencies.  	} else if depTag == staticLibTag {  		// Propagate <uses-library> through static library dependencies, unless it is a component  		// library (such as stubs). Component libraries have a dependency on their SDK library, @@ -1831,7 +1838,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,  	// <uses_library> and should not be added to CLC, but the transitive <uses-library> dependencies  	// from its CLC should be added to the current CLC.  	if sdkLib != nil { -		clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false, +		clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false, true,  			dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())  	} else {  		clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)  |