diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 41 | 
1 files changed, 17 insertions, 24 deletions
| diff --git a/java/java.go b/java/java.go index a8793fe87..a026610c2 100644 --- a/java/java.go +++ b/java/java.go @@ -273,6 +273,8 @@ type JavaInfo struct {  	// JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be  	// instrumented by jacoco.  	JacocoReportClassesFile android.Path + +	// TODO: Add device config declarations here?  }  var JavaInfoProvider = blueprint.NewProvider(JavaInfo{}) @@ -3104,24 +3106,15 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {  	// Attribute jvm_flags  	var jvmFlags bazel.StringListAttribute  	if m.binaryProperties.Jni_libs != nil { -		jniLibPackages := map[string]bool{} -		for _, jniLibLabel := range android.BazelLabelForModuleDeps(ctx, m.binaryProperties.Jni_libs).Includes { -			jniLibPackage := jniLibLabel.Label -			indexOfColon := strings.Index(jniLibLabel.Label, ":") -			if indexOfColon > 0 { -				// JNI lib from other package -				jniLibPackage = jniLibLabel.Label[2:indexOfColon] -			} else if indexOfColon == 0 { -				// JNI lib in the same package of java_binary -				packageOfCurrentModule := m.GetBazelLabel(ctx, m) -				jniLibPackage = packageOfCurrentModule[2:strings.Index(packageOfCurrentModule, ":")] -			} -			if _, inMap := jniLibPackages[jniLibPackage]; !inMap { -				jniLibPackages[jniLibPackage] = true +		jniLibPackages := []string{} +		for _, jniLib := range m.binaryProperties.Jni_libs { +			if jniLibModule, exists := ctx.ModuleFromName(jniLib); exists { +				otherDir := ctx.OtherModuleDir(jniLibModule) +				jniLibPackages = append(jniLibPackages, filepath.Join(otherDir, jniLib))  			}  		}  		jniLibPaths := []string{} -		for jniLibPackage, _ := range jniLibPackages { +		for _, jniLibPackage := range jniLibPackages {  			// See cs/f:.*/third_party/bazel/.*java_stub_template.txt for the use of RUNPATH  			jniLibPaths = append(jniLibPaths, "$${RUNPATH}"+jniLibPackage)  		} @@ -3145,9 +3138,9 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {  	}  	libInfo := libraryCreationInfo{ -		deps: deps, -		attrs: commonAttrs, -		baseName: m.Name(), +		deps:      deps, +		attrs:     commonAttrs, +		baseName:  m.Name(),  		hasKotlin: bp2BuildInfo.hasKotlin,  	}  	libName := createLibraryTarget(ctx, libInfo) @@ -3189,9 +3182,9 @@ func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) {  	}  	libInfo := libraryCreationInfo{ -		deps: deps, -		attrs: commonAttrs, -		baseName: m.Name(), +		deps:      deps, +		attrs:     commonAttrs, +		baseName:  m.Name(),  		hasKotlin: bp2BuildInfo.hasKotlin,  	}  	libName := createLibraryTarget(ctx, libInfo) @@ -3204,9 +3197,9 @@ func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) {  // libraryCreationInfo encapsulates the info needed to create java_library target from  // java_binary_host or java_test_host.  type libraryCreationInfo struct { -	deps bazel.LabelListAttribute -	attrs *javaCommonAttributes -	baseName string +	deps      bazel.LabelListAttribute +	attrs     *javaCommonAttributes +	baseName  string  	hasKotlin bool  } |