Merge pull request #11341 from muxi/fix-objc-plugin-output

Fixes gRPC ObjC plugin's upper camel conversion
pull/11533/head
Muxi Yan 8 years ago committed by GitHub
commit 070a8eeb28
  1. 4
      src/compiler/objective_c_generator_helpers.h
  2. 3
      src/compiler/objective_c_plugin.cc
  3. 22
      src/objective-c/tests/PluginTest/imported-with-dash.proto
  4. 27
      src/objective-c/tests/PluginTest/test-dash-filename.proto
  5. 1
      src/objective-c/tests/build_tests.sh
  6. 32
      src/objective-c/tests/run_tests.sh

@ -23,6 +23,8 @@
#include "src/compiler/config.h"
#include "src/compiler/generator_helpers.h"
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
namespace grpc_objective_c_generator {
using ::grpc::protobuf::FileDescriptor;
@ -30,7 +32,7 @@ using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
inline string MessageHeaderName(const FileDescriptor *file) {
return grpc_generator::FileNameInUpperCamel(file) + ".pbobjc.h";
return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h";
}
inline string ServiceClassName(const ServiceDescriptor *service) {

@ -44,7 +44,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return true;
}
::grpc::string file_name = grpc_generator::FileNameInUpperCamel(file);
::grpc::string file_name =
google::protobuf::compiler::objectivec::FilePath(file);
::grpc::string prefix = file->options().objc_class_prefix();
{

@ -0,0 +1,22 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package grpc.testing;
option objc_class_prefix = "RMT";
message TestMessageImported {
int32 dummy = 1;
}

@ -0,0 +1,27 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package grpc.testing;
option objc_class_prefix = "RMT";
import "imported-with-dash.proto";
message TestMessage {
int32 dummy = 1;
}
service DummyService {
}

@ -37,3 +37,4 @@ rm -f RemoteTestClient/*.{h,m}
echo "TIME: $(date)"
pod install

@ -23,6 +23,38 @@ cd $(dirname $0)
# Run the tests server.
BINDIR=../../../bins/$CONFIG
PROTOC=$BINDIR/protobuf/protoc
PLUGIN=$BINDIR/grpc_objective_c_plugin
rm -rf PluginTest/*pb*
# Verify the output proto filename
eval $PROTOC \
--plugin=protoc-gen-grpc=$PLUGIN \
--objc_out=PluginTest \
--grpc_out=PluginTest \
-I PluginTest \
-I ../../../third_party/protobuf/src \
PluginTest/*.proto
[ -e ./PluginTest/TestDashFilename.pbrpc.h ] || {
echo >&2 "protoc outputs wrong filename."
exit 1
}
# Verify names of the imported protos in generated code
[ "`cat PluginTest/TestDashFilename.pbrpc.h |
egrep '#import ".*\.pb(objc|rpc)\.h"$' |
egrep '-'`" ] && {
echo >&2 "protoc generated import with wrong filename."
exit 1
}
[ "`cat PluginTest/TestDashFilename.pbrpc.m |
egrep '#import ".*\.pb(objc|rpc)\.m"$' |
egrep '-'`" ] && {
echo >&2 "protoc generated import with wrong filename."
exit 1
}
[ -f $BINDIR/interop_server ] || {
echo >&2 "Can't find the test server. Make sure run_tests.py is making" \

Loading…
Cancel
Save