...

Text file src/github.com/letsencrypt/boulder/grpc/protogen.sh

Documentation: github.com/letsencrypt/boulder/grpc

     1#!/usr/bin/env bash
     2
     3# Should point to /path/to/boulder, given that this script
     4# lives in the //grpc subdirectory of the boulder repo.
     5root_dir=$(dirname $(dirname $(readlink -f "$0")))
     6
     7# Find each file below root_dir whose name matches *.proto and whose
     8# path does not include the "vendor" directory. Emit them null-delimited
     9# (to allow for spaces and newlines in filenames), and assign each to the
    10# local variable `file`.
    11find "${root_dir}" -name "*.proto" -not -path "*/vendor/*" -print0 | while read -d $'\0' file
    12do
    13  # Have to use absolute paths to make protoc happy.
    14  proto_file=$(realpath "${file}")
    15  proto_dir=$(dirname "${proto_file}")
    16  # -I "${proto_dir}" makes imports search the current directory first
    17  # -I "${root_dir}" ensures that our proto files can import each other
    18  # --go_out="${proto_dir}" writes the .pb.go file adjacent to the proto file
    19  # --go-grpc_out="${proto_dir}" does the same for _grpc.pb.go
    20  # --go_opt=paths=source_relative derives output filenames from input filenames
    21  # --go-grpc_opt=paths=source_relative does the same for _grpc.pb.go
    22  protoc -I "${proto_dir}" -I "${root_dir}" --go_out="${proto_dir}" --go-grpc_out="${proto_dir}" --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative "${proto_file}"
    23done

View as plain text