Do odex for prebuilt apk in kitkat

diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 3e73c8d..e740fae 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -5,6 +5,20 @@
 ## None.
 ##
 ###########################################################
+ifneq (true,$(WITH_DEXPREOPT))
+  LOCAL_DEX_PREOPT :=
+else
+  ifndef LOCAL_DEX_PREOPT
+LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
+endif
+endif
+ifeq (false,$(LOCAL_DEX_PREOPT))
+  LOCAL_DEX_PREOPT :=
+endif
+ifeq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+  LOCAL_DEX_PREOPT :=
+endif
+$(info prebuild $(LOCAL_MODULE)==> $(LOCAL_DEX_PREOPT))


 ifneq ($(LOCAL_PREBUILT_LIBS),)
 $(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
@@ -27,6 +41,7 @@ endif


 ifdef LOCAL_IS_HOST_MODULE
   my_prefix := HOST_
+  LOCAL_DEX_PREOPT :=
 else
   my_prefix := TARGET_
 endif
@@ -145,17 +160,42 @@ else
 endif


 ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+ifdef LOCAL_DEX_PREOPT
+  $(built_module): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT)
+endif
 ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
 # Ensure that presigned .apks have been aligned.
-$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
-       $(transform-prebuilt-to-target-with-zipalign)
+$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN)
+       #$(transform-prebuilt-to-target-with-zipalign)
+       $(transform-prebuilt-to-target)
+ifdef LOCAL_DEX_PREOPT
+       $(hide) rm -f $(patsubst %.apk,%.odex,$@)
+       $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
+  ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+       $(call dexpreopt-remove-classes.dex,$@)
+  endif
+endif
+       $(align-package)
 else
 # Sign and align non-presigned .apks.
 $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
        $(transform-prebuilt-to-target)
        $(sign-package)
+#add below
+ifdef LOCAL_DEX_PREOPT
+       $(hide) rm -f $(patsubst %.apk,%.odex,$@)
+       $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
+  ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+       $(call dexpreopt-remove-classes.dex,$@)
+  endif
+endif
+#add upon
        $(align-package)
 endif
+ifdef LOCAL_DEX_PREOPT
+  built_odex := $(basename $(built_module)).odex
+$(built_odex): $(built_module)
+endif
 else
 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
 $(built_module) : $(my_prebuilt_src_file)

你可能感兴趣的:(apk,android,odex,prebulit)