1#!/bin/sh -ex 2 3cd "$(dirname "$0")" 4 5die() { 6 echo "$@" >&2 7 exit 1 8} 9 10protoc_ver=$(protoc --version) 11case "$protoc_ver" in 12"libprotoc 3"*) ;; 13*) 14 die "you need to use protobuf 3 to regenerate .rs from .proto" 15 ;; 16esac 17 18cargo build --manifest-path=../protobuf-codegen/Cargo.toml 19cargo build --manifest-path=../protoc-bin/Cargo.toml --bin protoc-bin-print-paths 20 21eval "$(cargo run --manifest-path=../protoc-bin/Cargo.toml --bin protoc-bin-print-paths)" 22 23test -n "$PROTOC" 24 25where_am_i=$( 26 cd .. 27 pwd 28) 29 30rm -rf tmp-generated 31mkdir tmp-generated 32 33case $(uname) in 34Linux) 35 exe_suffix="" 36 ;; 37MSYS_NT*) 38 exe_suffix=".exe" 39 ;; 40esac 41 42"$PROTOC" \ 43 --plugin=protoc-gen-rust="$where_am_i/target/debug/protoc-gen-rust$exe_suffix" \ 44 --rust_out tmp-generated \ 45 --rust_opt 'inside_protobuf=true gen_mod_rs=false' \ 46 -I../proto \ 47 ../proto/google/protobuf/*.proto \ 48 ../proto/google/protobuf/compiler/*.proto \ 49 ../proto/rustproto.proto \ 50 ../proto/doctest_pb.proto 51 52mv \ 53 tmp-generated/descriptor.rs \ 54 tmp-generated/plugin.rs \ 55 tmp-generated/rustproto.rs \ 56 tmp-generated/doctest_pb.rs \ 57 src/ 58mv tmp-generated/well_known_types_mod.rs src/well_known_types/mod.rs 59mv tmp-generated/*.rs src/well_known_types/ 60 61# vim: set ts=4 sw=4 et: 62