Revert "Make package functions take an argument"

This reverts commit 5ea65dcc5e5564a335276a86a11b9ef4bbf25db8.

Reason for revert: Breaks some ART gtests on host.

Change-Id: I314692e31628a14d824e28544fdb3c765fc100f6
diff --git a/core/definitions.mk b/core/definitions.mk
index d73360c..35d70cb 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2340,7 +2340,7 @@
 # The MacOS jar tool doesn't like creating empty jar files,
 # so we need to give it something.
 # $(1) package to create
-define create-empty-package
+define create-empty-package-at
 @mkdir -p $(dir $(1))
 $(hide) touch $(dir $(1))zipdummy
 $(hide) $(JAR) cf $(1) -C $(dir $(1)) zipdummy
@@ -2348,6 +2348,13 @@
 $(hide) rm $(dir $(1))zipdummy
 endef
 
+# Create a mostly-empty .jar file that we'll add to later.
+# The MacOS jar tool doesn't like creating empty jar files,
+# so we need to give it something.
+define create-empty-package
+$(call create-empty-package-at,$@)
+endef
+
 # Copy an arhchive file and delete any class files and empty folders inside.
 # $(1): the source archive file.
 # $(2): the destination archive file.
@@ -2367,7 +2374,6 @@
 #Note that the version numbers are given to aapt as simple default
 #values; applications can override these by explicitly stating
 #them in their manifest.
-# $(1) the package file
 define add-assets-to-package
 $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
     $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
@@ -2384,17 +2390,16 @@
     $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
     $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
     --skip-symbols-without-default-localization \
-    -F $(1)
+    -F $@
 # So that we re-run aapt when the list of input files change
 $(hide) echo $(PRIVATE_RESOURCE_LIST) >/dev/null
 endef
 
 # We need the extra blank line, so that the command will be on a separate line.
-# $(1): the package
-# $(2): the ABI name
-# $(3): the list of shared libraies
+# $(1): the ABI name
+# $(2): the list of shared libraies
 define _add-jni-shared-libs-to-package-per-abi
-$(hide) cp $(3) $(dir $(1))lib/$(2)
+$(hide) cp $(2) $(dir $@)lib/$(1)
 
 endef
 
@@ -2408,19 +2413,23 @@
 ZIPALIGN_PAGE_ALIGN_FLAGS := -p
 endif
 
-# $(1): the package file
 define add-jni-shared-libs-to-package
-$(hide) rm -rf $(dir $(1))lib
-$(hide) mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
+$(hide) rm -rf $(dir $@)lib
+$(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
 $(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
-  $(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
+  $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
     $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
-$(hide) (cd $(dir $(1)) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $(1)) lib)
-$(hide) rm -rf $(dir $(1))lib
+$(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
+$(hide) rm -rf $(dir $@)lib
+endef
+
+#TODO: update the manifest to point to the dex file
+define add-dex-to-package
+$(call add-dex-to-package-arg,$@)
 endef
 
 # $(1): the package file.
-define add-dex-to-package
+define add-dex-to-package-arg
 $(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
 endef