Fix depfile output from dexpreopt strip script
strip.sh uses $2.d to write the depfile, while this had been passing in
$@.tmp in as $2. Instead, move the file first, then use strip.sh with
the real output file so that we can find the depfile.
Also don't specify a depfile (or other dependencies) when
LOCAL_CERTIFICATE==PRESIGNED, as we'll skip all of that in the rule in
that case.
Bug: 121058584
Test: NINJA_ARGS="-w missingdepfile=true" m
Change-Id: I1323e775e3a6ce5a06a19d59f3fb07495f116f34
diff --git a/core/package_internal.mk b/core/package_internal.mk
index a46d76a..18128ff 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -678,8 +678,8 @@
@# Keep a copy of apk with classes.dex unstripped
$(hide) cp -f $@ $(dir $@)package.dex.apk
endif # BUILD_PLATFORM_ZIP
- $(PRIVATE_STRIP_SCRIPT) $@ $@.tmp
- mv -f $@.tmp $@
+ mv -f $@ $@.tmp
+ $(PRIVATE_STRIP_SCRIPT) $@.tmp $@
endif # LOCAL_DEX_PREOPT
$(sign-package)
ifdef LOCAL_COMPRESSED_MODULE
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 013497f..66913c1 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -357,12 +357,14 @@
ifneq ($(BUILD_PLATFORM_ZIP),)
$(built_module) : .KATI_IMPLICIT_OUTPUTS := $(dir $(LOCAL_BUILT_MODULE))package.dex.apk
endif
+ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
ifdef LOCAL_DEX_PREOPT
$(built_module) : PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
$(built_module) : $(intermediates)/strip.sh
$(built_module) : | $(DEXPREOPT_GEN_DEPS)
$(built_module) : .KATI_DEPFILE := $(built_module).d
endif
+endif
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR)
$(transform-prebuilt-to-target)
$(uncompress-prebuilt-embedded-jni-libs)
@@ -387,8 +389,8 @@
$(run-appcompat)
endif # module_run_appcompat
ifdef LOCAL_DEX_PREOPT
- $(PRIVATE_STRIP_SCRIPT) $@ $@.tmp
- mv -f $@.tmp $@
+ mv -f $@ $@.tmp
+ $(PRIVATE_STRIP_SCRIPT) $@.tmp $@
endif # LOCAL_DEX_PREOPT
$(sign-package)
# No need for align-package because sign-package takes care of alignment