blob: a8d95aafa52730831c565e4dacab59e9b8c981bb [file] [log] [blame]
temporal40ee5512008-07-10 02:12:20 +00001#!/bin/sh
2
3# Run this script to regenerate descriptor.pb.{h,cc} after the protocol
4# compiler changes. Since these files are compiled into the protocol compiler
5# itself, they cannot be generated automatically by a make rule. "make check"
6# will fail if these files do not match what the protocol compiler would
7# generate.
kenton@google.com80b1d622009-07-29 01:13:20 +00008#
9# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
10# to make when building protoc. This is particularly useful for passing
11# -j4 to run 4 jobs simultaneously.
temporal40ee5512008-07-10 02:12:20 +000012
temporal40ee5512008-07-10 02:12:20 +000013if test ! -e src/google/protobuf/stubs/common.h; then
14 cat >&2 << __EOF__
15Could not find source code. Make sure you are running this script from the
16root of the distribution tree.
17__EOF__
18 exit 1
19fi
20
21if test ! -e src/Makefile; then
22 cat >&2 << __EOF__
23Could not find src/Makefile. You must run ./configure (and perhaps
24./autogen.sh) first.
25__EOF__
26 exit 1
27fi
28
kenton@google.com2f669cb2008-12-02 05:59:15 +000029cd src
Jisi Liu885b6122015-02-28 14:51:22 -080030CORE_PROTO_IS_CORRECT=0
31while [ $CORE_PROTO_IS_CORRECT -ne 1 ]
32do
33 CORE_PROTO_IS_CORRECT=1
34 cp google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp
35 cp google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp
36 cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp
37 cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp
38
39 make -j8 $@ protoc &&
40 ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. google/protobuf/descriptor.proto && \
41 ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto
42
43 diff google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp > /dev/null
44 if test $? -ne 0; then
45 CORE_PROTO_IS_CORRECT=0
46 fi
47 diff google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp > /dev/null
48 if test $? -ne 0; then
49 CORE_PROTO_IS_CORRECT=0
50 fi
51 diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null
52 if test $? -ne 0; then
53 CORE_PROTO_IS_CORRECT=0
54 fi
55 diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null
56 if test $? -ne 0; then
57 CORE_PROTO_IS_CORRECT=0
58 fi
59
60 rm google/protobuf/descriptor.pb.h.tmp
61 rm google/protobuf/descriptor.pb.cc.tmp
62 rm google/protobuf/compiler/plugin.pb.h.tmp
63 rm google/protobuf/compiler/plugin.pb.cc.tmp
64done
kenton@google.com2f669cb2008-12-02 05:59:15 +000065cd ..