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 | |
Lann Martin | 55b9468 | 2019-03-15 14:39:38 -0600 | [diff] [blame^] | 9 | # Versions of packages to get from CIPD. |
Lann Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 10 | CIPD_PROTOC_VERSION='v3.6.1' |
Lann Martin | 55b9468 | 2019-03-15 14:39:38 -0600 | [diff] [blame^] | 11 | CIPD_PROTOC_GEN_GO_VERSION='v1.3.1' |
Lann Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 12 | |
| 13 | # Move to this script's directory. |
| 14 | cd "$(dirname "$0")" |
| 15 | |
| 16 | # Get protobuf compiler from CIPD. |
| 17 | cipd_root=.cipd_bin |
| 18 | cipd ensure \ |
| 19 | -log-level warning \ |
| 20 | -root "${cipd_root}" \ |
| 21 | -ensure-file - \ |
Lann Martin | 55b9468 | 2019-03-15 14:39:38 -0600 | [diff] [blame^] | 22 | <<ENSURE_FILE |
| 23 | infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION} |
| 24 | chromiumos/infra/tools/protoc-gen-go version:${CIPD_PROTOC_GEN_GO_VERSION} |
| 25 | ENSURE_FILE |
Lann Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 26 | |
Lann Martin | 55b9468 | 2019-03-15 14:39:38 -0600 | [diff] [blame^] | 27 | PATH="${cipd_root}:${PATH}" |
Lann Martin | d8f0c0c | 2019-03-08 11:00:32 -0700 | [diff] [blame] | 28 | |
| 29 | # Clean up existing generated files. |
| 30 | find 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 |
| 34 | find src -name '*.proto' -exec \ |
Lann Martin | 55b9468 | 2019-03-15 14:39:38 -0600 | [diff] [blame^] | 35 | protoc -Isrc --go_out=paths=source_relative:go '{}' \; |