forked from openconfig/bootz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regenerate-files.sh
executable file
·28 lines (23 loc) · 1.15 KB
/
regenerate-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
set -euo pipefail
BASE=$(bazel info bazel-genfiles)
BOOTZ_NS='github.com/openconfig/bootz/proto'
ENTITY_NS='github.com/openconfig/bootz/server/entitymanager/proto'
copy_generated() {
pkg="$1"
# Default to using package name for proto if $4 is unset
proto="$1" && [ "${4++}" ] && proto="$4"
# Bazel go_rules will create empty files containing "// +build ignore\n\npackage ignore"
# in the case where the protoc compiler doesn't generate any output. See:
# https://github.com/bazelbuild/rules_go/blob/03a8b8e90eebe699d7/go/tools/builders/protoc.go#L190
for file in "${BASE}""/${3}""${proto}"_go_proto_/"${2}"/"${pkg}"/*.pb.go; do
[[ $(head -n 1 "${file}") == "// +build ignore" ]] || cp -f "${file}" "${3}${pkg}/"
done
}
# Don't upgrade bazel version until repo supports 7.0 syntax
export USE_BAZEL_VERSION=6.4.0
bazel build //proto:all
bazel build //server/entitymanager/proto:all
# first arg is the package name, second arg is namespace for the package, and thrid is the location where the generated code will be saved.
copy_generated "bootz" ${BOOTZ_NS} "proto/"
copy_generated "entity" ${ENTITY_NS} "server/entitymanager/proto/"