aboutsummaryrefslogtreecommitdiffstats
path: root/dexpreopt
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2019-02-12 13:12:16 +0000
committerNicolas Geoffray <ngeoffray@google.com>2019-02-13 11:59:20 +0000
commitfa6e9ec003d733006be10978599f62869ef2c6bd (patch)
treea9160e6ec00d7c73f29c18de7f744a9149d9d19a /dexpreopt
parent40e26a2a995dabed6129f774d84c6363c833f192 (diff)
downloadbuild_soong-fa6e9ec003d733006be10978599f62869ef2c6bd.tar.gz
build_soong-fa6e9ec003d733006be10978599f62869ef2c6bd.tar.bz2
build_soong-fa6e9ec003d733006be10978599f62869ef2c6bd.zip
Revert "Revert "Never strip and store dex files uncompressed when they are preopted on system.""
This reverts commit 67e8ec1973700bbdbc4cd68b3493d56d270ca377. Test: build && atest android.text.cts.EmojiTest#testEmojiGlyphWebView on Cuttlefish Exempt-From-Owner-Approval: Got +2 from Colin, latest PS is a rebase across conflicts. Change-Id: I99faf0f2ec698d70c107516bd43756b9ddcb90d0
Diffstat (limited to 'dexpreopt')
-rw-r--r--dexpreopt/config.go3
-rw-r--r--dexpreopt/dexpreopt.go13
-rw-r--r--dexpreopt/dexpreopt_test.go17
3 files changed, 29 insertions, 4 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 8fef0109..c7f06387 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -48,7 +48,8 @@ type GlobalConfig struct {
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
+ GenerateDMFiles bool // generate Dex Metadata files
+ NeverAllowStripping bool // whether stripping should not be done - used as build time check to make sure dex files are always available
NoDebugInfo bool // don't generate debug info by default
AlwaysSystemServerDebugInfo bool // always generate mini debug info for system server modules (overrides NoDebugInfo=true)
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index cd931df9..68bd3ea6 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -68,6 +68,9 @@ func GenerateStripRule(global GlobalConfig, module ModuleConfig) (rule *android.
strip := shouldStripDex(module, global)
if strip {
+ if global.NeverAllowStripping {
+ panic(fmt.Errorf("Stripping requested on %q, though the product does not allow it", module.DexLocation))
+ }
// Only strips if the dex files are not already uncompressed
rule.Command().
Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, module.StripInputPath).
@@ -496,7 +499,7 @@ func shouldGenerateDM(module ModuleConfig, global GlobalConfig) bool {
contains(module.PreoptFlags, "--compiler-filter=verify")
}
-func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool {
+func OdexOnSystemOtherByName(name string, dexLocation string, global GlobalConfig) bool {
if !global.HasSystemOther {
return false
}
@@ -505,12 +508,12 @@ func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool {
return false
}
- if contains(global.SpeedApps, module.Name) || contains(global.SystemServerApps, module.Name) {
+ if contains(global.SpeedApps, name) || contains(global.SystemServerApps, name) {
return false
}
for _, f := range global.PatternsOnSystemOther {
- if makefileMatch(filepath.Join(SystemPartition, f), module.DexLocation) {
+ if makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
return true
}
}
@@ -518,6 +521,10 @@ func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool {
return false
}
+func odexOnSystemOther(module ModuleConfig, global GlobalConfig) bool {
+ return OdexOnSystemOtherByName(module.Name, module.DexLocation, global)
+}
+
// PathToLocation converts .../system/framework/arm64/boot.art to .../system/framework/boot.art
func PathToLocation(path string, arch android.ArchType) string {
pathArch := filepath.Base(filepath.Dir(path))
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index be861901..ecaf8769 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -36,6 +36,7 @@ var testGlobalConfig = GlobalConfig{
DefaultCompilerFilter: "",
SystemServerCompilerFilter: "",
GenerateDMFiles: false,
+ NeverAllowStripping: false,
NoDebugInfo: false,
AlwaysSystemServerDebugInfo: false,
NeverSystemServerDebugInfo: false,
@@ -109,6 +110,22 @@ func TestDexPreopt(t *testing.T) {
}
}
+func TestDexPreoptStrip(t *testing.T) {
+ // Test that we panic if we strip in a configuration where stripping is not allowed.
+ global, module := testGlobalConfig, testModuleConfig
+
+ global.NeverAllowStripping = true
+ module.NoStripping = false
+ module.Name = "test"
+ module.DexLocation = "/system/app/test/test.apk"
+ module.BuildPath = "out/test/test.apk"
+
+ _, err := GenerateStripRule(global, module)
+ if err == nil {
+ t.Errorf("Expected an error when calling GenerateStripRule on a stripped module")
+ }
+}
+
func TestDexPreoptSystemOther(t *testing.T) {
global, module := testGlobalConfig, testModuleConfig