Add support for flattened Runtime APEX to Make rule `standalone-apex-files`.

Adjust the source of the Runtime APEX libraries copied to the
/system/lib(64) directory sync'd to the target, so that this rule
works both for non-flattened and flattened APEXes.

Test: ART chroot-based on-device testing using the master-art branch
Bug: 121117762
Change-Id: I9f796e58c22c6346d11416742ed8b81baa712c6a
diff --git a/Android.mk b/Android.mk
index c91f700..0866cc7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -532,14 +532,36 @@
   lib/libandroidio.so \
   lib64/libandroidio.so \
 
+# Copy some libraries into `$(TARGET_OUT)/lib(64)` (the
+# `/system/lib(64)` directory to be sync'd to the target) for ART testing
+# purposes:
+# - Bionic bootstrap libraries, copied from
+#   `$(TARGET_OUT)/lib(64)/bootstrap` (the `/system/lib(64)/bootstrap`
+#   directory to be sync'd to the target);
+# - Some libraries which are part of the Runtime APEX; if the product
+#   to build uses flattened APEXes, these libraries are copied from
+#   `$(TARGET_OUT)/apex/com.android.runtime.debug` (the flattened
+#   (Debug) Runtime APEX directory to be sync'd to the target);
+#   otherwise, they are copied from
+#   `$(TARGET_OUT)/../apex/com.android.runtime.debug` (the local
+#   directory under the build tree containing the (Debug) Runtime APEX
+#   artifacts, which is not sync'd to the target).
+#
+# TODO(b/121117762): Remove this when the ART Buildbot and Golem have
+# full support for the Runtime APEX.
 .PHONY: standalone-apex-files
 standalone-apex-files: libc.bootstrap libdl.bootstrap libm.bootstrap linker com.android.runtime.debug
 	for f in $(PRIVATE_BIONIC_FILES); do \
 	  tf=$(TARGET_OUT)/$$f; \
 	  if [ -f $$tf ]; then cp -f $$tf $$(echo $$tf | sed 's,bootstrap/,,'); fi; \
 	done
+	if [ "x$(TARGET_FLATTEN_APEX)" = xtrue ]; then \
+	  runtime_apex_orig_dir=$(TARGET_OUT)/apex/com.android.runtime.debug; \
+	else \
+	  runtime_apex_orig_dir=$(TARGET_OUT)/../apex/com.android.runtime.debug; \
+	fi; \
 	for f in $(PRIVATE_RUNTIME_DEPENDENCY_LIBS); do \
-	  tf=$(TARGET_OUT)/../apex/com.android.runtime.debug/$$f; \
+	  tf="$$runtime_apex_orig_dir/$$f"; \
 	  if [ -f $$tf ]; then cp -f $$tf $(TARGET_OUT)/$$f; fi; \
 	done