diff options
author | Jon Skeet <jonskeet@google.com> | 2015-05-14 09:11:57 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-05-14 09:11:57 +0100 |
commit | 734393d0f9e1f746f4bd228f709c5b1142faa16d (patch) | |
tree | 3cb105db805c328c1823d1c191301f2fb45397af /csharp/generate_protos.sh | |
parent | 2d9b1c592ff7319ee9d6520c9df4838087522e05 (diff) | |
download | protobuf-734393d0f9e1f746f4bd228f709c5b1142faa16d.tar.gz protobuf-734393d0f9e1f746f4bd228f709c5b1142faa16d.tar.bz2 protobuf-734393d0f9e1f746f4bd228f709c5b1142faa16d.zip |
Make generate_protos.sh Windows-friendly.
To my surprise, executing generate_protos.sh used the version of Bash installed with Git for Windows by default.
After a few modifications to detect the most appropriate protoc to use, this worked pretty simply.
This change also:
- adds generation of the address book tutorial proto,
- fixes the addressbook.proto to specify proto2 explicitly (to avoid a warning from protoc; I don't think we want warnings...)
- fixes the addressbook.proto C# namespace (which I thought I'd done before, but apparently hadn't)
- includes the regenerated UnittestCustomOptions.cs apart from the DescriptorProtoFIle => Descriptor change
Diffstat (limited to 'csharp/generate_protos.sh')
-rwxr-xr-x | csharp/generate_protos.sh | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index 9cd3eb58..8c066cbe 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -8,8 +8,22 @@ set -ex # cd to repository root cd $(dirname $0)/.. -# protocol buffer compiler to use -PROTOC=src/protoc +# Protocol buffer compiler to use. If the PROTOC variable is set, +# use that. Otherwise, probe for expected locations under both +# Windows and Unix. +if [ -z "$PROTOC" ]; then + # TODO(jonskeet): Use an array and a for loop instead? + if [ -x vsprojects/Debug/protoc.exe ]; then + PROTOC=vsprojects/Debug/protoc.exe + elif [ -x vsprojects/Release/protoc.exe ]; then + PROTOC=vsprojects/Release/protoc.exe + elif [ -x src/protoc ]; then + PROTOC=src/protoc + else + echo "Unable to find protocol buffer compiler." + exit 1 + fi +fi # Descriptor proto #TODO(jtattermusch): generate descriptor.proto @@ -48,3 +62,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ $PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ csharp/protos/extest/unittest_extras_full.proto \ csharp/protos/extest/unittest_extras_lite.proto + +# AddressBook sample protos +$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ + examples/addressbook.proto |