mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-01 05:32:19 +00:00
* *: Consolidate protobuf generation scripts * *: Update to rust-protobuf 2.8.1 * *: Mark protobuf generated modules with '_proto'
36 lines
837 B
Bash
Executable File
36 lines
837 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# exit immediately when a command fails
|
|
set -e
|
|
# only exit with zero if all commands of the pipeline exit successfully
|
|
set -o pipefail
|
|
# error on unset variables
|
|
set -u
|
|
# print each command before executing it
|
|
set -x
|
|
|
|
|
|
# The source .proto file.
|
|
SOURCE_PROTO_FILE=$1
|
|
|
|
DEST_FOLDER=$(dirname "$SOURCE_PROTO_FILE")
|
|
|
|
# The .rs file generated via protoc.
|
|
TMP_GEN_RUST_FILE=${SOURCE_PROTO_FILE/proto/rs}
|
|
|
|
# The above with `_proto` injected.
|
|
FINAL_GEN_RUST_FILE=${TMP_GEN_RUST_FILE/.rs/_proto.rs}
|
|
|
|
|
|
sudo docker build -t rust-libp2p-protobuf-builder $(dirname "$0")
|
|
|
|
sudo docker run --rm \
|
|
-v `pwd`:/usr/code:z \
|
|
-u="$(id -u):$(id -g)" \
|
|
-w /usr/code \
|
|
rust-libp2p-protobuf-builder \
|
|
/bin/bash -c " \
|
|
protoc --rust_out $DEST_FOLDER $SOURCE_PROTO_FILE"
|
|
|
|
|
|
mv $TMP_GEN_RUST_FILE $FINAL_GEN_RUST_FILE
|