[cproto] Put -proto-path last in --proto_path passed to protoc.
[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=332b6c56634d0f63001046c664a2370006a02420@chromium.org

Change-Id: Ifabfb32d77d84b769ce8b72309ed3227f8276025
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/3449095
Reviewed-by: Chan Li <332b6c56634d0f63001046c664a2370006a02420@chromium.org>
Commit-Queue: Vadim Shtayura <9f116ddb1b24f6fc1916a676eb17161b6c07dfc1@chromium.org>
Reviewed-by: Robbie Iannucci <40f3d43a28ebae3cb819288542e1c84d73d962d5@chromium.org>

luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go