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:
parent
89479facb9
commit
92430106c3
4 changed files with 29 additions and 14 deletions
|
@ -43,6 +43,7 @@ type AndroidMkData struct {
|
|||
OutputFile OptionalPath
|
||||
Disabled bool
|
||||
Include string
|
||||
Required []string
|
||||
|
||||
Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData)
|
||||
|
||||
|
@ -168,6 +169,8 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
|
|||
data.Include = "$(BUILD_PREBUILT)"
|
||||
}
|
||||
|
||||
data.Required = amod.commonProperties.Required
|
||||
|
||||
// Make does not understand LinuxBionic
|
||||
if amod.Os() == LinuxBionic {
|
||||
return nil
|
||||
|
@ -197,8 +200,8 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
|
|||
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_CLASS :=", data.Class)
|
||||
fmt.Fprintln(&data.preamble, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
|
||||
|
||||
if len(amod.commonProperties.Required) > 0 {
|
||||
fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(amod.commonProperties.Required, " "))
|
||||
if len(data.Required) > 0 {
|
||||
fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
|
||||
}
|
||||
|
||||
archStr := amod.Arch().ArchType.String()
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,8 +274,6 @@ func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Pat
|
|||
func AndroidAppFactory() android.Module {
|
||||
module := &AndroidApp{}
|
||||
|
||||
module.deviceProperties.Dex = true
|
||||
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.deviceProperties,
|
||||
|
|
13
java/java.go
13
java/java.go
|
@ -125,16 +125,15 @@ type CompilerDeviceProperties struct {
|
|||
// if not blank, set to the version of the sdk to compile against
|
||||
Sdk_version string
|
||||
|
||||
// Set for device java libraries, and for host versions of device java libraries
|
||||
// built for testing
|
||||
Dex bool `blueprint:"mutated"`
|
||||
|
||||
// directories to pass to aidl tool
|
||||
Aidl_includes []string
|
||||
|
||||
// directories that should be added as include directories
|
||||
// for any aidl sources of modules that depend on this module
|
||||
Export_aidl_include_dirs []string
|
||||
|
||||
// If true, export a copy of the module as a -hostdex module for host testing.
|
||||
Hostdex *bool
|
||||
}
|
||||
|
||||
// Module contains the properties and members used by all java module types
|
||||
|
@ -279,8 +278,6 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||
if sdkDep.useModule {
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
|
||||
}
|
||||
} else {
|
||||
// TODO(ccross): add hostdex support
|
||||
}
|
||||
}
|
||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||
|
@ -508,7 +505,6 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
|||
|
||||
j.classpathFile = outputFile
|
||||
|
||||
// TODO(ccross): handle hostdex
|
||||
if ctx.Device() && j.installable() {
|
||||
dxFlags := j.deviceProperties.Dxflags
|
||||
if false /* emma enabled */ {
|
||||
|
@ -622,7 +618,6 @@ func LibraryFactory(installable bool) func() android.Module {
|
|||
if !installable {
|
||||
module.properties.Installable = proptools.BoolPtr(false)
|
||||
}
|
||||
module.deviceProperties.Dex = true
|
||||
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
|
@ -680,8 +675,6 @@ func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
func BinaryFactory() android.Module {
|
||||
module := &Binary{}
|
||||
|
||||
module.deviceProperties.Dex = true
|
||||
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.deviceProperties,
|
||||
|
|
Loading…
Reference in a new issue