Max Inden 206e4e7553 *: Consolidate protobuf scripts and update to rust-protobuf 2.8.1 (#1275)
* *: Consolidate protobuf generation scripts

* *: Update to rust-protobuf 2.8.1

* *: Mark protobuf generated modules with '_proto'
2019-10-22 13:39:07 +02:00

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