xref: /aosp_15_r20/external/grpc-grpc-java/xds/third_party/googleapis/import.sh (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1#!/bin/bash
2# Copyright 2020 The gRPC Authors
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# Update VERSION then in this directory run ./import.sh
17
18set -e
19BRANCH=master
20VERSION=ca1372c6d7bcb199638ebfdb40d2b2660bab7b88
21GIT_REPO="https://github.com/googleapis/googleapis.git"
22GIT_BASE_DIR=googleapis
23SOURCE_PROTO_BASE_DIR=googleapis
24TARGET_PROTO_BASE_DIR=src/main/proto
25# Sorted alphabetically.
26FILES=(
27google/api/expr/v1alpha1/checked.proto
28google/api/expr/v1alpha1/syntax.proto
29)
30
31pushd `git rev-parse --show-toplevel`/xds/third_party/googleapis
32
33# clone the googleapis github repo in a tmp directory
34tmpdir="$(mktemp -d)"
35trap "rm -rf ${tmpdir}" EXIT
36
37pushd "${tmpdir}"
38git clone -b $BRANCH $GIT_REPO
39trap "rm -rf $GIT_BASE_DIR" EXIT
40cd "$GIT_BASE_DIR"
41git checkout $VERSION
42popd
43
44cp -p "${tmpdir}/${GIT_BASE_DIR}/LICENSE" LICENSE
45
46rm -rf "${TARGET_PROTO_BASE_DIR}"
47mkdir -p "${TARGET_PROTO_BASE_DIR}"
48pushd "${TARGET_PROTO_BASE_DIR}"
49
50# copy proto files to project directory
51for file in "${FILES[@]}"
52do
53  mkdir -p "$(dirname "${file}")"
54  cp -p "${tmpdir}/${SOURCE_PROTO_BASE_DIR}/${file}" "${file}"
55done
56popd
57
58popd
59