aboutsummaryrefslogtreecommitdiffstats
path: root/dexpreopt/config.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-11-12 10:13:39 -0800
committerColin Cross <ccross@android.com>2018-12-15 19:07:54 -0800
commit43f08db29e874ec5f5eb56de6972ef7ed0321809 (patch)
tree172846f9da39b8c54157d8ec77d4dfc5363ac681 /dexpreopt/config.go
parentdf76efe5244766fed2940a80003de9b772005bc1 (diff)
downloadbuild_soong-43f08db29e874ec5f5eb56de6972ef7ed0321809.tar.gz
build_soong-43f08db29e874ec5f5eb56de6972ef7ed0321809.tar.bz2
build_soong-43f08db29e874ec5f5eb56de6972ef7ed0321809.zip
Dexpreopt soong modules inside soong
Port the dexpreopt logic from Make to the dexpreopt package in Soong, and use it to dexpreopt Soong modules. The same package is also compiled into the dexpreopt_gen binary to generate dexpreopt scripts for Make modules. This relands Ib67e2febf9ed921f06e8a86b9ec945c80dff35eb and I462182638bd57b1367b5bfb0718e975c11ae66f7, along with multiple fixes to depsfile generation in dexpreopt_gen that caused .odex files for modules in defined make to be missing dependencies on boot.art, and a fix to not dexpreopt and strip tests. Bug: 119412419 Bug: 120273280 Test: no differences to dexpreopt outputs on aosp_sailfish system/, only expected changes to dexpreopt outputs on system_other (.vdex files for privileged Soong modules no longer incorrectly contain .dex contents). Test: OUT_DIR=$PWD/out m Test: NINJA_ARGS="-t deps out/target/product/sailfish/obj/APPS/Contacts_intermediates/dexpreopt.zip" m Change-Id: I6bb2c971cee65d2338839753aa0d84939f335b1b
Diffstat (limited to 'dexpreopt/config.go')
-rw-r--r--dexpreopt/config.go141
1 files changed, 141 insertions, 0 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
new file mode 100644
index 00000000..6a4fd4a0
--- /dev/null
+++ b/dexpreopt/config.go
@@ -0,0 +1,141 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package dexpreopt
+
+import (
+ "encoding/json"
+ "io/ioutil"
+)
+
+// GlobalConfig stores the configuration for dex preopting set by the product
+type GlobalConfig struct {
+ DefaultNoStripping bool // don't strip dex files by default
+
+ DisablePreoptModules []string // modules with preopt disabled by product-specific config
+
+ OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
+
+ HasSystemOther bool // store odex files that match PatternsOnSystemOther on the system_other partition
+ PatternsOnSystemOther []string // patterns (using '%' to denote a prefix match) to put odex on the system_other partition
+
+ DisableGenerateProfile bool // don't generate profiles
+
+ BootJars []string // jars that form the boot image
+ SystemServerJars []string // jars that form the system server
+ SystemServerApps []string // apps that are loaded into system server
+ SpeedApps []string // apps that should be speed optimized
+
+ PreoptFlags []string // global dex2oat flags that should be used if no module-specific dex2oat flags are specified
+
+ DefaultCompilerFilter string // default compiler filter to pass to dex2oat, overridden by --compiler-filter= in module-specific dex2oat flags
+ SystemServerCompilerFilter string // default compiler filter to pass to dex2oat for system server jars
+
+ GenerateDMFiles bool // generate Dex Metadata files
+
+ NoDebugInfo bool // don't generate debug info by default
+ AlwaysSystemServerDebugInfo bool // always generate mini debug info for system server modules (overrides NoDebugInfo=true)
+ NeverSystemServerDebugInfo bool // never generate mini debug info for system server modules (overrides NoDebugInfo=false)
+ AlwaysOtherDebugInfo bool // always generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
+ NeverOtherDebugInfo bool // never generate mini debug info for non-system server modules (overrides NoDebugInfo=true)
+
+ MissingUsesLibraries []string // libraries that may be listed in OptionalUsesLibraries but will not be installed by the product
+
+ IsEng bool // build is a eng variant
+ SanitizeLite bool // build is the second phase of a SANITIZE_LITE build
+
+ DefaultAppImages bool // build app images (TODO: .art files?) by default
+
+ Dex2oatXmx string // max heap size
+ Dex2oatXms string // initial heap size
+
+ EmptyDirectory string // path to an empty directory
+
+ DefaultDexPreoptImageLocation map[string]string // default boot image location for each architecture
+ CpuVariant map[string]string // cpu variant for each architecture
+ InstructionSetFeatures map[string]string // instruction set for each architecture
+
+ Tools Tools // paths to tools possibly used by the generated commands
+}
+
+// Tools contains paths to tools possibly used by the generated commands. If you add a new tool here you MUST add it
+// to the order-only dependency list in DEXPREOPT_GEN_DEPS.
+type Tools struct {
+ Profman string
+ Dex2oat string
+ Aapt string
+ SoongZip string
+ Zip2zip string
+
+ VerifyUsesLibraries string
+ ConstructContext string
+}
+
+type ModuleConfig struct {
+ Name string
+ DexLocation string // dex location on device
+ BuildPath string
+ DexPath string
+ PreferIntegrity bool
+ UncompressedDex bool
+ HasApkLibraries bool
+ PreoptFlags []string
+
+ ProfileClassListing string
+ ProfileIsTextListing bool
+
+ EnforceUsesLibraries bool
+ OptionalUsesLibraries []string
+ UsesLibraries []string
+ LibraryPaths map[string]string
+
+ Archs []string
+ DexPreoptImageLocation string
+
+ PreoptExtractedApk bool // Overrides OnlyPreoptModules
+
+ NoCreateAppImage bool
+ ForceCreateAppImage bool
+
+ PresignedPrebuilt bool
+
+ StripInputPath string
+ StripOutputPath string
+}
+
+func LoadGlobalConfig(path string) (GlobalConfig, error) {
+ config := GlobalConfig{}
+ err := loadConfig(path, &config)
+ return config, err
+}
+
+func LoadModuleConfig(path string) (ModuleConfig, error) {
+ config := ModuleConfig{}
+ err := loadConfig(path, &config)
+ return config, err
+}
+
+func loadConfig(path string, config interface{}) error {
+ data, err := ioutil.ReadFile(path)
+ if err != nil {
+ return err
+ }
+
+ err = json.Unmarshal(data, config)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}