Install java_binary wrappers in make
Convert java_binary modules into two make modules, one for the
underlying java_library and one for the wrapper prebuilt.
Test: m -j checkbuild
Change-Id: I5ddf74f24f1e41fc1f39b3e8d254b7e191dbd47a
diff --git a/java/androidmk.go b/java/androidmk.go
index 1939924..12643cf 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -17,6 +17,7 @@
import (
"fmt"
"io"
+ "strings"
"android/soong/android"
)
@@ -44,3 +45,25 @@
},
}
}
+
+func (binary *Binary) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Class: "JAVA_LIBRARIES",
+ OutputFile: android.OptionalPathForPath(binary.outputFile),
+ SubName: ".jar",
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ android.WriteAndroidMkData(w, data)
+
+ fmt.Fprintln(w, "include $(CLEAR_VARS)")
+ fmt.Fprintln(w, "LOCAL_MODULE := "+name)
+ fmt.Fprintln(w, "LOCAL_MODULE_CLASS := EXECUTABLES")
+ if strings.Contains(prefix, "HOST_") {
+ fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
+ }
+ fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+name+".jar")
+ fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE := "+binary.wrapperFile.String())
+ fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
+ },
+ }
+}
diff --git a/java/java.go b/java/java.go
index 4c614e5..ac88020 100644
--- a/java/java.go
+++ b/java/java.go
@@ -486,6 +486,9 @@
Library
binaryProperties binaryProperties
+
+ wrapperFile android.ModuleSrcPath
+ binaryFile android.OutputPath
}
func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -493,8 +496,9 @@
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
// another build rule before the jar has been installed.
- ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper),
- j.installFile)
+ j.wrapperFile = android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper)
+ j.binaryFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"),
+ j.wrapperFile, j.installFile)
}
func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {