BoringSSL-GRPC.podspec.template 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. %YAML 1.2
  2. --- |
  3. <%!
  4. def expand_symbol_list(symbol_list):
  5. return ',\n '.join("'#define %s GRPC_SHADOW_%s'" % (symbol, symbol) for symbol in symbol_list)
  6. import subprocess
  7. boringssl_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd='third_party/boringssl-with-bazel').decode().strip()
  8. import gzip, shutil, os, base64
  9. # TODO(mxyan): move to python3 style gzip compression when possible
  10. with open('src/boringssl/boringssl_prefix_symbols.h', 'rb') as f_in, gzip.open('src/boringssl/boringssl_prefix_symbols.h.gz', 'wb') as f_out:
  11. shutil.copyfileobj(f_in, f_out)
  12. with open('src/boringssl/boringssl_prefix_symbols.h.gz', 'rb') as f_in:
  13. prefix_gz = f_in.read()
  14. os.remove('src/boringssl/boringssl_prefix_symbols.h.gz')
  15. prefix_gz_b64 = base64.b64encode(prefix_gz)
  16. %>
  17. # This file has been automatically generated from a template file.
  18. # Please make modifications to
  19. # `templates/src/objective-c/BoringSSL-GRPC.podspec.template` instead. This
  20. # file can be regenerated from the template by running
  21. # `tools/buildgen/generate_projects.sh`.
  22. # BoringSSL CocoaPods podspec
  23. # Copyright 2015, Google Inc.
  24. # All rights reserved.
  25. #
  26. # Redistribution and use in source and binary forms, with or without
  27. # modification, are permitted provided that the following conditions are
  28. # met:
  29. #
  30. # * Redistributions of source code must retain the above copyright
  31. # notice, this list of conditions and the following disclaimer.
  32. # * Redistributions in binary form must reproduce the above
  33. # copyright notice, this list of conditions and the following disclaimer
  34. # in the documentation and/or other materials provided with the
  35. # distribution.
  36. # * Neither the name of Google Inc. nor the names of its
  37. # contributors may be used to endorse or promote products derived from
  38. # this software without specific prior written permission.
  39. #
  40. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  41. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  42. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  43. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  44. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  45. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  46. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  47. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  48. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  49. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  50. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  51. Pod::Spec.new do |s|
  52. s.name = 'BoringSSL-GRPC'
  53. version = '0.0.8'
  54. s.version = version
  55. s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google\'s needs.'
  56. # Adapted from the homepage:
  57. s.description = <<-DESC
  58. BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.
  59. Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is.
  60. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating
  61. because there are no guarantees of API stability. Only the latest version of this pod is
  62. supported, and every new version is a new major version.
  63. We update Google libraries and programs that use BoringSSL as needed when deciding to make API
  64. changes. This allows us to mostly avoid compromises in the name of compatibility. It works for
  65. us, but it may not work for you.
  66. As a Cocoapods pod, it has the advantage over OpenSSL's pods that the library doesn't need to
  67. be precompiled. This eliminates the 10 - 20 minutes of wait the first time a user does "pod
  68. install", lets it be used as a dynamic framework (pending solution of Cocoapods' issue #4605),
  69. and works with bitcode automatically. It's also thought to be smaller than OpenSSL (which takes
  70. 1MB - 2MB per ARM architecture), but we don't have specific numbers yet.
  71. BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built
  72. up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's
  73. product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved
  74. in maintaining all these patches in multiple places was growing steadily.
  75. Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the
  76. NDK) and a number of other apps/programs.
  77. DESC
  78. s.homepage = 'https://github.com/google/boringssl'
  79. s.license = { :type => 'Mixed', :file => 'LICENSE' }
  80. # "The name and email addresses of the library maintainers, not the Podspec maintainer."
  81. s.authors = 'Adam Langley', 'David Benjamin', 'Matt Braithwaite'
  82. s.source = {
  83. :git => 'https://github.com/google/boringssl.git',
  84. :commit => "${boringssl_commit}",
  85. }
  86. s.ios.deployment_target = '7.0'
  87. s.osx.deployment_target = '10.7'
  88. s.tvos.deployment_target = '10.0'
  89. s.watchos.deployment_target = '4.0'
  90. name = 'openssl_grpc'
  91. # When creating a dynamic framework, name it openssl.framework instead of BoringSSL.framework.
  92. # This lets users write their includes like `#include <openssl/ssl.h>` as opposed to `#include
  93. # <BoringSSL/ssl.h>`.
  94. s.module_name = name
  95. # When creating a dynamic framework, copy the headers under `include/openssl/` into the root of
  96. # the `Headers/` directory of the framework (i.e., not under `Headers/include/openssl`).
  97. #
  98. # TODO(jcanizales): Debug why this doesn't work on macOS.
  99. s.header_mappings_dir = 'src/include/openssl'
  100. # The above has an undesired effect when creating a static library: It forces users to write
  101. # includes like `#include <BoringSSL/ssl.h>`. `s.header_dir` adds a path prefix to that, and
  102. # because Cocoapods lets omit the pod name when including headers of static libraries, the
  103. # following lets users write `#include <openssl/ssl.h>`.
  104. s.header_dir = name
  105. # The module map and umbrella header created automatically by Cocoapods don't work for C libraries
  106. # like this one. The following file, and a correct umbrella header, are created on the fly by the
  107. # `prepare_command` of this pod.
  108. s.module_map = 'src/include/openssl/BoringSSL.modulemap'
  109. # We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't
  110. # want that for some reason.
  111. s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DBORINGSSL_PREFIX=GRPC'
  112. s.requires_arc = false
  113. # Like many other C libraries, BoringSSL has its public headers under `include/<libname>/` and its
  114. # sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't
  115. # allow any header to be listed outside the `header_mappings_dir` (even though doing so works in
  116. # practice). Because we need our `header_mappings_dir` to be `include/openssl/` for the reason
  117. # mentioned above, we work around the linter limitation by dividing the pod into two subspecs, one
  118. # for public headers and the other for implementation. Each gets its own `header_mappings_dir`,
  119. # making the linter happy.
  120. s.subspec 'Interface' do |ss|
  121. ss.header_mappings_dir = 'src/include/openssl'
  122. ss.source_files = 'src/include/openssl/*.h'
  123. end
  124. s.subspec 'Implementation' do |ss|
  125. ss.header_mappings_dir = 'src'
  126. ss.source_files = 'src/ssl/*.{h,c,cc}',
  127. 'src/ssl/**/*.{h,c,cc}',
  128. 'src/crypto/*.{h,c,cc}',
  129. 'src/crypto/**/*.{h,c,cc}',
  130. # We have to include fiat because spake25519 depends on it
  131. 'src/third_party/fiat/*.{h,c,cc}',
  132. # Include the err_data.c pre-generated in boringssl's master-with-bazel branch
  133. 'err_data.c'
  134. ss.private_header_files = 'src/ssl/*.h',
  135. 'src/ssl/**/*.h',
  136. 'src/crypto/*.h',
  137. 'src/crypto/**/*.h',
  138. 'src/third_party/fiat/*.h'
  139. # bcm.c includes other source files, creating duplicated symbols. Since it is not used, we
  140. # explicitly exclude it from the pod.
  141. # TODO (mxyan): Work with BoringSSL team to remove this hack.
  142. ss.exclude_files = 'src/crypto/fipsmodule/bcm.c',
  143. 'src/**/*_test.*',
  144. 'src/**/test_*.*',
  145. 'src/**/test/*.*'
  146. ss.dependency "#{s.name}/Interface", version
  147. end
  148. s.prepare_command = <<-END_OF_COMMAND
  149. # Add a module map and an umbrella header
  150. cat > src/include/openssl/umbrella.h <<EOF
  151. #include "ssl.h"
  152. #include "crypto.h"
  153. #include "aes.h"
  154. /* The following macros are defined by base.h. The latter is the first file included by the
  155. other headers. */
  156. #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
  157. # include "arm_arch.h"
  158. #endif
  159. #include "asn1.h"
  160. #include "asn1_mac.h"
  161. #include "asn1t.h"
  162. #include "blowfish.h"
  163. #include "cast.h"
  164. #include "chacha.h"
  165. #include "cmac.h"
  166. #include "conf.h"
  167. #include "cpu.h"
  168. #include "curve25519.h"
  169. #include "des.h"
  170. #include "dtls1.h"
  171. #include "hkdf.h"
  172. #include "md4.h"
  173. #include "md5.h"
  174. #include "obj_mac.h"
  175. #include "objects.h"
  176. #include "opensslv.h"
  177. #include "ossl_typ.h"
  178. #include "pkcs12.h"
  179. #include "pkcs7.h"
  180. #include "pkcs8.h"
  181. #include "poly1305.h"
  182. #include "rand.h"
  183. #include "rc4.h"
  184. #include "ripemd.h"
  185. #include "safestack.h"
  186. #include "srtp.h"
  187. #include "x509.h"
  188. #include "x509v3.h"
  189. EOF
  190. cat > src/include/openssl/BoringSSL.modulemap <<EOF
  191. framework module openssl {
  192. umbrella header "umbrella.h"
  193. textual header "arm_arch.h"
  194. export *
  195. module * { export * }
  196. }
  197. EOF
  198. # To avoid symbol conflict with OpenSSL, gRPC needs to rename all the BoringSSL symbols with a
  199. # prefix. This is done with BoringSSL's BORINGSSL_PREFIX mechanism
  200. # (https://github.com/google/boringssl/blob/75148d7abf12bdd1797fec3c5da9a21963703516/BUILDING.md#building-with-prefixed-symbols).
  201. # The required prefix header file boringssl_prefix_symbols.h is not part of BoringSSL repo at
  202. # this moment. It has to be generated by BoringSSL's users and be injected to BoringSSL build.
  203. # gRPC generates this file in script /tools/distrib/upgrade_boringssl_objc.sh. This script
  204. # outputs a gzip+base64 encoded version of boringssl_prefix_symbols.h because of Cocoapods'
  205. # limit on the 'prepare_command' field length. The encoded header is generated from
  206. # /src/boringssl/boringssl_prefix_symbols.h. Here we decode the content and inject the header to
  207. # the correct location in BoringSSL.
  208. base64 -D <<EOF | gunzip > include/openssl/boringssl_prefix_symbols.h
  209. ${prefix_gz_b64}
  210. EOF
  211. # We are renaming openssl to openssl_grpc so that there is no conflict with openssl if it exists
  212. find . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g'
  213. # BoringSSL include boringssl_prefix_symbols.h without any prefix, which does not match the
  214. # Include of boringssl_prefix_symbols.h does not follow Xcode import style. We add the package
  215. # name here so that Xcode knows where to find it.
  216. find . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <boringssl_prefix_symbols.h>;#include <openssl_grpc/boringssl_prefix_symbols.h>;g'
  217. END_OF_COMMAND
  218. end