Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 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 | |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 15 | load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 16 | load( |
| 17 | ":BUILD.generated.bzl", |
| 18 | "crypto_headers", |
| 19 | "crypto_internal_headers", |
| 20 | "crypto_sources", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 21 | "crypto_sources_apple_aarch64", |
| 22 | "crypto_sources_apple_x86_64", |
| 23 | "crypto_sources_linux_aarch64", |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 24 | "crypto_sources_linux_ppc64le", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 25 | "crypto_sources_linux_x86_64", |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 26 | "fips_fragments", |
| 27 | "ssl_headers", |
| 28 | "ssl_internal_headers", |
| 29 | "ssl_sources", |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 30 | "tool_headers", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 31 | "tool_sources", |
| 32 | ) |
| 33 | |
| 34 | licenses(["notice"]) |
| 35 | |
| 36 | exports_files(["LICENSE"]) |
| 37 | |
| 38 | config_setting( |
| 39 | name = "linux_aarch64", |
| 40 | constraint_values = [ |
| 41 | "@platforms//os:linux", |
| 42 | "@platforms//cpu:aarch64", |
| 43 | ], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 44 | ) |
| 45 | |
| 46 | config_setting( |
| 47 | name = "linux_x86_64", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 48 | constraint_values = [ |
| 49 | "@platforms//os:linux", |
| 50 | "@platforms//cpu:x86_64", |
| 51 | ], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 52 | ) |
| 53 | |
| 54 | config_setting( |
| 55 | name = "linux_ppc64le", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 56 | constraint_values = [ |
| 57 | "@platforms//os:linux", |
| 58 | "@platforms//cpu:ppc", |
| 59 | ], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 60 | ) |
| 61 | |
| 62 | config_setting( |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 63 | name = "macos_aarch64", |
| 64 | constraint_values = [ |
| 65 | "@platforms//os:macos", |
| 66 | "@platforms//cpu:aarch64", |
| 67 | ], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 68 | ) |
| 69 | |
| 70 | config_setting( |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 71 | name = "macos_x86_64", |
| 72 | constraint_values = [ |
| 73 | "@platforms//os:macos", |
| 74 | "@platforms//cpu:x86_64", |
| 75 | ], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 76 | ) |
| 77 | |
| 78 | posix_copts = [ |
| 79 | # Assembler option --noexecstack adds .note.GNU-stack to each object to |
| 80 | # ensure that binaries can be built with non-executable stack. |
| 81 | "-Wa,--noexecstack", |
| 82 | |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 83 | # This list of warnings should match those in the top-level CMakeLists.txt. |
| 84 | "-Wall", |
| 85 | "-Werror", |
| 86 | "-Wformat=2", |
| 87 | "-Wsign-compare", |
| 88 | "-Wmissing-field-initializers", |
| 89 | "-Wwrite-strings", |
| 90 | "-Wshadow", |
| 91 | "-fno-common", |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 92 | ] |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 93 | |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 94 | linux_copts = posix_copts + [ |
| 95 | # This is needed on Linux systems (at least) to get rwlock in pthread, but |
| 96 | # it should not be set on Apple platforms, where it instead disables APIs |
| 97 | # we use. See compat(5) and sys/cdefs.h. |
| 98 | "-D_XOPEN_SOURCE=700", |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 99 | ] |
| 100 | |
| 101 | boringssl_copts = select({ |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 102 | "@platforms//os:linux": linux_copts, |
| 103 | "@platforms//os:macos": posix_copts, |
| 104 | "@platforms//os:windows": ["-DWIN32_LEAN_AND_MEAN"], |
| 105 | "//conditions:default": [], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 106 | }) |
| 107 | |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 108 | # These selects must be kept in sync. |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 109 | crypto_sources_asm = select({ |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 110 | ":linux_aarch64": crypto_sources_linux_aarch64, |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 111 | ":linux_ppc64le": crypto_sources_linux_ppc64le, |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 112 | ":linux_x86_64": crypto_sources_linux_x86_64, |
| 113 | ":macos_aarch64": crypto_sources_apple_aarch64, |
| 114 | ":macos_x86_64": crypto_sources_apple_x86_64, |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 115 | "//conditions:default": [], |
| 116 | }) |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 117 | boringssl_copts += select({ |
| 118 | ":linux_aarch64": [], |
| 119 | ":linux_ppc64le": [], |
| 120 | ":linux_x86_64": [], |
| 121 | ":macos_aarch64": [], |
| 122 | ":macos_x86_64": [], |
| 123 | "//conditions:default": ["-DOPENSSL_NO_ASM"], |
| 124 | }) |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 125 | |
| 126 | # For C targets only (not C++), compile with C11 support. |
| 127 | posix_copts_c11 = [ |
| 128 | "-std=c11", |
| 129 | "-Wmissing-prototypes", |
| 130 | "-Wold-style-definition", |
| 131 | "-Wstrict-prototypes", |
| 132 | ] |
| 133 | |
| 134 | boringssl_copts_c11 = boringssl_copts + select({ |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 135 | "@platforms//os:linux": posix_copts_c11, |
| 136 | "@platforms//os:macos": posix_copts_c11, |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 137 | "//conditions:default": [], |
| 138 | }) |
| 139 | |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 140 | # For C++ targets only (not C), compile with C++14 support. |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 141 | posix_copts_cxx = [ |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 142 | "-std=c++14", |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 143 | "-Wmissing-declarations", |
| 144 | ] |
| 145 | |
| 146 | boringssl_copts_cxx = boringssl_copts + select({ |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 147 | "@platforms//os:linux": posix_copts_cxx, |
| 148 | "@platforms//os:macos": posix_copts_cxx, |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 149 | "//conditions:default": [], |
| 150 | }) |
| 151 | |
| 152 | cc_library( |
| 153 | name = "crypto", |
| 154 | srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm, |
| 155 | hdrs = crypto_headers + fips_fragments, |
| 156 | copts = boringssl_copts_c11, |
| 157 | includes = ["src/include"], |
| 158 | linkopts = select({ |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 159 | # Android supports pthreads, but does not provide a libpthread |
| 160 | # to link against. |
Kaido Kert | b108943 | 2024-03-18 19:46:49 -0700 | [diff] [blame^] | 161 | "@platforms//os:android": [], |
| 162 | "@platforms//os:macos": [], |
| 163 | "@platforms//os:windows": ["-defaultlib:advapi32.lib"], |
Andrew Top | dee8b29 | 2019-01-22 14:48:26 -0800 | [diff] [blame] | 164 | "//conditions:default": ["-lpthread"], |
| 165 | }), |
| 166 | visibility = ["//visibility:public"], |
| 167 | ) |
| 168 | |
| 169 | cc_library( |
| 170 | name = "ssl", |
| 171 | srcs = ssl_sources + ssl_internal_headers, |
| 172 | hdrs = ssl_headers, |
| 173 | copts = boringssl_copts_cxx, |
| 174 | includes = ["src/include"], |
| 175 | visibility = ["//visibility:public"], |
| 176 | deps = [ |
| 177 | ":crypto", |
| 178 | ], |
| 179 | ) |
| 180 | |
| 181 | cc_binary( |
| 182 | name = "bssl", |
| 183 | srcs = tool_sources + tool_headers, |
| 184 | copts = boringssl_copts_cxx, |
| 185 | visibility = ["//visibility:public"], |
| 186 | deps = [":ssl"], |
| 187 | ) |