diff options
author | 2023-02-03 13:18:52 -0800 | |
---|---|---|
committer | 2023-02-10 19:53:08 +0000 | |
commit | 1da15a2389d667a9b76018f30439f1594e29c28f (patch) | |
tree | 5bf1bb2e1ff91b62c0900eead42c1d9f773d919b | |
parent | 910c95fe2dd57bc0d70c78bdc0c6cdf4d21ce700 (diff) |
Update host_bcp.sh script to use apex-info-list.xml
Use the host-generated apex-info-list mapping to trace bootclasspath
references to apex jars. This seems to be slightly more robust to host
paths for both flattened and unflattened modules.
Test: art/tools/compile-classes.sh Bar.java
Bug: 161394143
Change-Id: I40f62fc1bde54b1303f5b85ab0604274d20ec046
-rwxr-xr-x | tools/compile-jar.py | 6 | ||||
-rwxr-xr-x | tools/host_bcp.sh | 50 |
2 files changed, 23 insertions, 33 deletions
diff --git a/tools/compile-jar.py b/tools/compile-jar.py index 56a07d5a61..d3484460ce 100755 --- a/tools/compile-jar.py +++ b/tools/compile-jar.py @@ -105,19 +105,17 @@ def get_bcp_runtime_args(additions, image, arch): "art/tools/host_bcp.sh", os.path.expandvars( "${{OUT}}/system/framework/oat/{}/services.odex".format(arch)), - "--use-first-dir" ] print("Running: {}".format(run_print(args))) print("=START=======================================") res = subprocess.run(args, capture_output=True, text=True) print("=END=========================================") if res.returncode != 0: - print("Falling back to com.android.art BCP") + print("Falling back to ART boot image: {}".format(res)) args = [ "art/tools/host_bcp.sh", os.path.expandvars( - "${{OUT}}/apex/com.android.art.debug/javalib/{}/boot.oat".format(arch)), - "--use-first-dir" + "${{OUT}}/apex/art_boot_images/javalib/{}/boot.oat".format(arch)), ] print("Running: {}".format(run_print(args))) print("=START=======================================") diff --git a/tools/host_bcp.sh b/tools/host_bcp.sh index 26231cdca1..62ebae70d7 100755 --- a/tools/host_bcp.sh +++ b/tools/host_bcp.sh @@ -14,27 +14,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -if [[ ${#@} != 1 ]] && [[ ${#@} != 2 ]]; then +if [[ ${#@} != 1 ]]; then cat <<EOF Usage - host_bcp <image> [--use-first-dir] | xargs <art-host-tool> ... + host_bcp <image> | xargs <art-host-tool> ... Extracts boot class path locations from <image> and outputs the appropriate --runtime-arg -Xbootclasspath:... --runtime-arg -Xbootclasspath-locations:... arguments for many ART host tools based on the \$ANDROID_PRODUCT_OUT variable -and existing \$ANDROID_PRODUCT_OUT/apex/com.android.art* paths. -If --use-first-dir is specified, the script will use the first apex dir instead -of resulting in an error. +and existing \$ANDROID_PRODUCT_OUT/apex/* paths. EOF exit 1 fi IMAGE=$1 -USE_FIRST_DIR=false - -if [[ $2 == "--use-first-dir" ]]; then - USE_FIRST_DIR=true -fi if [[ ! -e ${IMAGE} ]]; then IMAGE=${ANDROID_PRODUCT_OUT}/$1 @@ -50,34 +43,33 @@ if [[ "x${BCPL}" == "x" ]]; then exit 1 fi -MANIFEST=/apex_manifest.pb -ART_APEX=/apex/com.android.art -ART_APEX_SELECTED= -for m in `ls -1 -d ${ANDROID_PRODUCT_OUT}{,/system}${ART_APEX}*${MANIFEST} 2>/dev/null`; do - d=${m:0:-${#MANIFEST}} - if [[ "x${ART_APEX_SELECTED}" != "x" ]]; then - if [[ $USE_FIRST_DIR == true ]]; then - break - fi - echo "Multiple ART APEX dirs: ${ART_APEX_SELECTED}, ${d}." - exit 1 - fi - ART_APEX_SELECTED=${d} -done -if [[ "x${ART_APEX_SELECTED}" == "x" ]]; then - echo "No ART APEX dir." +APEX_INFO_LIST=${ANDROID_PRODUCT_OUT}/apex/apex-info-list.xml +if [[ ! -e ${APEX_INFO_LIST} ]]; then + echo "Failed to locate apex info at ${APEX_INFO_LIST}." exit 1 fi BCP= OLD_IFS=${IFS} IFS=: +APEX_PREFIX=/apex/ for COMPONENT in ${BCPL}; do HEAD=${ANDROID_PRODUCT_OUT} TAIL=${COMPONENT} - if [[ ${COMPONENT:0:${#ART_APEX}} = ${ART_APEX} ]]; then - HEAD=${ART_APEX_SELECTED} - TAIL=${COMPONENT:${#ART_APEX}} + # Apex module paths aren't symlinked on the host, so map from the symbolic + # device path to the prebuilt (host) module path using the apex info table. + if [[ ${COMPONENT:0:${#APEX_PREFIX}} = ${APEX_PREFIX} ]]; then + # First extract the symbolic module name and its (internal) jar path. + COMPONENT=${COMPONENT#${APEX_PREFIX}} + MODULE_NAME=${COMPONENT%%/*} + MODULE_JAR=${COMPONENT#*/} + # Use the module name to look up the preinstalled module path.. + HOST_MODULE=`xmllint --xpath "string(//apex-info[@moduleName=\"${MODULE_NAME}\"]/@preinstalledModulePath)" ${APEX_INFO_LIST}` + # Extract the preinstalled module name from the full path (strip prefix/suffix). + HOST_MODULE_NAME=${HOST_MODULE#*${APEX_PREFIX}} + HOST_MODULE_NAME=${HOST_MODULE_NAME%.*apex} + # Rebuild the host path using the preinstalled module name. + TAIL="${APEX_PREFIX}${HOST_MODULE_NAME}/${MODULE_JAR}" fi if [[ ! -e $HEAD$TAIL ]]; then echo "File does not exist: $HEAD$TAIL" |