Export java_host_for_device and java_device_for_host modules to Make
Robolectric needs to reference some modules declared with
java_host_for_device and java_device_for_host from Make for now.
Bug: 122331577
Test: m checkbuild
Change-Id: I09b3848edb120f2c3ee16b449b937b650f59811b
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index 9f40a6c..9c883e5 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -15,9 +15,12 @@
package java
import (
- "android/soong/android"
+ "fmt"
+ "io"
"github.com/google/blueprint"
+
+ "android/soong/android"
)
type DeviceHostConverter struct {
@@ -30,6 +33,9 @@
implementationJars android.Paths
implementationAndResourceJars android.Paths
resourceJars android.Paths
+
+ combinedHeaderJar android.Path
+ combinedImplementationJar android.Path
}
type DeviceHostConverterProperties struct {
@@ -98,6 +104,27 @@
ctx.PropertyErrorf("libs", "module %q cannot be used as a dependency", ctx.OtherModuleName(m))
}
})
+
+ jarName := ctx.ModuleName() + ".jar"
+
+ if len(d.implementationAndResourceJars) > 1 {
+ outputFile := android.PathForModuleOut(ctx, "combined", jarName)
+ TransformJarsToJar(ctx, outputFile, "combine", d.implementationAndResourceJars,
+ android.OptionalPath{}, false, nil, nil)
+ d.combinedImplementationJar = outputFile
+ } else {
+ d.combinedImplementationJar = d.implementationAndResourceJars[0]
+ }
+
+ if len(d.headerJars) > 1 {
+ outputFile := android.PathForModuleOut(ctx, "turbine-combined", jarName)
+ TransformJarsToJar(ctx, outputFile, "turbine combine", d.headerJars,
+ android.OptionalPath{}, false, nil, nil)
+ d.combinedHeaderJar = outputFile
+ } else {
+ d.combinedHeaderJar = d.headerJars[0]
+ }
+
}
var _ Dependency = (*DeviceHostConverter)(nil)
@@ -129,3 +156,18 @@
func (d *DeviceHostConverter) ExportedSdkLibs() []string {
return nil
}
+
+func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Class: "JAVA_LIBRARIES",
+ OutputFile: android.OptionalPathForPath(d.combinedImplementationJar),
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ Extra: []android.AndroidMkExtraFunc{
+ func(w io.Writer, outputFile android.Path) {
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", d.combinedHeaderJar.String())
+ fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", d.combinedImplementationJar.String())
+ },
+ },
+ }
+}