blob: a314cbc827220b79ff843dc2c37088bf3b46d9ef [file] [log] [blame]
#!/bin/bash -e
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Runs protoc over the protos in this repo to produce generated proto code.
# Versions of packages to get from CIPD.
# Move to this script's directory.
cd "$(dirname "$0")"
# Get protobuf compiler from CIPD.
cipd ensure \
-log-level warning \
-root "${cipd_root}" \
-ensure-file - \
infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION}
chromiumos/infra/tools/protoc-gen-go version:${CIPD_PROTOC_GEN_GO_VERSION}
# Clean up existing generated files.
find go -name '*.pb.go' -exec rm '{}' \;
# Go files need to be processed individually until this is fixed:
find src -name '*.proto' -exec \
protoc -Isrc --go_out=paths=source_relative,plugins=grpc:go '{}' \;
# Assemble a proto descriptor set with all protos in this repo, it is later
# used by lucicfg to work with these protos when generating configs.
export LC_ALL=C # for stable sorting order
all_protos=$(find src -name "*.proto" | cut -d'/' -f2- | sort)
protoc -Isrc --descriptor_set_out=descpb.bin ${all_protos}