uber / prototool

Your Swiss Army Knife for Protocol Buffers
MIT License
5.05k stars 345 forks source link

Relative path support for binaries #493

Closed lukasmalkmus closed 5 years ago

lukasmalkmus commented 5 years ago

It would be great to have relative path support for protoc- binaries: https://github.com/uber/prototool/blob/4a300a9b2a55c7693516746ca22e72c9d00e7d26/etc/config/example/prototool.yaml#L159

I'm in need for this because a project installs its tools into a project local bin folder living in the root of the project while the prototool.yaml lives in api/v1. To use an absolute path isn't possible (multiple people with different location of the project on disc, CI, etc.)

So what I want to basically do is:

protoc:
  plugins:
    - name: go
      type: go
      flags: plugins=grpc
      output: ../../internal/proto/v1
      path: ../../bin/protoc-gen-go
smaye81 commented 5 years ago

This should already work. What error are you seeing?

To test this, I copied and renamed the protoc-gen-gogo plugin binary in my $GOPATH to be protoc-gen-gogo-backup. I was able to generate files with the following config:

  plugins:
    - name: gogo
      type: gogo
      flags: plugins=grpc
      output: ../../gen/proto/go
      path: ../go/bin/protoc-gen-gogo-backup
lukasmalkmus commented 5 years ago

exec: "../../bin/protoc-gen-go": stat ../../bin/protoc-gen-go: no such file or directory

But the executable is definitely there.

To extend my example above, take this projects structure:

.
├── Makefile
├── api
│   └── v1
│       ├── authentication.proto
│       └── prototool.yaml
├── bin
│   ├── protoc-gen-go
│   └── prototool
└── internal
    └── proto
        └── v1
            └── authentication.pb.go

If I run prototool generate in the api/v1 folder, I get the error mentioned above. Although you can clearly see and ls ../../bin/protoc-gen-go verifies: The binary is there.

lukasmalkmus commented 5 years ago

Ah, I was wrong. My bad! Running prototool generate from the api/v1 folder works perfectly fine. I did it from the root of the project: prototool generate api/v1. Without looking at the code, I guess the plugins.output is relative to the protos source location while the plugins.path is evaluated from prototools working directory.

Sorry for the false report.

smaye81 commented 5 years ago

No worries. Glad you worked it out.