bazel-contrib / bazel-contrib/rules_go

allow executables not prefixed with protoc-gen in go_proto_compiler

Open
#2,701 0 comments 0 reactions 0 assignees View on GitHub
enhancement proto
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?

v0.24.5

### What version of gazelle are you using?

v0.22.2

### What version of Bazel are you using?

### Does this issue reproduce with the latest releases of all the above?

Yes

### What operating system and processor architecture are you using?

MacOS

### Any other potentially useful information about your toolchain?

None.

### What did you do?

I have a protogen plugin (`go_binary) target` with target name `my/awesome/plugin`. I use

```
go_proto_compiler(
name = "go_awesome_plugin",
plugin = "//my/awesome/plugin",
suffix = ".validate.pb.go",
)
```

to create a `GoProtoCompiler`.
I reference this target in the `go_proto_library` I want to build. I run the build.

### What did you expect to see?

A sucessful build.

### What did you see instead?

An error:

```
protoc-gen-prototool: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--prototool_out: protoc-gen-prototool: Plugin failed with status code 1.
```

---

It would be nice if one could use targets that are not prefixed with `protoc-gen-`.

The code responsible for this:

https://github.com/bazelbuild/rules_go/blob/9c1568a7f510fe306a59f8d09e91579a71f5e08c/go/tools/builders/protoc.go#L74-L84

The above scenario results in `--plugin prototool= --prototool_out=` (to work it must be `--plugin protoc-gen-prototool= --prototool_out=`)

Fixing would be simple:

```
"--plugin", fmt.Sprintf("protoc-gen-%v=%v", pluginName, *plugin),
```

Contributor guide

Open the contributing guide

Research direction

Start in go/tools/builders/protoc.go around lines 74-84 and reproduce the go_proto_compiler build using the unprefixed plugin target described in the issue. Verify the generated protoc plugin argument and confirm that the example build succeeds with a target not named protoc-gen-*. No test file is mentioned in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.