commit | 4d1d1337474010a27aeee2c2e271cf93882a7bfa | [log] [tgz] |
---|---|---|
author | Vadim Shtayura <vadimsh@chromium.org> | Wed Feb 09 00:44:51 2022 |
committer | LUCI CQ <infra-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Feb 09 00:44:51 2022 |
tree | 2ae62e6368a1c48c07d83018968a9d2093a93e0f | |
parent | 7e42178fccd7fd86fb317ea55d80a9b7e81b4828 [diff] |
[cproto] Put -proto-path last in --proto_path passed to protoc. When using cproto with Go modules, it builds a staging directory with Go modules symlinked into directories based on their module names, e.g. "infra" becomes "<staging>/infra" and "go.chromium.org/luci" becomes "<staging>/go.chromium.org/luci", where "<staging>" is some temp directory. It then calls protoc as protoc --proto_path <staging> ... <staging>/some/file.proto That way proto files can maintain the illusion they live in a single source tree (like they did in the GOPATH mode). Now there's a problem: this staging tree contains only real Go modules. This doesn't work for go.chromium.org/chromiumos/config protos: they aren't actually in a Go module. They just happened to be under GOPATH when GOPATH existed. There's a known solution for telling protoc about such out-of-tree files: --proto_path (which cproto exposes as -proto-path flag). Due to how our Go modules and git checkouts laid out on disk, `--proto_path` needed to pick up go.chromium.org/chromiumos/config protos happens to match former GOPATH (this is not surprising, considering we migrated to Go modules without moving any files). In particular, when such --proto_path is passed to protoc, the call looks like: protoc \ --proto_path <former_root> \ --proto_path <staging> \ <staging>/some/file.proto Again, due to how our checkouts laid out, <staging>/some/file.proto and <former_root>/some/file.proto are actually the exact same file (<staging> was meant to emulate former GOPATH layout after all). To derive proto file names for the proto registry, protoc calculates relative path from <staging>/some/file.proto to *any* of `--proto_path`. And it appears it is getting confused when it finds the input file in another (non <staging>) --proto_path if this path precedes <staging>: <staging>/infra/tools/dirmd/proto/chromeos/chromeos.proto: Input is shadowed in the --proto_path by "<former_root>/infra/tools/dirmd/proto/chromeos/chromeos.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first. This CL makes sure protoc is called like: protoc \ --proto_path <staging> \ --proto_path <former_root> \ <staging>/some/file.proto It makes protoc happy. R=chanli@chromium.org Change-Id: Ifabfb32d77d84b769ce8b72309ed3227f8276025 Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/3449095 Reviewed-by: Chan Li <chanli@chromium.org> Commit-Queue: Vadim Shtayura <vadimsh@chromium.org> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
LUCI Go code is meant to be worked on from an Chromium infra.git checkout, which enforces packages versions and Go toolchain version. First get fetch via depot_tools.git then run:
fetch infra cd infra/go eval `./env.py` cd src/go.chromium.org/luci
Contributing uses the same flow as Chromium contributions.