blob: 5c748e35cf9829f63d6951ebfaf2869615539d3e [file] [log] [blame]
Brian Silverman9c614bc2016-02-15 20:20:02 -05001#!/bin/bash
2# Generates C# source files from .proto files.
3# You first need to make sure protoc has been built (see instructions on
4# building protoc in root of this repository)
5
Austin Schuh40c16522018-10-28 20:27:54 -07006set -e
Brian Silverman9c614bc2016-02-15 20:20:02 -05007
8# cd to repository root
Austin Schuh40c16522018-10-28 20:27:54 -07009pushd $(dirname $0)/..
Brian Silverman9c614bc2016-02-15 20:20:02 -050010
11# Protocol buffer compiler to use. If the PROTOC variable is set,
12# use that. Otherwise, probe for expected locations under both
13# Windows and Unix.
14if [ -z "$PROTOC" ]; then
15 # TODO(jonskeet): Use an array and a for loop instead?
16 if [ -x cmake/build/Debug/protoc.exe ]; then
17 PROTOC=cmake/build/Debug/protoc.exe
18 elif [ -x cmake/build/Release/protoc.exe ]; then
19 PROTOC=cmake/build/Release/protoc.exe
20 elif [ -x src/protoc ]; then
21 PROTOC=src/protoc
22 else
23 echo "Unable to find protocol buffer compiler."
24 exit 1
25 fi
26fi
27
28# descriptor.proto and well-known types
29$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
30 --csharp_opt=base_namespace=Google.Protobuf \
31 src/google/protobuf/descriptor.proto \
32 src/google/protobuf/any.proto \
33 src/google/protobuf/api.proto \
34 src/google/protobuf/duration.proto \
35 src/google/protobuf/empty.proto \
36 src/google/protobuf/field_mask.proto \
37 src/google/protobuf/source_context.proto \
38 src/google/protobuf/struct.proto \
39 src/google/protobuf/timestamp.proto \
40 src/google/protobuf/type.proto \
41 src/google/protobuf/wrappers.proto
42
Austin Schuh40c16522018-10-28 20:27:54 -070043# Test protos
44$PROTOC -Isrc -Icsharp/protos \
45 --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
46 csharp/protos/map_unittest_proto3.proto \
47 csharp/protos/unittest_issues.proto \
48 csharp/protos/unittest_custom_options_proto3.proto \
49 csharp/protos/unittest_proto3.proto \
50 csharp/protos/unittest_import_proto3.proto \
51 csharp/protos/unittest_import_public_proto3.proto \
52 src/google/protobuf/unittest_well_known_types.proto \
53 src/google/protobuf/test_messages_proto3.proto
Brian Silverman9c614bc2016-02-15 20:20:02 -050054
55# AddressBook sample protos
Austin Schuh40c16522018-10-28 20:27:54 -070056$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
Brian Silverman9c614bc2016-02-15 20:20:02 -050057 examples/addressbook.proto
58
59$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
60 conformance/conformance.proto