github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/cmd/gazelle/README.md (about)

     1  # cmd/gazelle
     2  
     3  This is essentially a copy of the files in bazelbuild/bazel-gazelle/cmd/gazelle.
     4  
     5  To upgrade gazelle, one must:
     6  
     7  - `go get` the correct version and update `go.mod` file
     8  - `make tidy` to propagate changes to `go.sum` and `go_repositories.bzl`.
     9  - update the version of @bazel_gazelle in `deps/BUILD.bazel`, then run `make
    10     deps` to regenerate the actual deps tree.
    11  - Compare changes in the source repo to the files here.  It's easiest to just
    12     copy over each file and see where the diffs are.  Make sure `langs.go`
    13     includes the `github.com/stackb/rules_proto/language/protobuf`.  Internal
    14     packages referenced must also be copied over (ugh).  There's probably a more elegant solution to keeping a modified copy of gazelle binary here.
    15  - Since the `proto_gazelle.bzl` rule uses
    16    `@bazel_gazelle//internal:gazelle.bash.in`, changes there must remain
    17    compatible with proto_gazelle.  Look at the diff there and make sure the proto_gazelle_impl is satifying the needs of that template.
    18  - Remember that this `cmd/gazelle` must be buildable via the standard go
    19    toolchain (see proto_repository_tools.bzl):
    20  
    21  ```py
    22      args = [
    23          go_tool,
    24          "install",
    25          "-ldflags",
    26          "-w -s",
    27          "-gcflags",
    28          "all=-trimpath=" + env["GOPATH"],
    29          "-asmflags",
    30          "all=-trimpath=" + env["GOPATH"],
    31          "github.com/stackb/rules_proto/cmd/gazelle",
    32      ]
    33      result = env_execute(ctx, args, environment = env)
    34      if result.return_code:
    35          fail("failed to build tools: " + result.stderr)
    36  ```
    37  
    38  So any and all deps must be in the vendor tree.