Fix multiple output file generation for AAPT2

Make R.stamp actually part of the same rule that creates R.java.
Otherwise if the generated sources directory is removed, we don't
regenerate R.java / Manifest.java.

Also move the package-export.apk and proguard options file into the same
rule.

Test: m telephony-common; rm out/target/common/obj/*/*_intermediates/src; m telephony-common
Change-Id: I71f6fcaf20593ca23271d52d15537aaa9ef4cc77
diff --git a/core/definitions.mk b/core/definitions.mk
index ae62931..68d1fa2 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2060,7 +2060,7 @@
     --skip-symbols-without-default-localization
 endef
 
-# Search for generated R.java/Manifest.java, copy the found R.java as $@.
+# Search for generated R.java/Manifest.java, copy the found R.java as $1.
 # Also copy them to a central 'R' directory to make it easier to add the files to an IDE.
 define find-generated-R.java
 $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
@@ -2075,11 +2075,11 @@
     mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
     $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
       || exit 31; \
-    $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
+    $(ACP) -fp $$GENERATED_R_FILE $1 || exit 32; \
   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 $@
+$(hide) touch $1
 endef
 
 ###########################################################