Lann Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 1 | #!/bin/bash -e |
Sean Abraham | fdabbe7 | 2019-03-13 09:03:37 -0600 | [diff] [blame^] | 2 | # |
| 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 Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 8 | |
| 9 | # Version of Protobuf compiler to get from CIPD. |
| 10 | CIPD_PROTOC_VERSION='v3.6.1' |
| 11 | |
| 12 | # Move to this script's directory. |
| 13 | cd "$(dirname "$0")" |
| 14 | |
| 15 | # Get protobuf compiler from CIPD. |
| 16 | cipd_root=.cipd_bin |
| 17 | cipd ensure \ |
| 18 | -log-level warning \ |
| 19 | -root "${cipd_root}" \ |
| 20 | -ensure-file - \ |
| 21 | <<< "infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION}" |
| 22 | |
| 23 | protoc="${cipd_root}/protoc" |
| 24 | |
| 25 | # Clean up existing generated files. |
| 26 | find go -name '*.pb.go' -exec rm '{}' \; |
| 27 | |
| 28 | # Go files need to be processed individually until this is fixed: |
| 29 | # https://github.com/golang/protobuf/issues/39 |
| 30 | find src -name '*.proto' -exec \ |
| 31 | "${protoc}" -Isrc --go_out=paths=source_relative:go '{}' \; |