David Burger | c33d1eb | 2020-01-21 14:24:50 -0700 | [diff] [blame] | 1 | #!/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 | |
| 9 | # Versions of packages to get from CIPD. |
| 10 | CIPD_PROTOC_VERSION='v3.6.1' |
Andrew Lamb | 9aadbc8 | 2020-01-30 09:41:35 -0700 | [diff] [blame^] | 11 | CIPD_PROTOC_GEN_GO_VERSION='v1.3.2' |
David Burger | c33d1eb | 2020-01-21 14:24:50 -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 - \ |
| 22 | <<ENSURE_FILE |
| 23 | infra/tools/protoc/\${platform} protobuf_version:${CIPD_PROTOC_VERSION} |
Andrew Lamb | 9aadbc8 | 2020-01-30 09:41:35 -0700 | [diff] [blame^] | 24 | chromiumos/infra/tools/protoc-gen-go version:${CIPD_PROTOC_GEN_GO_VERSION} |
David Burger | c33d1eb | 2020-01-21 14:24:50 -0700 | [diff] [blame] | 25 | ENSURE_FILE |
| 26 | |
| 27 | PATH="${cipd_root}:${PATH}" |
| 28 | |
Andrew Lamb | 9aadbc8 | 2020-01-30 09:41:35 -0700 | [diff] [blame^] | 29 | all_protos=( |
| 30 | chromite/infra/proto/src/chromiumos/common.proto |
| 31 | src/config/api/build_config.proto |
| 32 | src/config/api/component.proto |
| 33 | src/config/api/component_id.proto |
| 34 | src/config/api/config_bundle.proto |
| 35 | src/config/api/design.proto |
| 36 | src/config/api/design_config_id.proto |
| 37 | src/config/api/design_id.proto |
| 38 | src/config/api/device_brand.proto |
| 39 | src/config/api/device_brand_id.proto |
| 40 | src/config/api/hardware_topology.proto |
| 41 | src/config/api/partner.proto |
| 42 | src/config/api/partner_id.proto |
| 43 | src/config/api/program.proto |
| 44 | src/config/api/program_id.proto |
| 45 | src/config/api/topology.proto |
| 46 | src/third_party/chromiumos-overlay/proto/audio_config.proto |
| 47 | src/third_party/chromiumos-overlay/proto/brand_config.proto |
| 48 | src/third_party/chromiumos-overlay/proto/build_target_config_id.proto |
| 49 | src/third_party/chromiumos-overlay/proto/design_variant_config.proto |
| 50 | src/third_party/chromiumos-overlay/proto/firmware_config.proto |
| 51 | src/platform2/bluetooth/proto/config.proto |
| 52 | src/platform2/chromeos-config/proto/design_variant_id_scan_config.proto |
| 53 | src/platform2/chromeos-config/proto/brand_id_scan_config.proto |
Andrew Lamb | 95561d8 | 2020-01-21 16:36:51 -0700 | [diff] [blame] | 54 | src/platform2/power_manager/config.proto |
Andrew Lamb | 9aadbc8 | 2020-01-30 09:41:35 -0700 | [diff] [blame^] | 55 | ) |
| 56 | |
| 57 | protoc -I../../ --descriptor_set_out=proto/descpb.bin "${all_protos[@]}" |
| 58 | |
| 59 | # Clean up existing generated Go files. |
| 60 | find go -name '*.pb.go' -exec rm '{}' \; |
| 61 | |
| 62 | # Go files need to be processed individually until this is fixed: |
| 63 | # https://github.com/golang/protobuf/issues/39 |
| 64 | for proto in "${all_protos[@]}"; do |
| 65 | # platform2 protos currently do not specify a go_package, so any proto |
| 66 | # importing them specifies an invalid import path and cannot compile. |
| 67 | # TODO(crbug.com/1046074): Compile platform2 protos once crrev.com/c/2023308 |
| 68 | # is submitted. |
| 69 | if [[ $proto == src/config/* && $proto != src/config/api/build_config.proto ]] |
| 70 | then |
| 71 | protoc -I../../ --go_out=paths=source_relative:go "${proto}" |
| 72 | fi |
| 73 | done |
| 74 | |
| 75 | cd ./go |
| 76 | go test ./... |