blob: edcc89d3f260743e42107fddf7670dec382c7a84 [file] [log] [blame]
David Burgerc33d1eb2020-01-21 14:24:50 -07001#!/bin/bash -e
2#
3# Copyright 2020 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 configuration protos to produce generated proto code.
8
David Burger1b845362020-02-13 14:43:37 -07009# Allows the recursive glob for proto files below to work.
10shopt -s globstar
11
David Burgerc33d1eb2020-01-21 14:24:50 -070012# Versions of packages to get from CIPD.
13CIPD_PROTOC_VERSION='v3.6.1'
Andrew Lambbc029d32020-02-24 12:42:50 -070014CIPD_PROTOC_GEN_GO_VERSION='v1.3.2'
David Burgerc33d1eb2020-01-21 14:24:50 -070015
16# Move to this script's directory.
17cd "$(dirname "$0")"
18
19# Get protobuf compiler from CIPD.
20cipd_root=.cipd_bin
21cipd ensure \
22 -log-level warning \
23 -root "${cipd_root}" \
24 -ensure-file - \
25 <<ENSURE_FILE
26infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION}
Andrew Lambbc029d32020-02-24 12:42:50 -070027chromiumos/infra/tools/protoc-gen-go version:${CIPD_PROTOC_GEN_GO_VERSION}
David Burgerc33d1eb2020-01-21 14:24:50 -070028ENSURE_FILE
29
30PATH="${cipd_root}:${PATH}"
31
Andrew Lambbc029d32020-02-24 12:42:50 -070032# Collect all the protos.
David Burger1b845362020-02-13 14:43:37 -070033protos=(proto/**/*.proto)
David Burger1b845362020-02-13 14:43:37 -070034
Andrew Lambbc029d32020-02-24 12:42:50 -070035protoc -Iproto --descriptor_set_out=util/bindings/descpb.bin \
Andrew Lambeceaec02020-02-11 14:16:41 -070036 --python_out=payload_utils/bindings \
David Burger1b845362020-02-13 14:43:37 -070037 "${protos[@]}"
Andrew Lambbc029d32020-02-24 12:42:50 -070038
39# Go files need to be processed individually until this is fixed:
40# https://github.com/golang/protobuf/issues/39
41for proto in "${protos[@]}"; do
42 protoc -Iproto --go_out=paths=source_relative:go "${proto}"
43done