github.com/prysmaticlabs/prysm@v1.4.4/scripts/update-go-pbs.sh (about)

     1  #!/bin/bash
     2  . "$(dirname "$0")"/common.sh
     3  
     4  # Script to copy pb.go files from bazel build folder to appropriate location.
     5  # Bazel builds to bazel-bin/... folder, script copies them back to original folder where .proto is.
     6  
     7  bazel build //proto/...
     8  
     9  file_list=()
    10  while IFS= read -d $'\0' -r file; do
    11      file_list=("${file_list[@]}" "$file")
    12  done < <($findutil -L "$(bazel info bazel-bin)"/proto -type f -regextype sed -regex ".*pb\.\(gw\.\)\?go$" -print0)
    13  
    14  arraylength=${#file_list[@]}
    15  searchstring="prysmaticlabs/prysm/"
    16  
    17  # Copy pb.go files from bazel-bin to original folder where .proto is.
    18  for ((i = 0; i < arraylength; i++)); do
    19      color "34" "$destination"
    20      destination=${file_list[i]#*$searchstring}
    21      chmod 755 "$destination"
    22      cp -R -L "${file_list[i]}" "$destination"
    23  done
    24  
    25  # Run goimports on newly generated protos
    26  # formats imports properly.
    27  # https://github.com/gogo/protobuf/issues/554
    28  goimports -w proto/**/*.pb.go
    29  gofmt -s -w proto/