1#!/usr/bin/env bash 2 3# Copyright (C) 2023 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Tests that the java toolchain depends on all prebuilt android.jar. 18 19source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" 20 21function check_toolchain_refers_to_all_prebuilt_files() { 22 actual_query_name=$1 23 file=$2 24 readonly package_path="__main__/prebuilts/sdk" 25 26 actual_query=$(cat $(rlocation $package_path/$actual_query_name)|sed 's%//\|:%/%g') 27 expected_query=$(ls $(rlocation $package_path)/**/*/${file}|sed s%$(rlocation "__main__")%%;) 28 29 if [ "$expected_query" != "$actual_query" ]; then 30 toolchain_type=$(echo ${actual_query_name}|sed s%_toolchain.*%%) 31 echo "device ${toolchain_type} toolchain does not refer to all ${file} under prebuilts/sdk." && 32 echo "The toolchain depends on:" && 33 echo $actual_query && 34 echo "The directory structure has:" && 35 echo $expected_query && 36 exit 1 37 fi; 38} 39 40check_toolchain_refers_to_all_prebuilt_files "java_toolchain_android_jar_deps" "android.jar" 41check_toolchain_refers_to_all_prebuilt_files "android_sdk_toolchain_android_jar_deps" "android.jar" 42check_toolchain_refers_to_all_prebuilt_files "java_toolchain_core_jar_deps" "core-for-system-modules.jar" 43check_toolchain_refers_to_all_prebuilt_files "android_sdk_toolchain_core_jar_deps" "core-for-system-modules.jar" 44check_toolchain_refers_to_all_prebuilt_files "android_sdk_toolchain_framework_aidl_deps" "framework.aidl" 45