blob: da6f940e8bfae2dbcd949d203940f0d88d1191e7 [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
Jon Skeetb1a395c2015-05-15 14:36:07 +01006# This script performs a few fix-ups as part of generation. These are:
7# - descriptor.proto is renamed to descriptor_proto_file.proto before
8# generation, to avoid the naming collision between the class for the file
9# descriptor and its Descriptor property
10# - This change also impacts UnittestCustomOptions, which expects to
11# use a class of Descriptor when it's actually been renamed to
12# DescriptorProtoFile.
13# - Issue 307 (codegen for double-nested types) breaks Unittest.proto and
14# its lite equivalents.
15
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070016set -ex
17
18# cd to repository root
19cd $(dirname $0)/..
20
Jon Skeet734393d2015-05-14 09:11:57 +010021# Protocol buffer compiler to use. If the PROTOC variable is set,
22# use that. Otherwise, probe for expected locations under both
23# Windows and Unix.
24if [ -z "$PROTOC" ]; then
25 # TODO(jonskeet): Use an array and a for loop instead?
Jon Skeet09f3f4e2015-06-17 15:16:14 +010026 if [ -x cmake/build/Debug/protoc.exe ]; then
27 PROTOC=cmake/build/Debug/protoc.exe
28 elif [ -x cmake/build/Release/protoc.exe ]; then
29 PROTOC=cmake/build/Release/protoc.exe
Jon Skeet734393d2015-05-14 09:11:57 +010030 elif [ -x src/protoc ]; then
31 PROTOC=src/protoc
32 else
33 echo "Unable to find protocol buffer compiler."
34 exit 1
35 fi
36fi
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070037
38# Descriptor proto
Jon Skeetb1a395c2015-05-15 14:36:07 +010039# TODO(jonskeet): Remove fixup
Jon Skeet59eeebe2015-07-17 08:26:04 +010040$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/Reflection \
Jon Skeetca89a1a2015-08-25 14:32:28 +010041 src/google/protobuf/descriptor.proto
Jon Skeetb1a395c2015-05-15 14:36:07 +010042
Jon Skeet59eeebe2015-07-17 08:26:04 +010043$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/WellKnownTypes \
Jon Skeet739d13d2015-07-14 14:26:31 +010044 src/google/protobuf/any.proto \
45 src/google/protobuf/api.proto \
46 src/google/protobuf/duration.proto \
47 src/google/protobuf/empty.proto \
48 src/google/protobuf/field_mask.proto \
49 src/google/protobuf/source_context.proto \
50 src/google/protobuf/struct.proto \
51 src/google/protobuf/timestamp.proto \
52 src/google/protobuf/type.proto \
53 src/google/protobuf/wrappers.proto
54
Jon Skeet59eeebe2015-07-17 08:26:04 +010055$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
Jon Skeetc1283312015-06-26 10:32:23 +010056 src/google/protobuf/map_unittest_proto3.proto \
Jon Skeeteb70bd02015-06-12 09:53:44 +010057 src/google/protobuf/unittest_proto3.proto \
58 src/google/protobuf/unittest_import_proto3.proto \
Jon Skeetb2ac8682015-07-15 13:17:42 +010059 src/google/protobuf/unittest_import_public_proto3.proto \
60 src/google/protobuf/unittest_well_known_types.proto
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070061
Jon Skeetc1283312015-06-26 10:32:23 +010062
Jon Skeet0f370b42015-08-03 10:59:27 +010063$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
64 csharp/protos/unittest_issues.proto
Jan Tattermuschdfefe9a2015-05-12 20:52:28 -070065
Jon Skeet734393d2015-05-14 09:11:57 +010066# AddressBook sample protos
67$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
68 examples/addressbook.proto
Jon Skeet044c36e2015-08-04 09:25:38 +010069
70$PROTOC -Iconformance --csharp_out=csharp/src/Google.Protobuf.Conformance \
71 conformance/conformance.proto