kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/examples/proto/test_direct_index_proto_user.sh (about) 1 #!/bin/bash -e 2 # Copyright 2016 The Kythe Authors. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # 16 # usage: test_direct_index_proto_user.sh [artifact-dir] 17 # If artifact-dir is not provided, a temporary directory will be used. 18 19 set -o pipefail 20 set -o errexit 21 22 cd "$(bazel info workspace)" 23 24 if [[ -d "$1" ]]; then 25 D="$1" 26 else 27 D="$(mktemp -d 2>/dev/null || mktemp -d -t 'kythetest')" 28 trap 'rm -rf "${D}"' EXIT ERR INT 29 fi 30 31 # Generate the proto descriptor. 32 bazel build //kythe/examples/proto:example.descriptor 33 34 # Index the proto descriptor. 35 BAZELGENFILES="$(bazel info workspace)/bazel-genfiles" 36 bazel build //kythe/examples/proto:proto_indexer \ 37 //kythe/cxx/verifier:verifier \ 38 //kythe/cxx/indexer/cxx:indexer 39 ./bazel-bin/kythe/examples/proto/proto_indexer \ 40 "${BAZELGENFILES}"/kythe/examples/proto/example.descriptor \ 41 > "${D}/proto.entries" 42 43 # Verify that part of the index. 44 ./bazel-bin/kythe/cxx/verifier/verifier kythe/examples/proto/example.proto \ 45 < "${D}/proto.entries" 46 47 # Generate the kzip for the proto-using CU. 48 # This will include the .meta file (because of the kythe_metadata pragma). 49 BAZELOUT="$(bazel info workspace)/bazel-out" 50 51 # Remove any old kzips. 52 pushd "$BAZELOUT" 53 find . \ 54 -path "*/extra_actions/kythe/cxx/extractor/extra_action/kythe/examples/proto/*.kzip" \ 55 -delete 56 popd 57 58 bazel build \ 59 --experimental_action_listener=//kythe/cxx/extractor:extract_cxx \ 60 --experimental_extra_action_top_level_only \ 61 --experimental_proto_extra_actions \ 62 //kythe/examples/proto:proto_user 63 64 pushd "$BAZELOUT" 65 find . \ 66 -path "*/extra_actions/kythe/cxx/extractor/extra_action/kythe/examples/proto/*.kzip" \ 67 -exec cp {} "${D}/proto_user.kzip" \; \ 68 && \ 69 chmod 644 "${D}/proto_user.kzip" 70 popd 71 72 echo "Running indexer and verifier using ${D}/proto_user.kzip" 73 ./bazel-bin/kythe/cxx/indexer/cxx/indexer "${D}/proto_user.kzip" \ 74 > "${D}/proto_user.entries" 75 cat "${D}/proto_user.entries" "${D}/proto.entries" | 76 ./bazel-bin/kythe/cxx/verifier/verifier --ignore_dups \ 77 kythe/examples/proto/example.proto \ 78 kythe/examples/proto/proto_user.cc