BUILD.toplevel 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. licenses(["notice"])
  15. exports_files(["LICENSE"])
  16. load(
  17. ":BUILD.generated.bzl",
  18. "crypto_headers",
  19. "crypto_internal_headers",
  20. "crypto_sources",
  21. "crypto_sources_linux_x86_64",
  22. "crypto_sources_linux_ppc64le",
  23. "crypto_sources_mac_x86_64",
  24. "fips_fragments",
  25. "ssl_headers",
  26. "ssl_internal_headers",
  27. "ssl_sources",
  28. "tool_sources",
  29. "tool_headers",
  30. )
  31. config_setting(
  32. name = "linux_x86_64",
  33. values = {"cpu": "k8"},
  34. )
  35. config_setting(
  36. name = "linux_ppc64le",
  37. values = {"cpu": "ppc"},
  38. )
  39. config_setting(
  40. name = "mac_x86_64",
  41. values = {"cpu": "darwin"},
  42. )
  43. config_setting(
  44. name = "windows_x86_64",
  45. values = {"cpu": "x64_windows"},
  46. )
  47. config_setting(
  48. name = "android",
  49. values = {"crosstool_top": "//external:android/crosstool"}
  50. )
  51. posix_copts = [
  52. # Assembler option --noexecstack adds .note.GNU-stack to each object to
  53. # ensure that binaries can be built with non-executable stack.
  54. "-Wa,--noexecstack",
  55. # This is needed on Linux systems (at least) to get rwlock in pthread.
  56. "-D_XOPEN_SOURCE=700",
  57. # This list of warnings should match those in the top-level CMakeLists.txt.
  58. "-Wall",
  59. "-Werror",
  60. "-Wformat=2",
  61. "-Wsign-compare",
  62. "-Wmissing-field-initializers",
  63. "-Wwrite-strings",
  64. "-Wshadow",
  65. "-fno-common",
  66. # Modern build environments should be able to set this to use atomic
  67. # operations for reference counting rather than locks. However, it's
  68. # known not to work on some Android builds.
  69. # "-DOPENSSL_C11_ATOMIC",
  70. ]
  71. boringssl_copts = select({
  72. ":linux_x86_64": posix_copts,
  73. ":linux_ppc64le": posix_copts,
  74. ":mac_x86_64": posix_copts,
  75. ":windows_x86_64": [
  76. "-DWIN32_LEAN_AND_MEAN",
  77. "-DOPENSSL_NO_ASM",
  78. ],
  79. "//conditions:default": ["-DOPENSSL_NO_ASM"],
  80. })
  81. crypto_sources_asm = select({
  82. ":linux_x86_64": crypto_sources_linux_x86_64,
  83. ":linux_ppc64le": crypto_sources_linux_ppc64le,
  84. ":mac_x86_64": crypto_sources_mac_x86_64,
  85. "//conditions:default": [],
  86. })
  87. # For C targets only (not C++), compile with C11 support.
  88. posix_copts_c11 = [
  89. "-std=c11",
  90. "-Wmissing-prototypes",
  91. "-Wold-style-definition",
  92. "-Wstrict-prototypes",
  93. ]
  94. boringssl_copts_c11 = boringssl_copts + select({
  95. ":linux_x86_64": posix_copts_c11,
  96. ":linux_ppc64le": posix_copts_c11,
  97. ":mac_x86_64": posix_copts_c11,
  98. "//conditions:default": [],
  99. })
  100. # For C++ targets only (not C), compile with C++11 support.
  101. posix_copts_cxx = [
  102. "-std=c++11",
  103. "-Wmissing-declarations",
  104. ]
  105. boringssl_copts_cxx = boringssl_copts + select({
  106. ":linux_x86_64": posix_copts_cxx,
  107. ":linux_ppc64le": posix_copts_cxx,
  108. ":mac_x86_64": posix_copts_cxx,
  109. "//conditions:default": [],
  110. })
  111. cc_library(
  112. name = "crypto",
  113. srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
  114. hdrs = crypto_headers + fips_fragments,
  115. copts = boringssl_copts_c11,
  116. includes = ["src/include"],
  117. linkopts = select({
  118. ":mac_x86_64": [],
  119. # Android supports pthreads, but does not provide a libpthread
  120. # to link against.
  121. ":android": [],
  122. ":windows_x86_64": ["-defaultlib:advapi32.lib"],
  123. "//conditions:default": ["-lpthread"],
  124. }),
  125. visibility = ["//visibility:public"],
  126. )
  127. cc_library(
  128. name = "ssl",
  129. srcs = ssl_sources + ssl_internal_headers,
  130. hdrs = ssl_headers,
  131. copts = boringssl_copts_cxx,
  132. includes = ["src/include"],
  133. visibility = ["//visibility:public"],
  134. deps = [
  135. ":crypto",
  136. ],
  137. )
  138. cc_binary(
  139. name = "bssl",
  140. srcs = tool_sources + tool_headers,
  141. copts = boringssl_copts_cxx,
  142. visibility = ["//visibility:public"],
  143. deps = [":ssl"],
  144. )