BUILD 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. # Copyright (c) 2016, Google Inc.
  2. #
  3. # Permission to use, copy, modify, and/or distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
  15. load(
  16. ":BUILD.generated.bzl",
  17. "crypto_headers",
  18. "crypto_internal_headers",
  19. "crypto_sources",
  20. "crypto_sources_linux_aarch64",
  21. "crypto_sources_linux_ppc64le",
  22. "crypto_sources_linux_x86_64",
  23. "crypto_sources_mac_x86_64",
  24. "fips_fragments",
  25. "ssl_headers",
  26. "ssl_internal_headers",
  27. "ssl_sources",
  28. "tool_headers",
  29. "tool_sources",
  30. )
  31. licenses(["notice"])
  32. exports_files(["LICENSE"])
  33. config_setting(
  34. name = "linux_aarch64",
  35. values = {"cpu": "aarch64"},
  36. )
  37. config_setting(
  38. name = "linux_x86_64",
  39. values = {"cpu": "k8"},
  40. )
  41. config_setting(
  42. name = "linux_ppc64le",
  43. values = {"cpu": "ppc"},
  44. )
  45. config_setting(
  46. name = "mac_x86_64",
  47. values = {"cpu": "darwin"},
  48. )
  49. config_setting(
  50. name = "windows_x86_64",
  51. values = {"cpu": "x64_windows"},
  52. )
  53. config_setting(
  54. name = "android_legacy",
  55. values = {"crosstool_top": "//external:android/crosstool"},
  56. )
  57. config_setting(
  58. name = "android_stlport",
  59. values = {"crosstool_top": "@androidndk//:toolchain-stlport"},
  60. )
  61. config_setting(
  62. name = "android_libcpp",
  63. values = {"crosstool_top": "@androidndk//:toolchain-libcpp"},
  64. )
  65. config_setting(
  66. name = "android_gnu_libstdcpp",
  67. values = {"crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp"},
  68. )
  69. config_setting(
  70. name = "android_default",
  71. values = {"crosstool_top": "@androidndk//:default_crosstool"},
  72. )
  73. posix_copts = [
  74. # Assembler option --noexecstack adds .note.GNU-stack to each object to
  75. # ensure that binaries can be built with non-executable stack.
  76. "-Wa,--noexecstack",
  77. # This is needed on Linux systems (at least) to get rwlock in pthread.
  78. "-D_XOPEN_SOURCE=700",
  79. # This list of warnings should match those in the top-level CMakeLists.txt.
  80. "-Wall",
  81. "-Werror",
  82. "-Wformat=2",
  83. "-Wsign-compare",
  84. "-Wmissing-field-initializers",
  85. "-Wwrite-strings",
  86. "-Wshadow",
  87. "-fno-common",
  88. # Modern build environments should be able to set this to use atomic
  89. # operations for reference counting rather than locks. However, it's
  90. # known not to work on some Android builds.
  91. # "-DOPENSSL_C11_ATOMIC",
  92. ]
  93. boringssl_copts = select({
  94. ":linux_aarch64": posix_copts,
  95. ":linux_ppc64le": posix_copts,
  96. ":linux_x86_64": posix_copts,
  97. ":mac_x86_64": posix_copts,
  98. ":windows_x86_64": [
  99. "-DWIN32_LEAN_AND_MEAN",
  100. "-DOPENSSL_NO_ASM",
  101. ],
  102. "//conditions:default": ["-DOPENSSL_NO_ASM"],
  103. })
  104. crypto_sources_asm = select({
  105. ":linux_aarch64": crypto_sources_linux_aarch64,
  106. ":linux_ppc64le": crypto_sources_linux_ppc64le,
  107. ":linux_x86_64": crypto_sources_linux_x86_64,
  108. ":mac_x86_64": crypto_sources_mac_x86_64,
  109. "//conditions:default": [],
  110. })
  111. # For C targets only (not C++), compile with C11 support.
  112. posix_copts_c11 = [
  113. "-std=c11",
  114. "-Wmissing-prototypes",
  115. "-Wold-style-definition",
  116. "-Wstrict-prototypes",
  117. ]
  118. boringssl_copts_c11 = boringssl_copts + select({
  119. ":linux_aarch64": posix_copts_c11,
  120. ":linux_ppc64le": posix_copts_c11,
  121. ":linux_x86_64": posix_copts_c11,
  122. ":mac_x86_64": posix_copts_c11,
  123. "//conditions:default": [],
  124. })
  125. # For C++ targets only (not C), compile with C++11 support.
  126. posix_copts_cxx = [
  127. "-std=c++11",
  128. "-Wmissing-declarations",
  129. ]
  130. boringssl_copts_cxx = boringssl_copts + select({
  131. ":linux_aarch64": posix_copts_cxx,
  132. ":linux_ppc64le": posix_copts_cxx,
  133. ":linux_x86_64": posix_copts_cxx,
  134. ":mac_x86_64": posix_copts_cxx,
  135. "//conditions:default": [],
  136. })
  137. cc_library(
  138. name = "crypto",
  139. srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
  140. hdrs = crypto_headers + fips_fragments,
  141. copts = boringssl_copts_c11,
  142. includes = ["src/include"],
  143. linkopts = select({
  144. # Android supports pthreads, but does not provide a libpthread
  145. # to link against.
  146. ":android_legacy": [],
  147. ":android_stlport": [],
  148. ":android_libcpp": [],
  149. ":android_gnu_libstdcpp": [],
  150. ":android_default": [],
  151. ":mac_x86_64": [],
  152. ":windows_x86_64": ["-defaultlib:advapi32.lib"],
  153. "//conditions:default": ["-lpthread"],
  154. }),
  155. visibility = ["//visibility:public"],
  156. )
  157. cc_library(
  158. name = "ssl",
  159. srcs = ssl_sources + ssl_internal_headers,
  160. hdrs = ssl_headers,
  161. copts = boringssl_copts_cxx,
  162. includes = ["src/include"],
  163. visibility = ["//visibility:public"],
  164. deps = [
  165. ":crypto",
  166. ],
  167. )
  168. cc_binary(
  169. name = "bssl",
  170. srcs = tool_sources + tool_headers,
  171. copts = boringssl_copts_cxx,
  172. visibility = ["//visibility:public"],
  173. deps = [":ssl"],
  174. )