OSDN Git Service

Make sure R.stamp is always created
authorMartin Arenlind <martin.arenlind@sonymobile.com>
Tue, 15 Sep 2015 13:52:56 +0000 (15:52 +0200)
committerYing Wang <wangying@google.com>
Fri, 23 Oct 2015 18:07:28 +0000 (11:07 -0700)
When an app has a resource directory, but the
directory contain no resources, R.stamp is not created.

This leads to that such apps are always rebuilt,
even when there are no changes.

This patch changes so that an empty R.stamp is
created even if there are no resources.
This leads to that affected apps are not rebuilt
unless changed.

Change-Id: Ia63e5b1913a4456402700b615ba7f9d56d2da852

core/package_internal.mk

index 1f98cdc..a2cbe31 100644 (file)
@@ -241,7 +241,7 @@ $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
 $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
 $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
        @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
-       @rm -f $@
+       @rm -rf $@ && mkdir -p $(dir $@)
        $(create-resource-java-files)
        $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
                                        -name Manifest.java 2> /dev/null`; do \
@@ -256,7 +256,10 @@ $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_
                $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
                        || exit 31; \
                $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
-       done; \
+       done;
+       @# Ensure that the target file is always created, i.e. also in case we did not
+       @# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding.
+       $(hide) touch $@
 
 $(proguard_options_file): $(R_file_stamp)