Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
Bring bazel generate up-to-date with make bazel-generate at HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
rickystewart committed Feb 23, 2021
1 parent ee14915 commit 6c54f71
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ package main

import (
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"

"github.com/cockroachdb/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -73,5 +78,19 @@ func runGenerate(cmd *cobra.Command, targets []string) error {
}

func generateBazel(ctx context.Context, cmd *cobra.Command) error {
return execute(ctx, "bazel", "run", "@cockroach//:gazelle", "--color=yes")
if err := execute(ctx, "bazel", "run", "//:gazelle", "--", "update-repos", "-from_file=go.mod", "-build_file_proto_mode=disable_global", "-to_macro=DEPS.bzl%go_deps", "-prune=true"); err != nil {
return err
}
cwd, err := os.Getwd()
if err != nil {
return err
}
buf, err := exec.Command("bazel", "run", "//pkg/cmd/generate-test-suites", "--run_under", fmt.Sprintf("cd %s &&", cwd)).Output()
if err != nil {
return err
}
if err := ioutil.WriteFile(path.Join(cwd, "pkg/BUILD.bazel"), buf, 0644); err != nil {
return err
}
return execute(ctx, "bazel", "run", "//:gazelle")
}

0 comments on commit 6c54f71

Please sign in to comment.