blob: 9899097ddfabc6649105cf2f27c1ddc32605ea40 [file] [log] [blame]
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -07001#!/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
6set -ex
7
8# cd to repository root
9cd $(dirname $0)/..
10
Jon Skeet734393d2015-05-14 09:11:57 +010011# 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?
Jon Skeet09f3f4e2015-06-17 15:16:14 +010016 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
Jon Skeet734393d2015-05-14 09:11:57 +010020 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
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070027
Jon Skeet5eb1fac2015-09-01 15:05:03 +010028# 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 \
Jon Skeet739d13d2015-07-14 14:26:31 +010032 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
Jon Skeet5eb1fac2015-09-01 15:05:03 +010043# Test protos where the namespace matches the target location
44$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
45 --csharp_opt=base_namespace=Google.Protobuf \
Jon Skeetc1283312015-06-26 10:32:23 +010046 src/google/protobuf/map_unittest_proto3.proto \
Jon Skeeteb70bd02015-06-12 09:53:44 +010047 src/google/protobuf/unittest_proto3.proto \
48 src/google/protobuf/unittest_import_proto3.proto \
Jon Skeetb2ac8682015-07-15 13:17:42 +010049 src/google/protobuf/unittest_import_public_proto3.proto \
50 src/google/protobuf/unittest_well_known_types.proto
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070051
Jon Skeet5eb1fac2015-09-01 15:05:03 +010052# Different base namespace to the protos above
53$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
54 --csharp_opt=base_namespace=UnitTest.Issues \
Jon Skeet0f370b42015-08-03 10:59:27 +010055 csharp/protos/unittest_issues.proto
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070056
Jon Skeet734393d2015-05-14 09:11:57 +010057# AddressBook sample protos
58$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
59 examples/addressbook.proto
Jon Skeet044c36e2015-08-04 09:25:38 +010060
Jon Skeetd49b9c82016-01-04 14:02:00 +000061$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
Jon Skeet044c36e2015-08-04 09:25:38 +010062 conformance/conformance.proto