package
3.2.0+incompatible
Repository: https://github.com/stackb/rules_proto.git
Documentation: pkg.go.dev

# README

cmd/gazelle

This is essentially a copy of the files in bazelbuild/bazel-gazelle/cmd/gazelle.

To upgrade gazelle, one must:

  • go get the correct version and update go.mod file
  • make tidy to propagate changes to go.sum and go_repositories.bzl.
  • update the version of @bazel_gazelle in deps/BUILD.bazel, then run make deps to regenerate the actual deps tree.
  • Compare changes in the source repo to the files here. It's easiest to just copy over each file and see where the diffs are. Make sure langs.go includes the github.com/stackb/rules_proto/language/protobuf. Internal packages referenced must also be copied over (ugh). There's probably a more elegant solution to keeping a modified copy of gazelle binary here.
  • Since the proto_gazelle.bzl rule uses @bazel_gazelle//internal:gazelle.bash.in, changes there must remain compatible with proto_gazelle. Look at the diff there and make sure the proto_gazelle_impl is satifying the needs of that template.
  • Remember that this cmd/gazelle must be buildable via the standard go toolchain (see proto_repository_tools.bzl):
    args = [
        go_tool,
        "install",
        "-ldflags",
        "-w -s",
        "-gcflags",
        "all=-trimpath=" + env["GOPATH"],
        "-asmflags",
        "all=-trimpath=" + env["GOPATH"],
        "github.com/stackb/rules_proto/cmd/gazelle",
    ]
    result = env_execute(ctx, args, environment = env)
    if result.return_code:
        fail("failed to build tools: " + result.stderr)

So any and all deps must be in the vendor tree.

# Functions

FindRepoRoot searches from the given dir and up for a directory containing a WORKSPACE file returning the directory containing it, or an error if none found in the tree.
FindWORKSPACEFile returns a path to a file in the provided root directory, either to an existing WORKSPACE or WORKSPACE.bazel file, or to root/WORKSPACE if neither exists.
IsWORKSPACE checks whether path is a WORKSPACE or WORKSPACE.bazel file.