protobuild icon indicating copy to clipboard operation
protobuild copied to clipboard

Use paths=source_relative flag

Open stevvooe opened this issue 2 years ago • 2 comments

https://developers.google.com/protocol-buffers/docs/reference/go-generated documents a flag paths=source_relative:

If the paths=source_relative flag is specified, the output file is placed in the same relative directory as the input file. For example, an input file protos/buzz.proto results in an output file at protos/buzz.pb.go.

This fixes a chief issue with module-based output, allowing to move to using --go_out=. to work from the repo root.

We should probably move the version 2 config to emit with these options.

stevvooe avatar Jan 20 '22 04:01 stevvooe

With this, we can now support Go module-based generation on containerd with the creation of a directory tree and a single link back to the project:

module=$(go list -m)
mkdir -p /tmp/protoimportroot/$(dirname $module)
ln -sf $PWD /tmp/protoimportroot/$module
protoc -I/tmp/protoimportroot  --go_out=/tmp/protoimportroot/ --go_opt=paths=source_relative --go-grpc_out=/tmp/protoimportroot/ --go-grpc_opt=paths=source_relative /tmp/protoimportroot/$module/api/services/whatever.proto

We do lose support for having other Go projects work as generation and import dependencies, but that's ok for the time-being. It's possible that is a much easier fix, since those all have direct paths in the module cache.

stevvooe avatar Jan 20 '22 04:01 stevvooe

After having #54, we should be able to pass arbitrary parameters with small changes.

kzys avatar Jul 01 '22 20:07 kzys

#54 is all we need actually. It works now (see https://github.com/containerd/cgroups/pull/251).

kzys avatar Nov 07 '22 17:11 kzys