xref: /aosp_15_r20/external/grpc-grpc-java/xds/third_party/protoc-gen-validate/import.sh (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1#!/bin/bash
2# Copyright 2018 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 GIT_ORIGIN_REV_ID then in this directory run ./import.sh
17
18set -e
19BRANCH=main
20# import GIT_ORIGIN_REV_ID from one of the google internal CLs
21GIT_ORIGIN_REV_ID=dfcdc5ea103dda467963fb7079e4df28debcfd28
22GIT_REPO="https://github.com/envoyproxy/protoc-gen-validate.git"
23GIT_BASE_DIR=protoc-gen-validate
24SOURCE_PROTO_BASE_DIR=protoc-gen-validate
25TARGET_PROTO_BASE_DIR=src/main/proto
26# Sorted alphabetically.
27FILES=(
28validate/validate.proto
29)
30
31# clone the protoc-gen-validate github repo in a tmp directory
32tmpdir="$(mktemp -d)"
33pushd "${tmpdir}"
34rm -rf "$GIT_BASE_DIR"
35git clone -b $BRANCH $GIT_REPO
36cd "$GIT_BASE_DIR"
37git checkout $GIT_ORIGIN_REV_ID
38popd
39
40cp -p "${tmpdir}/${GIT_BASE_DIR}/LICENSE" LICENSE
41cp -p "${tmpdir}/${GIT_BASE_DIR}/NOTICE" NOTICE
42
43mkdir -p "${TARGET_PROTO_BASE_DIR}"
44pushd "${TARGET_PROTO_BASE_DIR}"
45
46# copy proto files to project directory
47for file in "${FILES[@]}"
48do
49  mkdir -p "$(dirname "${file}")"
50  cp -p "${tmpdir}/${SOURCE_PROTO_BASE_DIR}/${file}" "${file}"
51done
52popd
53
54rm -rf "$tmpdir"
55