1*7594170eSAndroid Build Coastguard Worker#!/bin/bash -eux 2*7594170eSAndroid Build Coastguard Worker 3*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2023 The Android Open Source Project 4*7594170eSAndroid Build Coastguard Worker# 5*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*7594170eSAndroid Build Coastguard Worker# 9*7594170eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*7594170eSAndroid Build Coastguard Worker# 11*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*7594170eSAndroid Build Coastguard Worker# limitations under the License. 16*7594170eSAndroid Build Coastguard Worker 17*7594170eSAndroid Build Coastguard Workerif [[ ! -d "build/bazel/ci" ]]; then 18*7594170eSAndroid Build Coastguard Worker echo "Please run this script from TOP". 19*7594170eSAndroid Build Coastguard Worker exit 1 20*7594170eSAndroid Build Coastguard Workerfi 21*7594170eSAndroid Build Coastguard Worker 22*7594170eSAndroid Build Coastguard Workersource "build/bazel/ci/build_with_bazel.sh" 23*7594170eSAndroid Build Coastguard Workersource "build/bazel/ci/target_lists.sh" 24*7594170eSAndroid Build Coastguard Worker 25*7594170eSAndroid Build Coastguard Workerfunction test_wrapper_providers() { 26*7594170eSAndroid Build Coastguard Worker for target in ${EXAMPLE_WRAPPER_TARGETS[@]}; do 27*7594170eSAndroid Build Coastguard Worker private_providers="$(build/bazel/bin/bazel ${STARTUP_FLAGS[@]} \ 28*7594170eSAndroid Build Coastguard Worker cquery ${FLAGS[@]} --config=android "${target}_private" \ 29*7594170eSAndroid Build Coastguard Worker --starlark:expr="sorted(providers(target).keys())" --output=starlark|uniq)" 30*7594170eSAndroid Build Coastguard Worker wrapper_providers="$(build/bazel/bin/bazel ${STARTUP_FLAGS[@]} \ 31*7594170eSAndroid Build Coastguard Worker cquery ${FLAGS[@]} --config=android "${target}" \ 32*7594170eSAndroid Build Coastguard Worker --starlark:expr="sorted(providers(target).keys())" --output=starlark|uniq)" 33*7594170eSAndroid Build Coastguard Worker if [[ -z "${private_providers}" ]]; then 34*7594170eSAndroid Build Coastguard Worker echo "Empty provider list, bazel invocation probably failed" >&2 35*7594170eSAndroid Build Coastguard Worker exit 1 36*7594170eSAndroid Build Coastguard Worker fi 37*7594170eSAndroid Build Coastguard Worker if [[ ! $(cmp -s <(echo "${private_providers}") <(echo "${wrapper_providers}")) ]]; then 38*7594170eSAndroid Build Coastguard Worker echo "${target} and ${target}_private should have the same providers. Diff:" 39*7594170eSAndroid Build Coastguard Worker diff <(echo "${private_providers}") <(echo "${wrapper_providers}") 40*7594170eSAndroid Build Coastguard Worker fi 41*7594170eSAndroid Build Coastguard Worker done 42*7594170eSAndroid Build Coastguard Worker} 43