Split java_binary modules into common and binary variants
Add a common_first multilib type and use it for java.Binary
so that the java part is compiled as a "common" arch type
but the wrapper script is installed as a "linux_glibc" arch
type. This allows java_binary to be used as a tool dependency
for a genrule.
Bug: 68397812
Test: TestJavaBinary
Change-Id: I809060839ce8878300da3fb76426ceb1ea6b0e8e
diff --git a/java/androidmk.go b/java/androidmk.go
index 2e67639..f52d5e9 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -95,28 +95,35 @@
}
func (binary *Binary) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
- Class: "JAVA_LIBRARIES",
- OutputFile: android.OptionalPathForPath(binary.implementationJarFile),
- Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
- fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
- 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_PREBUILT_MODULE_FILE :=", binary.wrapperFile.String())
- fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
+ if !binary.isWrapperVariant {
+ return android.AndroidMkData{
+ Class: "JAVA_LIBRARIES",
+ OutputFile: android.OptionalPathForPath(binary.implementationJarFile),
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ android.WriteAndroidMkData(w, data)
- // Ensure that the wrapper script timestamp is always updated when the jar is updated
- fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
- fmt.Fprintln(w, "jar_installed_module :=")
- },
+ fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
+ },
+ }
+ } else {
+ return android.AndroidMkData{
+ Class: "EXECUTABLES",
+ OutputFile: android.OptionalPathForPath(binary.wrapperFile),
+ Extra: []android.AndroidMkExtraFunc{
+ func(w io.Writer, outputFile android.Path) {
+ fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
+ },
+ },
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ android.WriteAndroidMkData(w, data)
+
+ // Ensure that the wrapper script timestamp is always updated when the jar is updated
+ fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
+ fmt.Fprintln(w, "jar_installed_module :=")
+ },
+ }
}
}