Add hostdex support

If hostdex: true is specified for a java library, create an extra
Make module that copies the dex jar to a module with a -hostdex
suffix in the host output directory.

Bug: 67600882
Test: m -j checkbuild
Change-Id: I859dfaabeefdca714b566de94e00f74e03c85939
This commit is contained in:
Colin Cross
2017-10-09 14:59:32 -07:00
parent 89479facb9
commit 92430106c3
4 changed files with 29 additions and 14 deletions

View File

@@ -19,6 +19,8 @@ import (
"io"
"strings"
"github.com/google/blueprint/proptools"
"android/soong/android"
)
@@ -38,6 +40,25 @@ func (library *Library) AndroidMk() android.AndroidMkData {
fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.deviceProperties.Sdk_version)
},
},
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
android.WriteAndroidMkData(w, data)
if proptools.Bool(library.deviceProperties.Hostdex) && !library.Host() {
fmt.Fprintln(w, "include $(CLEAR_VARS)")
fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.classpathFile.String())
if library.properties.Installable != nil && *library.properties.Installable == false {
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
}
if library.dexJarFile != nil {
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
}
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
}
},
}
}