1#!/bin/bash -eux 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 17if [[ ! -d "build/bazel/ci" ]]; then 18 echo "Please run this script from TOP". 19 exit 1 20fi 21 22source "build/bazel/ci/build_with_bazel.sh" 23source "build/bazel/ci/target_lists.sh" 24 25function test_wrapper_providers() { 26 for target in ${EXAMPLE_WRAPPER_TARGETS[@]}; do 27 private_providers="$(build/bazel/bin/bazel ${STARTUP_FLAGS[@]} \ 28 cquery ${FLAGS[@]} --config=android "${target}_private" \ 29 --starlark:expr="sorted(providers(target).keys())" --output=starlark|uniq)" 30 wrapper_providers="$(build/bazel/bin/bazel ${STARTUP_FLAGS[@]} \ 31 cquery ${FLAGS[@]} --config=android "${target}" \ 32 --starlark:expr="sorted(providers(target).keys())" --output=starlark|uniq)" 33 if [[ -z "${private_providers}" ]]; then 34 echo "Empty provider list, bazel invocation probably failed" >&2 35 exit 1 36 fi 37 if [[ ! $(cmp -s <(echo "${private_providers}") <(echo "${wrapper_providers}")) ]]; then 38 echo "${target} and ${target}_private should have the same providers. Diff:" 39 diff <(echo "${private_providers}") <(echo "${wrapper_providers}") 40 fi 41 done 42} 43