Skip to content

Commit

Permalink
dev: add generate protobuf
Browse files Browse the repository at this point in the history
Convenient, fast.

Release note: None
  • Loading branch information
ajwerner committed Feb 2, 2022
1 parent 8533644 commit 55d23fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=8
DEV_VERSION=9

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
17 changes: 14 additions & 3 deletions pkg/cmd/dev/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ func makeGenerateCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.

func (d *dev) generate(cmd *cobra.Command, targets []string) error {
var generatorTargetMapping = map[string]func(cmd *cobra.Command) error{
"bazel": d.generateBazel,
"docs": d.generateDocs,
"go": d.generateGo,
"bazel": d.generateBazel,
"docs": d.generateDocs,
"go": d.generateGo,
"protobuf": d.generateProtobuf,
}

if len(targets) == 0 {
Expand Down Expand Up @@ -177,3 +178,13 @@ func (d *dev) generateGo(cmd *cobra.Command) error {
}
return d.hoistGeneratedCode(ctx, workspace, bazelBin)
}

func (d *dev) generateProtobuf(cmd *cobra.Command) error {
// The bazel target //pkg/gen:go_proto builds and hoists the protobuf
// go files.
return d.exec.CommandContextInheritingStdStreams(
cmd.Context(), "bazel", append(append([]string{"run"},
mustGetRemoteCacheArgs(remoteCacheAddr)...),
"//pkg/gen:go_proto")...,
)
}

0 comments on commit 55d23fa

Please sign in to comment.