2019-01-06 14:55:10 +00:00
|
|
|
#!/bin/bash
|
2021-03-24 19:57:27 +00:00
|
|
|
. "$(dirname "$0")"/common.sh
|
2019-01-06 14:55:10 +00:00
|
|
|
|
|
|
|
# Script to copy pb.go files from bazel build folder to appropriate location.
|
|
|
|
# Bazel builds to bazel-bin/... folder, script copies them back to original folder where .proto is.
|
|
|
|
|
2023-03-10 17:49:34 +00:00
|
|
|
bazel query 'attr(testonly, 0, //proto/...)' | xargs bazel build $@
|
2019-01-06 14:55:10 +00:00
|
|
|
|
|
|
|
file_list=()
|
2020-06-03 21:15:37 +00:00
|
|
|
while IFS= read -d $'\0' -r file; do
|
2019-01-06 14:55:10 +00:00
|
|
|
file_list=("${file_list[@]}" "$file")
|
2021-03-24 19:57:27 +00:00
|
|
|
done < <($findutil -L "$(bazel info bazel-bin)"/proto -type f -regextype sed -regex ".*pb\.\(gw\.\)\?go$" -print0)
|
2020-06-03 21:15:37 +00:00
|
|
|
|
2019-01-06 14:55:10 +00:00
|
|
|
arraylength=${#file_list[@]}
|
2023-03-17 18:52:56 +00:00
|
|
|
searchstring="prysmaticlabs/prysm/v4/"
|
2019-01-06 14:55:10 +00:00
|
|
|
|
|
|
|
# Copy pb.go files from bazel-bin to original folder where .proto is.
|
2020-12-01 01:55:30 +00:00
|
|
|
for ((i = 0; i < arraylength; i++)); do
|
2021-03-24 19:57:27 +00:00
|
|
|
color "34" "$destination"
|
2020-06-03 21:15:37 +00:00
|
|
|
destination=${file_list[i]#*$searchstring}
|
|
|
|
chmod 755 "$destination"
|
|
|
|
cp -R -L "${file_list[i]}" "$destination"
|
2019-01-06 14:55:10 +00:00
|
|
|
done
|
2019-03-17 20:19:38 +00:00
|
|
|
|
2021-05-17 18:32:04 +00:00
|
|
|
# Run goimports on newly generated protos
|
2019-03-17 20:19:38 +00:00
|
|
|
# formats imports properly.
|
|
|
|
# https://github.com/gogo/protobuf/issues/554
|
2021-10-26 10:07:49 +00:00
|
|
|
goimports -w proto
|
|
|
|
gofmt -s -w proto
|