aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2016-07-11 00:34:14 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2016-07-11 00:34:14 -0700
commit6eade6dcd7456b6608113408fd866f2d4f0f3150 (patch)
tree046f1a9dc698fa707fff80b142fe55f02a550149 /src
parent3e53e1a5be4ee1d0433a64b73553496fa3f93827 (diff)
Podspecs for Protoc and the gRPC plugin
The examples under <repo_root>/examples now rely on the released versions. Those under src/objective-c/examples, as well as the tests, rely on protoc and the plugin as compiled from head.
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/!ProtoCompiler-gRPCPlugin.podspec87
-rw-r--r--src/objective-c/!ProtoCompiler.podspec (renamed from src/objective-c/ProtoCompiler.podspec)39
-rw-r--r--src/objective-c/examples/RemoteTestClient/RemoteTest.podspec21
-rw-r--r--src/objective-c/examples/Sample/Podfile3
-rw-r--r--src/objective-c/examples/SwiftSample/Podfile3
-rw-r--r--src/objective-c/tests/Podfile5
-rw-r--r--src/objective-c/tests/RemoteTestClient/RemoteTest.podspec21
7 files changed, 163 insertions, 16 deletions
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
new file mode 100644
index 0000000000..b2671ec99a
--- /dev/null
+++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
@@ -0,0 +1,87 @@
+# CocoaPods podspec for the gRPC Proto Compiler Plugin
+
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Pod::Spec.new do |s|
+ # This pod is only a utility that will be used by other pods _at install time_ (not at compile
+ # time). Other pods can access it in their `prepare_command` script, under <pods_root>/<pod name>.
+ # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an
+ # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
+ # before them.
+ s.name = '!ProtoCompiler-gRPCPlugin'
+ v = '0.14.0'
+ s.version = v
+ s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
+ s.description = <<-DESC
+ This podspec only downloads the gRPC protoc plugin so that local pods generating protos can use
+ it in their invocation of protoc, as part of their prepare_command.
+ The generated code will have a dependency on the gRPC Objective-C Proto runtime of the same
+ version. The runtime can be obtained as the "gRPC-ProtoRPC" pod.
+ DESC
+ s.homepage = 'http://www.grpc.io'
+ s.license = 'New BSD'
+ s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
+
+ repo = 'grpc/grpc'
+ release = 'release-0_14_1'
+ file = "grpc_objective_c_plugin-#{v}-macos-x86_64.zip"
+ s.source = {
+ :http => "https://github.com/#{repo}/releases/download/#{release}/#{file}",
+ # TODO(jcanizales): Add sha1 or sha256
+ # :sha1 => '??',
+ }
+
+ repo_root = '../..'
+ plugin = 'grpc_objective_c_plugin'
+
+ s.preserve_paths = plugin
+
+ # Restrict the protoc version to the one supported by this plugin.
+ s.dependency '!ProtoCompiler', '3.0.0-beta-3.1'
+ # Restrict the gRPC runtime version to the one supported by this plugin.
+ s.dependency 'gRPC-ProtoRPC', v
+
+ # This is only for local development of the plugin: If the Podfile brings this pod from a local
+ # directory using `:path`, CocoaPods won't download the zip file and so the plugin won't be
+ # 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
+ CMD
+end
diff --git a/src/objective-c/ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec
index 2f13853b0b..f78d3c08b0 100644
--- a/src/objective-c/ProtoCompiler.podspec
+++ b/src/objective-c/!ProtoCompiler.podspec
@@ -1,6 +1,6 @@
-# BoringSSL CocoaPods podspec
+# Proto Compiler CocoaPods podspec
-# Copyright 2015, Google Inc.
+# Copyright 2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pod::Spec.new do |s|
- s.name = 'ProtoCompiler'
+ # This pod is only a utility that will be used by other pods _at install time_ (not at compile
+ # time). Other pods can access it in their `prepare_command` script, under <pods_root>/<pod name>.
+ # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an
+ # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
+ # before them.
+ s.name = '!ProtoCompiler'
v = '3.0.0-beta-3.1'
s.version = v
s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files'
@@ -45,12 +50,38 @@ Pod::Spec.new do |s|
# "The name and email addresses of the library maintainers, not the Podspec maintainer."
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
+ repo = 'google/protobuf'
+ release = "v#{v}"
+ file = "protoc-#{v}-osx-x86_64.zip"
s.source = {
- :http => "https://github.com/google/protobuf/releases/download/v#{v}/protoc-#{v}-osx-fat.zip",
+ :http => "https://github.com/#{repo}/releases/download/#{release}/#{file}",
# TODO(jcanizales): Add sha1 or sha256
# :sha1 => '??',
}
s.preserve_paths = 'protoc',
'google/**/*.proto' # Well-known protobuf types
+
+ # Restrict the protobuf runtime version to the one supported by this version of protoc.
+ s.dependency 'Protobuf', v
+
+ # This is only for local development of protoc: If the Podfile brings this pod from a local
+ # directory using `:path`, CocoaPods won't download the zip file and so the compiler won't be
+ # 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'
+ s.prepare_command = <<-CMD
+ if [ ! -f 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 -
+ fi
+ CMD
+
end
diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
index e3b50ddea5..6e783fb5ad 100644
--- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
+++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
@@ -11,15 +11,30 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.9'
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
+ s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14"
+
+ repo_root = '../../../..'
+ bin_dir = "#{repo_root}/bins/$CONFIG"
+
+ protoc = "#{bin_dir}/protobuf/protoc"
+ well_known_types_dir = "#{repo_root}/third_party/protobuf/src"
+ plugin = "#{bin_dir}/grpc_objective_c_plugin"
+
s.prepare_command = <<-CMD
- protoc --objc_out=. --objcgrpc_out=. *.proto
+ #{protoc} \
+ --plugin=protoc-gen-grpc=#{plugin} \
+ --objc_out=. \
+ --grpc_out=. \
+ -I . \
+ -I #{well_known_types_dir} \
+ *.proto
CMD
s.subspec 'Messages' do |ms|
ms.source_files = '*.pbobjc.{h,m}'
ms.header_mappings_dir = '.'
ms.requires_arc = false
- ms.dependency 'Protobuf', '~> 3.0.0-beta-3.1'
+ ms.dependency 'Protobuf'
# This is needed by all pods that depend on Protobuf:
ms.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
@@ -30,7 +45,7 @@ Pod::Spec.new do |s|
ss.source_files = '*.pbrpc.{h,m}'
ss.header_mappings_dir = '.'
ss.requires_arc = true
- ss.dependency 'gRPC-ProtoRPC', '~> 0.14'
+ ss.dependency 'gRPC-ProtoRPC'
ss.dependency "#{s.name}/Messages"
end
end
diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile
index 80ab2c320d..8740b2f963 100644
--- a/src/objective-c/examples/Sample/Podfile
+++ b/src/objective-c/examples/Sample/Podfile
@@ -12,6 +12,9 @@ target 'Sample' do
# Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following
# lines in your application.
+ pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
+ pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
+
pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf"
pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile
index b675fd29ef..2f783340f5 100644
--- a/src/objective-c/examples/SwiftSample/Podfile
+++ b/src/objective-c/examples/SwiftSample/Podfile
@@ -12,6 +12,9 @@ target 'SwiftSample' do
# Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following
# lines in your application.
+ pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
+ pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
+
pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf"
pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 168114da37..8bc23a5169 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -17,7 +17,8 @@ GRPC_LOCAL_SRC = '../../..'
).each do |target_name|
target target_name do
pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true
- pod 'ProtoCompiler', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
+ pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
+ pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
pod 'gRPC', :path => GRPC_LOCAL_SRC
@@ -66,7 +67,7 @@ post_install do |installer|
end
if target.name == 'gRPC-Core'
target.build_configurations.each do |config|
- # TODO(zyc) Remove this setting after the issue is resolved
+ # TODO(zyc): Remove this setting after the issue is resolved
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
index e705310370..7d84a5ae4d 100644
--- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
+++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
@@ -11,23 +11,30 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.9'
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
+ s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14"
+
repo_root = '../../../..'
- pods_root = "#{repo_root}/src/objective-c/tests/Pods"
bin_dir = "#{repo_root}/bins/$CONFIG"
- protoc = "#{pods_root}/ProtoCompiler/protoc" # "#{bin_dir}/protobuf/protoc"
+ protoc = "#{bin_dir}/protobuf/protoc"
+ well_known_types_dir = "#{repo_root}/third_party/protobuf/src"
plugin = "#{bin_dir}/grpc_objective_c_plugin"
+
s.prepare_command = <<-CMD
- #{protoc} --plugin=protoc-gen-grpc=#{plugin} --objc_out=. --grpc_out=. *.proto
+ #{protoc} \
+ --plugin=protoc-gen-grpc=#{plugin} \
+ --objc_out=. \
+ --grpc_out=. \
+ -I . \
+ -I #{well_known_types_dir} \
+ *.proto
CMD
- s.dependency "ProtoCompiler", "~> 3.0.0-beta-3.1"
-
s.subspec "Messages" do |ms|
ms.source_files = "*.pbobjc.{h,m}"
ms.header_mappings_dir = "."
ms.requires_arc = false
- ms.dependency "Protobuf", "~> 3.0.0-beta-3.1"
+ ms.dependency "Protobuf"
# This is needed by all pods that depend on Protobuf:
ms.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
@@ -38,7 +45,7 @@ Pod::Spec.new do |s|
ss.source_files = "*.pbrpc.{h,m}"
ss.header_mappings_dir = "."
ss.requires_arc = true
- ss.dependency "gRPC-ProtoRPC", "~> 0.14"
+ ss.dependency "gRPC-ProtoRPC"
ss.dependency "#{s.name}/Messages"
end
end