mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-10-05 08:07:18 +08:00

* Add failing proto test * Add a new proto compilation script A proto file's *import path* is relative to one of the `--proto-path`s. Previously, the proto files were compiled separately. Some invocations used different values for the `--proto_path`, which led to inconsistent import paths in proto file descriptors. Typically, this wouldn't be a problem. However, if a downstream project uses `protoregistry.GlobalFiles` to inspect proto dependencies, it will fail to find a dependency's file descriptor when the dependency was compiled with a different `--proto_path`. By using a single script to generate all protobuf files, we can ensure the `--proto_path` is always set to the same sane value (the root of the project, as suggested in the [official documentation]). [official documentation]: https://protobuf.dev/programming-guides/proto2/#importing * Add go_package options so scripts/gen-proto.sh succeeds * Remove undesirable `go:generate protoc` directives * Run `go generate ./...` * Script uses arrays, I think we need bash --------- Co-authored-by: Marco Munizaga <git@marcopolo.io>
28 lines
767 B
Bash
Executable File
28 lines
767 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eou pipefail
|
|
|
|
root=$1
|
|
|
|
proto_array=(
|
|
core/crypto/pb/crypto.proto
|
|
core/record/pb/envelope.proto
|
|
core/peer/pb/peer_record.proto
|
|
core/sec/insecure/pb/plaintext.proto
|
|
p2p/host/autonat/pb/autonat.proto
|
|
p2p/security/noise/pb/payload.proto
|
|
p2p/transport/webrtc/pb/message.proto
|
|
p2p/protocol/identify/pb/identify.proto
|
|
p2p/protocol/circuitv2/pb/circuit.proto
|
|
p2p/protocol/circuitv2/pb/voucher.proto
|
|
p2p/protocol/autonatv2/pb/autonatv2.proto
|
|
p2p/protocol/holepunch/pb/holepunch.proto
|
|
p2p/host/peerstore/pstoreds/pb/pstore.proto
|
|
)
|
|
|
|
proto_paths=""
|
|
for path in "${proto_array[@]}"; do
|
|
proto_paths+="$path "
|
|
done
|
|
|
|
protoc --proto_path=$root --go_out=$root --go_opt=paths=source_relative $proto_paths
|