Merge "AndroidMk for the hostdex library has separate AndroidMkEntries"
This commit is contained in:
commit
aafc04ea5c
|
@ -17,99 +17,103 @@ package java
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) {
|
func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
|
||||||
if Bool(library.deviceProperties.Hostdex) && !library.Host() {
|
hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
|
||||||
fmt.Fprintln(w, "include $(CLEAR_VARS)")
|
if !library.IsForPlatform() {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
|
// If the platform variant is available, don't emit hostdex modules from the APEX variants
|
||||||
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
hostDexNeeded = false
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
|
|
||||||
if library.dexJarFile != nil {
|
|
||||||
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.dexJarFile.String())
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String())
|
|
||||||
}
|
|
||||||
if library.dexJarFile != nil {
|
|
||||||
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
|
|
||||||
}
|
|
||||||
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
|
|
||||||
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
|
|
||||||
if len(entries.Required) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(entries.Required, " "))
|
|
||||||
}
|
|
||||||
if len(entries.Host_required) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(entries.Host_required, " "))
|
|
||||||
}
|
|
||||||
if len(entries.Target_required) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(entries.Target_required, " "))
|
|
||||||
}
|
|
||||||
if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
|
|
||||||
}
|
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", library.Stem()+"-hostdex")
|
|
||||||
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hostDexNeeded {
|
||||||
|
var output android.Path
|
||||||
|
if library.dexJarFile != nil {
|
||||||
|
output = library.dexJarFile
|
||||||
|
} else {
|
||||||
|
output = library.implementationAndResourcesJar
|
||||||
|
}
|
||||||
|
return android.AndroidMkEntries{
|
||||||
|
Class: "JAVA_LIBRARIES",
|
||||||
|
SubName: "-hostdex",
|
||||||
|
OutputFile: android.OptionalPathForPath(output),
|
||||||
|
Required: library.deviceProperties.Target.Hostdex.Required,
|
||||||
|
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
|
||||||
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
|
func(entries *android.AndroidMkEntries) {
|
||||||
|
entries.SetBool("LOCAL_IS_HOST_MODULE", true)
|
||||||
|
entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
|
||||||
|
if library.dexJarFile != nil {
|
||||||
|
entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
|
||||||
|
}
|
||||||
|
entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
|
||||||
|
entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
|
||||||
|
entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return android.AndroidMkEntries{Disabled: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
|
func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
if !library.IsForPlatform() {
|
var entriesList []android.AndroidMkEntries
|
||||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
|
||||||
Disabled: true,
|
mainEntries := android.AndroidMkEntries{Disabled: true}
|
||||||
}}
|
// For a java library built for an APEX, we don't need Make module
|
||||||
}
|
if library.IsForPlatform() {
|
||||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
mainEntries = android.AndroidMkEntries{
|
||||||
Class: "JAVA_LIBRARIES",
|
Class: "JAVA_LIBRARIES",
|
||||||
OutputFile: android.OptionalPathForPath(library.outputFile),
|
OutputFile: android.OptionalPathForPath(library.outputFile),
|
||||||
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
|
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
|
||||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
func(entries *android.AndroidMkEntries) {
|
func(entries *android.AndroidMkEntries) {
|
||||||
if len(library.logtagsSrcs) > 0 {
|
if len(library.logtagsSrcs) > 0 {
|
||||||
var logtags []string
|
var logtags []string
|
||||||
for _, l := range library.logtagsSrcs {
|
for _, l := range library.logtagsSrcs {
|
||||||
logtags = append(logtags, l.Rel())
|
logtags = append(logtags, l.Rel())
|
||||||
|
}
|
||||||
|
entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
|
||||||
}
|
}
|
||||||
entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if library.installFile == nil {
|
if library.installFile == nil {
|
||||||
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
|
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
|
||||||
}
|
}
|
||||||
if library.dexJarFile != nil {
|
if library.dexJarFile != nil {
|
||||||
entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
|
entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
|
||||||
}
|
}
|
||||||
if len(library.dexpreopter.builtInstalled) > 0 {
|
if len(library.dexpreopter.builtInstalled) > 0 {
|
||||||
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
|
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
|
||||||
}
|
}
|
||||||
entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
|
entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
|
||||||
entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
|
entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
|
||||||
entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
|
entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
|
||||||
|
|
||||||
if library.jacocoReportClassesFile != nil {
|
if library.jacocoReportClassesFile != nil {
|
||||||
entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
|
entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
|
entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
|
||||||
|
|
||||||
if len(library.additionalCheckedModules) != 0 {
|
if len(library.additionalCheckedModules) != 0 {
|
||||||
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
|
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if library.proguardDictionary != nil {
|
if library.proguardDictionary != nil {
|
||||||
entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
|
entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
|
||||||
}
|
}
|
||||||
entries.SetString("LOCAL_MODULE_STEM", library.Stem())
|
entries.SetString("LOCAL_MODULE_STEM", library.Stem())
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
}
|
||||||
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
|
|
||||||
library.AndroidMkHostDex(w, name, entries)
|
hostDexEntries := library.AndroidMkEntriesHostDex()
|
||||||
},
|
|
||||||
},
|
entriesList = append(entriesList, mainEntries, hostDexEntries)
|
||||||
}}
|
return entriesList
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called for modules that are a component of a test suite.
|
// Called for modules that are a component of a test suite.
|
||||||
|
|
|
@ -50,17 +50,23 @@ func TestHostdex(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
|
|
||||||
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
||||||
entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
|
entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
|
||||||
|
if len(entriesList) != 2 {
|
||||||
|
t.Errorf("two entries are expected, but got %d", len(entriesList))
|
||||||
|
}
|
||||||
|
|
||||||
|
mainEntries := &entriesList[0]
|
||||||
expected := []string{"foo"}
|
expected := []string{"foo"}
|
||||||
actual := entries.EntryMap["LOCAL_MODULE"]
|
actual := mainEntries.EntryMap["LOCAL_MODULE"]
|
||||||
if !reflect.DeepEqual(expected, actual) {
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
|
t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
footerLines := entries.FooterLinesForTests()
|
subEntries := &entriesList[1]
|
||||||
if !android.InList("LOCAL_MODULE := foo-hostdex", footerLines) {
|
expected = []string{"foo-hostdex"}
|
||||||
t.Errorf("foo-hostdex is not found in the footers: %q", footerLines)
|
actual = subEntries.EntryMap["LOCAL_MODULE"]
|
||||||
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
|
t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,17 +81,23 @@ func TestHostdexRequired(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
|
|
||||||
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
||||||
entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
|
entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
|
||||||
|
if len(entriesList) != 2 {
|
||||||
|
t.Errorf("two entries are expected, but got %d", len(entriesList))
|
||||||
|
}
|
||||||
|
|
||||||
|
mainEntries := &entriesList[0]
|
||||||
expected := []string{"libfoo"}
|
expected := []string{"libfoo"}
|
||||||
actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
|
actual := mainEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
|
||||||
if !reflect.DeepEqual(expected, actual) {
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
|
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
footerLines := entries.FooterLinesForTests()
|
subEntries := &entriesList[1]
|
||||||
if !android.InList("LOCAL_REQUIRED_MODULES := libfoo", footerLines) {
|
expected = []string{"libfoo"}
|
||||||
t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
|
actual = subEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
|
||||||
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
|
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,14 +116,20 @@ func TestHostdexSpecificRequired(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
|
|
||||||
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
mod := ctx.ModuleForTests("foo", "android_common").Module()
|
||||||
entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
|
entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
|
||||||
|
if len(entriesList) != 2 {
|
||||||
|
t.Errorf("two entries are expected, but got %d", len(entriesList))
|
||||||
|
}
|
||||||
|
|
||||||
if r, ok := entries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
|
mainEntries := &entriesList[0]
|
||||||
|
if r, ok := mainEntries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
|
||||||
t.Errorf("Unexpected required modules: %q", r)
|
t.Errorf("Unexpected required modules: %q", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
footerLines := entries.FooterLinesForTests()
|
subEntries := &entriesList[1]
|
||||||
if !android.InList("LOCAL_REQUIRED_MODULES += libfoo", footerLines) {
|
expected := []string{"libfoo"}
|
||||||
t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
|
actual := subEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
|
||||||
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
|
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue