summaryrefslogtreecommitdiff
path: root/test/etc/apex_bootclasspath_utils.py
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2022-06-20 21:30:56 +0100
committer David Srbecky <dsrbecky@google.com> 2022-08-01 08:05:33 +0000
commitbfa76b30ea40855b119995ecabf43d3afc4651f1 (patch)
treef54496135e44ca7d942e7c617ac07d8fe61cbaf9 /test/etc/apex_bootclasspath_utils.py
parentbc1d0af64f234350234a7bcde5fa104aa5bec3b3 (diff)
Convert run-test-jar from bash to python
This is a naive 1:1 conversion with intent to create minimal diff. The code does not follow python conventions, idioms or formatting. (this is left for follow up clean-up CLs) I have tested it by recording and comparing the commands and their environment executed by both version. They match. Test: test.py -r --all-target --all-run --all-gc Change-Id: Ie01c4a53618a425acb5e8708f172f2379da3e343
Diffstat (limited to 'test/etc/apex_bootclasspath_utils.py')
-rwxr-xr-xtest/etc/apex_bootclasspath_utils.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/etc/apex_bootclasspath_utils.py b/test/etc/apex_bootclasspath_utils.py
new file mode 100755
index 0000000000..0a95646901
--- /dev/null
+++ b/test/etc/apex_bootclasspath_utils.py
@@ -0,0 +1,79 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file contains utils for constructing -Xbootclasspath and -Xbootclasspath-location
+# for dex2oat and dalvikvm from apex modules list.
+#
+# Those utils could be used outside of art/test/ to run ART in chroot setup.
+
+import os, sys
+
+# Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
+# because that's what we use for compiling the boot.art image.
+# It may contain additional modules from TEST_CORE_JARS.
+bpath_modules="core-oj core-libart okhttp bouncycastle apache-xml core-icu4j conscrypt"
+
+ANDROID_BUILD_TOP=os.environ["ANDROID_BUILD_TOP"]
+ANDROID_HOST_OUT=os.environ["ANDROID_HOST_OUT"]
+
+# Helper function to construct paths for apex modules (for both -Xbootclasspath and
+# -Xbootclasspath-location).
+#
+# Arguments.
+# ${1}: path prefix.
+def get_apex_bootclasspath_impl(bpath_prefix: str):
+ bpath_separator=""
+ bpath=""
+ bpath_jar=""
+ for bpath_module in bpath_modules.split(" "):
+ apex_module="com.android.art"
+ if bpath_module == "conscrypt":
+ apex_module="com.android.conscrypt"
+ if bpath_module == "core-icu4j":
+ apex_module="com.android.i18n"
+ bpath_jar=f"/apex/{apex_module}/javalib/{bpath_module}.jar"
+ bpath+=f"{bpath_separator}{bpath_prefix}{bpath_jar}"
+ bpath_separator=":"
+ return bpath
+
+# Gets a -Xbootclasspath paths with the apex modules.
+#
+# Arguments.
+# ${1}: host (y|n).
+def get_apex_bootclasspath(host: str):
+ bpath_prefix=""
+
+ if host == "y":
+ bpath_prefix=ANDROID_HOST_OUT
+
+ return get_apex_bootclasspath_impl(bpath_prefix)
+
+# Gets a -Xbootclasspath-location paths with the apex modules.
+#
+# Arguments.
+# ${1}: host (y|n).
+def get_apex_bootclasspath_locations(host: str):
+ bpath_location_prefix=""
+
+ if host == "y":
+ if ANDROID_HOST_OUT[0:len(ANDROID_BUILD_TOP)+1] == f"{ANDROID_BUILD_TOP}/":
+ bpath_location_prefix=ANDROID_HOST_OUT[len(ANDROID_BUILD_TOP)+1:]
+ else:
+ print(f"ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT"\
+ "\nANDROID_BUILD_TOP={ANDROID_BUILD_TOP}"\
+ "\nANDROID_HOST_OUT={ANDROID_HOST_OUT}")
+ sys.exit(1)
+
+ return get_apex_bootclasspath_impl(bpath_location_prefix)