Replace making protoc and plugins with bazel build

Fixed templates and plugin-tests
pull/19855/head
Tony Lu 5 years ago
parent e00d7fc179
commit 422a7773ae
  1. 12
      src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec
  2. 12
      src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
  3. 17
      src/objective-c/!ProtoCompiler.podspec
  4. 6
      src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
  5. 34
      src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
  6. 12
      src/objective-c/tests/run_plugin_tests.sh
  7. 12
      templates/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec.template
  8. 12
      templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template
  9. 89
      test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec

@ -94,6 +94,7 @@ Pod::Spec.new do |s|
}
repo_root = '../..'
bazel = "#{repo_root}/tools/bazel"
plugin = 'grpc_cpp_plugin'
s.preserve_paths = plugin
@ -111,15 +112,6 @@ Pod::Spec.new do |s|
# present in this pod's directory. We use that knowledge to check for the existence of the file
# and, if absent, compile the plugin from the local sources.
s.prepare_command = <<-CMD
if [ ! -f #{plugin} ]; then
cd #{repo_root}
# This will build the plugin and put it in #{repo_root}/bins/opt.
#
# TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and
# library binary) if found, which _we do not want_. Find a way for this to always use the
# sources in the repo.
make #{plugin}
cd -
fi
#{bazel} build //src/compiler:grpc_cpp_plugin
CMD
end

@ -96,6 +96,7 @@ Pod::Spec.new do |s|
}
repo_root = '../..'
bazel = "#{repo_root}/tools/bazel"
plugin = 'grpc_objective_c_plugin'
s.preserve_paths = plugin
@ -115,15 +116,6 @@ Pod::Spec.new do |s|
# present in this pod's directory. We use that knowledge to check for the existence of the file
# and, if absent, compile the plugin from the local sources.
s.prepare_command = <<-CMD
if [ ! -f #{plugin} ]; then
cd #{repo_root}
# This will build the plugin and put it in #{repo_root}/bins/opt.
#
# TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and
# library binary) if found, which _we do not want_. Find a way for this to always use the
# sources in the repo.
make #{plugin}
cd -
fi
#{bazel} build //src/compiler:grpc_objective_c_plugin
CMD
end

@ -120,20 +120,9 @@ Pod::Spec.new do |s|
# present in this pod's directory. We use that knowledge to check for the existence of the file
# and, if absent, build it from the local sources.
repo_root = '../..'
plugin = 'grpc_objective_c_plugin'
bazel = "#{repo_root}/tools/bazel"
s.prepare_command = <<-CMD
if [ ! -f bin/protoc ]; then
cd #{repo_root}
# This will build protoc from the Protobuf submodule of gRPC, and put it in
# #{repo_root}/bins/opt/protobuf.
#
# TODO(jcanizales): Make won't build protoc from sources if one's locally installed, which
# _we do not want_. Find a way for this to always build from source.
make #{plugin}
cd -
else
mv bin/protoc .
mv include/google .
fi
#{bazel} build @com_google_protobuf//:protoc
CMD
end

@ -16,11 +16,11 @@ Pod::Spec.new do |s|
s.dependency "!ProtoCompiler-gRPCPlugin"
repo_root = '../../../..'
bin_dir = "#{repo_root}/bins/$CONFIG"
bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin"
protoc = "#{bin_dir}/protobuf/protoc"
protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc"
well_known_types_dir = "#{repo_root}/third_party/protobuf/src"
plugin = "#{bin_dir}/grpc_objective_c_plugin"
plugin = "#{bazel_exec_root}/src/compiler/grpc_objective_c_plugin"
# Since we switched to importing full path, -I needs to be set to the directory
# from which the imported file can be found, which is the grpc's root here

@ -16,34 +16,20 @@ Pod::Spec.new do |s|
s.dependency "!ProtoCompiler-gRPCPlugin"
repo_root = '../../../..'
config = ENV['CONFIG'] || 'opt'
bin_dir = "#{repo_root}/bins/#{config}"
bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin"
protoc = "#{bin_dir}/protobuf/protoc"
protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc"
well_known_types_dir = "#{repo_root}/third_party/protobuf/src"
plugin = "#{bin_dir}/grpc_objective_c_plugin"
plugin = "#{bazel_exec_root}/src/compiler/grpc_objective_c_plugin"
s.prepare_command = <<-CMD
if [ -f #{protoc} ]; then
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto
else
# protoc was not found bin_dir, use installed version instead
(>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC")
protoc \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto
fi
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/tests/RemoteTestClient/*.proto
CMD
s.subspec "Messages" do |ms|

@ -22,9 +22,15 @@ cd $(dirname $0)
# Run the tests server.
BINDIR=../../../bins/$CONFIG
PROTOC=$BINDIR/protobuf/protoc
PLUGIN=$BINDIR/grpc_objective_c_plugin
ROOT_DIR=../../..
BAZEL=$ROOT_DIR/tools/bazel
BAZEL_EXEC_ROOT=$ROOT_DIR/bazel-out/darwin-fastbuild/bin
PROTOC=$BAZEL_EXEC_ROOT/external/com_google_protobuf/protoc
PLUGIN=$BAZEL_EXEC_ROOT/src/compiler/grpc_objective_c_plugin
[ -f $PROTOC ] && [ -f $PLUGIN ] || {
BAZEL build @com_google_protobuf//:protoc //src/compiler:grpc_objective_c_plugin
}
rm -rf PluginTest/*pb*

@ -96,6 +96,7 @@
}
repo_root = '../..'
bazel = "#{repo_root}/tools/bazel"
plugin = 'grpc_cpp_plugin'
s.preserve_paths = plugin
@ -113,15 +114,6 @@
# present in this pod's directory. We use that knowledge to check for the existence of the file
# and, if absent, compile the plugin from the local sources.
s.prepare_command = <<-CMD
if [ ! -f #{plugin} ]; then
cd #{repo_root}
# This will build the plugin and put it in #{repo_root}/bins/opt.
#
# TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and
# library binary) if found, which _we do not want_. Find a way for this to always use the
# sources in the repo.
make #{plugin}
cd -
fi
#{bazel} build //src/compiler:grpc_cpp_plugin
CMD
end

@ -98,6 +98,7 @@
}
repo_root = '../..'
bazel = "#{repo_root}/tools/bazel"
plugin = 'grpc_objective_c_plugin'
s.preserve_paths = plugin
@ -117,15 +118,6 @@
# present in this pod's directory. We use that knowledge to check for the existence of the file
# and, if absent, compile the plugin from the local sources.
s.prepare_command = <<-CMD
if [ ! -f #{plugin} ]; then
cd #{repo_root}
# This will build the plugin and put it in #{repo_root}/bins/opt.
#
# TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and
# library binary) if found, which _we do not want_. Find a way for this to always use the
# sources in the repo.
make #{plugin}
cd -
fi
#{bazel} build //src/compiler:grpc_objective_c_plugin
CMD
end

@ -15,78 +15,39 @@ Pod::Spec.new do |s|
s.dependency "Protobuf-C++"
s.dependency "gRPC-C++"
s.source_files = "src/proto/grpc/testing/*.pb.{h,cc}"
s.header_mappings_dir = "RemoteTestCpp"
s.header_mappings_dir = "."
s.requires_arc = false
repo_root = '../../../..'
config = ENV['CONFIG'] || 'opt'
bin_dir = "#{repo_root}/bins/#{config}"
bazel_exec_root = "#{repo_root}/bazel-out/darwin-fastbuild/bin"
protoc = "#{bin_dir}/protobuf/protoc"
protoc = "#{bazel_exec_root}/external/com_google_protobuf/protoc"
well_known_types_dir = "#{repo_root}/third_party/protobuf/src"
plugin = "#{bin_dir}/grpc_cpp_plugin"
plugin = "#{bazel_exec_root}/src/compiler/grpc_cpp_plugin"
proto_dir = "#{repo_root}/src/proto/grpc/testing"
s.prepare_command = <<-CMD
if [ -f #{protoc} ]; then
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/echo.proto
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/echo_messages.proto
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/simple_messages.proto
else
# protoc was not found bin_dir, use installed version instead
if ! [ -x "$(command -v protoc)" ]; then
(>&2 echo "\nERROR: protoc not found")
exit 1
fi
(>&2 echo "\nWARNING: Using installed version of protoc. It might be incompatible with gRPC")
protoc \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/echo.proto
protoc \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/echo_messages.proto
protoc \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{proto_dir} \
-I #{well_known_types_dir} \
#{proto_dir}/simple_messages.proto
fi
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{proto_dir}/echo.proto
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{proto_dir}/echo_messages.proto
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--cpp_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{proto_dir}/simple_messages.proto
CMD
s.pod_target_xcconfig = {

Loading…
Cancel
Save