From 1bd8780881ffdeb4b16bfedc4410f54fc6e2fabb Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 5 Dec 2017 15:31:19 -0800 Subject: [PATCH] Add more dex_preopt properties Move dex_preopt to dex_preopt.enabled, and add dex_preopt.app_image, dex_preopt.profile_guided, and dex_preopt.profile. These values will be passed back to Make if provided to control dex preopting. Test: m checkbuild Change-Id: I54a4b1de697a08be20ab65d2a5dc43ce0046692d --- androidmk/cmd/androidmk/android.go | 7 ++++++- java/androidmk.go | 14 ++++++++++++-- java/java.go | 21 ++++++++++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go index 18756a9fc..bb9d140ff 100644 --- a/androidmk/cmd/androidmk/android.go +++ b/androidmk/cmd/androidmk/android.go @@ -94,6 +94,8 @@ func init() { "LOCAL_NOTICE_FILE": "notice", "LOCAL_JAVA_LANGUAGE_VERSION": "java_version", "LOCAL_INSTRUMENTATION_FOR": "instrumentation_for", + + "LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING": "dex_preopt.profile", }) addStandardProperties(bpparser.ListType, map[string]string{ @@ -151,7 +153,10 @@ func init() { "LOCAL_PROPRIETARY_MODULE": "proprietary", "LOCAL_VENDOR_MODULE": "vendor", "LOCAL_EXPORT_PACKAGE_RESOURCES": "export_package_resources", - "LOCAL_DEX_PREOPT": "dex_preopt", + + "LOCAL_DEX_PREOPT": "dex_preopt.enabled", + "LOCAL_DEX_PREOPT_APP_IMAGE": "dex_preopt.app_image", + "LOCAL_DEX_PREOPT_GENERATE_PROFILE": "dex_preopt.profile_guided", }) } diff --git a/java/androidmk.go b/java/androidmk.go index f52d5e957..acf597bb2 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -36,8 +36,18 @@ func (library *Library) AndroidMk() android.AndroidMkData { } if library.dexJarFile != nil { fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String()) - if library.deviceProperties.Dex_preopt != nil && *library.deviceProperties.Dex_preopt == false { - fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false") + if library.deviceProperties.Dex_preopt.Enabled != nil { + fmt.Fprintln(w, "LOCAL_DEX_PREOPT :=", *library.deviceProperties.Dex_preopt.Enabled) + } + if library.deviceProperties.Dex_preopt.App_image != nil { + fmt.Fprintln(w, "LOCAL_DEX_PREOPT_APP_IMAGE :=", *library.deviceProperties.Dex_preopt.App_image) + } + if library.deviceProperties.Dex_preopt.Profile_guided != nil { + fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE :=", *library.deviceProperties.Dex_preopt.Profile_guided) + } + if library.deviceProperties.Dex_preopt.Profile != nil { + fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE := true") + fmt.Fprintln(w, "LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING := $(LOCAL_PATH)/"+*library.deviceProperties.Dex_preopt.Profile) } } fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", String(library.deviceProperties.Sdk_version)) diff --git a/java/java.go b/java/java.go index 0e54e3c61..3663253c1 100644 --- a/java/java.go +++ b/java/java.go @@ -167,9 +167,24 @@ type CompilerDeviceProperties struct { // If true, export a copy of the module as a -hostdex module for host testing. Hostdex *bool - // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to - // true. - Dex_preopt *bool + Dex_preopt struct { + // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to + // true. + Enabled *bool + + // If true, generate an app image (.art file) for this module. + App_image *bool + + // If true, use a checked-in profile to guide optimization. Defaults to false unless + // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR + // that matches the name of this module, in which case it is defaulted to true. + Profile_guided *bool + + // If set, provides the path to profile relative to the Android.bp file. If not set, + // defaults to searching for a file that matches the name of this module in the default + // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found. + Profile *string + } // When targeting 1.9, override the modules to use with --system System_modules *string