blob: eb4102fb0025691bafef0b63db33220b28fa5bb0 [file] [log] [blame]
Lann Martind8f0c0c2019-03-08 11:00:32 -07001#!/bin/bash -e
Sean Abrahamfdabbe72019-03-13 09:03:37 -06002#
3# Copyright 2019 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# Runs protoc over the protos in this repo to produce generated proto code.
Lann Martind8f0c0c2019-03-08 11:00:32 -07008
Lann Martin55b94682019-03-15 14:39:38 -06009# Versions of packages to get from CIPD.
Lann Martind8f0c0c2019-03-08 11:00:32 -070010CIPD_PROTOC_VERSION='v3.6.1'
Allen Li474624a2019-12-11 23:55:40 -080011CIPD_PROTOC_GEN_GO_VERSION='v1.3.2'
Lann Martind8f0c0c2019-03-08 11:00:32 -070012
13# Move to this script's directory.
14cd "$(dirname "$0")"
15
16# Get protobuf compiler from CIPD.
17cipd_root=.cipd_bin
18cipd ensure \
19 -log-level warning \
20 -root "${cipd_root}" \
21 -ensure-file - \
Lann Martin55b94682019-03-15 14:39:38 -060022 <<ENSURE_FILE
23infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION}
24chromiumos/infra/tools/protoc-gen-go version:${CIPD_PROTOC_GEN_GO_VERSION}
25ENSURE_FILE
Lann Martind8f0c0c2019-03-08 11:00:32 -070026
Lann Martin55b94682019-03-15 14:39:38 -060027PATH="${cipd_root}:${PATH}"
Lann Martind8f0c0c2019-03-08 11:00:32 -070028
29# Clean up existing generated files.
30find go -name '*.pb.go' -exec rm '{}' \;
31
32# Go files need to be processed individually until this is fixed:
33# https://github.com/golang/protobuf/issues/39
34find src -name '*.proto' -exec \
Allen Li040c1e02019-12-10 18:07:18 -080035 protoc -Isrc --go_out=paths=source_relative,plugins=grpc:go '{}' \;