From 44181c02c4e80c404a2544f88c9542a15d8f3306 Mon Sep 17 00:00:00 2001
From: Alistair Veitch <aveitch@google.com>
Date: Thu, 26 May 2016 10:29:38 -0700
Subject: [PATCH] fix options file; fix generated include guards

---
 build.yaml                           | 1 +
 src/core/ext/census/gen/census.pb.h  | 4 ++--
 src/proto/census/census.options      | 2 +-
 third_party/protobuf                 | 2 +-
 tools/codegen/core/gen_nano_proto.sh | 7 +++++++
 5 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/build.yaml b/build.yaml
index 19e4b1adcd..bbd60cbe21 100644
--- a/build.yaml
+++ b/build.yaml
@@ -34,6 +34,7 @@ filegroups:
   plugin: census_grpc_plugin
   uses:
   - grpc_base
+  - nanopb
 - name: gpr_base
   public_headers:
   - include/grpc/support/alloc.h
diff --git a/src/core/ext/census/gen/census.pb.h b/src/core/ext/census/gen/census.pb.h
index fe263988c3..d040fe29e7 100644
--- a/src/core/ext/census/gen/census.pb.h
+++ b/src/core/ext/census/gen/census.pb.h
@@ -33,8 +33,8 @@
 /* Automatically generated nanopb header */
 /* Generated by nanopb-0.3.5-dev */
 
-#ifndef PB_CENSUS_PB_H_INCLUDED
-#define PB_CENSUS_PB_H_INCLUDED
+#ifndef GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H
+#define GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H
 #include "third_party/nanopb/pb.h"
 #if PB_PROTO_HEADER_VERSION != 30
 #error Regenerate this file with the current version of nanopb generator.
diff --git a/src/proto/census/census.options b/src/proto/census/census.options
index 08ebbc071b..a1f80395c7 100644
--- a/src/proto/census/census.options
+++ b/src/proto/census/census.options
@@ -1,3 +1,3 @@
 google.census.Tag.key max_size:255
 google.census.Tag.value max_size:255
-google.census.View.tag_keys max_count 15
+google.census.View.tag_key max_count:15
diff --git a/third_party/protobuf b/third_party/protobuf
index 3470b6895a..a1938b2aa9 160000
--- a/third_party/protobuf
+++ b/third_party/protobuf
@@ -1 +1 @@
-Subproject commit 3470b6895aa659b7559ed678e029a5338e535f14
+Subproject commit a1938b2aa9ca86ce7ce50c27ff9737c1008d2a03
diff --git a/tools/codegen/core/gen_nano_proto.sh b/tools/codegen/core/gen_nano_proto.sh
index b216a20379..c880fc23a2 100755
--- a/tools/codegen/core/gen_nano_proto.sh
+++ b/tools/codegen/core/gen_nano_proto.sh
@@ -136,6 +136,13 @@ readonly PROTO_BASENAME=$(basename $INPUT_PROTO .proto)
 sed -i "s:$PROTO_BASENAME.pb.h:${GRPC_OUTPUT_DIR}/$PROTO_BASENAME.pb.h:g" \
   "$OUTPUT_DIR/$PROTO_BASENAME.pb.c"
 
+# Fix up the include guards such that they pass the check_include_guards.py
+# test. Assumes that the generated files are being placed in gRPC src dir.
+readonly INCLUDE_GUARD_BASE=`echo $GRPC_OUTPUT_DIR | tr [a-z/] [A-Z_] | sed s:^.*SRC_::`
+readonly UC_PROTO_BASENAME=`echo $PROTO_BASENAME | tr [a-z] [A-Z]`
+sed -i "s:PB_${UC_PROTO_BASENAME}_PB_H_INCLUDED:GRPC_${INCLUDE_GUARD_BASE}_${UC_PROTO_BASENAME}_PB_H:g" \
+  "$OUTPUT_DIR/$PROTO_BASENAME.pb.h"
+
 # prepend copyright
 TMPFILE=$(mktemp)
 cat $COPYRIGHT_FILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.c" > $TMPFILE
-- 
GitLab