Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [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 | |
| 15 | licenses(["notice"]) |
| 16 | |
| 17 | exports_files(["LICENSE"]) |
| 18 | |
| 19 | load( |
| 20 | ":BUILD.generated.bzl", |
| 21 | "crypto_headers", |
| 22 | "crypto_internal_headers", |
| 23 | "crypto_sources", |
| 24 | "crypto_sources_linux_x86_64", |
| 25 | "crypto_sources_mac_x86_64", |
Garret Kelly | 0da939d | 2017-06-06 16:41:36 -0400 | [diff] [blame] | 26 | "fips_fragments", |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 27 | "ssl_headers", |
| 28 | "ssl_internal_headers", |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 29 | "ssl_sources", |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 30 | "tool_sources", |
| 31 | "tool_headers", |
| 32 | ) |
| 33 | |
| 34 | config_setting( |
| 35 | name = "linux_x86_64", |
| 36 | values = {"cpu": "k8"}, |
| 37 | ) |
| 38 | |
| 39 | config_setting( |
| 40 | name = "mac_x86_64", |
| 41 | values = {"cpu": "darwin"}, |
| 42 | ) |
| 43 | |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 44 | config_setting( |
| 45 | name = "windows_x86_64", |
| 46 | values = {"cpu": "x64_windows"}, |
| 47 | ) |
| 48 | |
| 49 | posix_copts = [ |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 50 | # Assembler option --noexecstack adds .note.GNU-stack to each object to |
| 51 | # ensure that binaries can be built with non-executable stack. |
| 52 | "-Wa,--noexecstack", |
| 53 | |
| 54 | # This is needed on Linux systems (at least) to get rwlock in pthread. |
| 55 | "-D_XOPEN_SOURCE=700", |
| 56 | |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 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 | |
| 67 | # Modern build environments should be able to set this to use atomic |
| 68 | # operations for reference counting rather than locks. However, it's |
| 69 | # known not to work on some Android builds. |
| 70 | # "-DOPENSSL_C11_ATOMIC", |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 71 | ] |
| 72 | |
| 73 | boringssl_copts = select({ |
| 74 | ":linux_x86_64": posix_copts, |
| 75 | ":mac_x86_64": posix_copts, |
| 76 | ":windows_x86_64": [ |
| 77 | "-DWIN32_LEAN_AND_MEAN", |
| 78 | "-DOPENSSL_NO_ASM", |
| 79 | ], |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 80 | "//conditions:default": ["-DOPENSSL_NO_ASM"], |
| 81 | }) |
| 82 | |
| 83 | crypto_sources_asm = select({ |
| 84 | ":linux_x86_64": crypto_sources_linux_x86_64, |
| 85 | ":mac_x86_64": crypto_sources_mac_x86_64, |
| 86 | "//conditions:default": [], |
| 87 | }) |
| 88 | |
| 89 | # For C targets only (not C++), compile with C11 support. |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 90 | posix_copts_c11 = [ |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 91 | "-std=c11", |
| 92 | "-Wmissing-prototypes", |
| 93 | "-Wold-style-definition", |
| 94 | "-Wstrict-prototypes", |
| 95 | ] |
| 96 | |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 97 | boringssl_copts_c11 = boringssl_copts + select({ |
| 98 | ":linux_x86_64": posix_copts_c11, |
| 99 | ":mac_x86_64": posix_copts_c11, |
| 100 | "//conditions:default": [], |
| 101 | }) |
| 102 | |
| 103 | # For C++ targets only (not C), compile with C++11 support. |
| 104 | posix_copts_cxx = [ |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 105 | "-std=c++11", |
| 106 | "-Wmissing-declarations", |
| 107 | ] |
| 108 | |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 109 | boringssl_copts_cxx = boringssl_copts + select({ |
| 110 | ":linux_x86_64": posix_copts_cxx, |
| 111 | ":mac_x86_64": posix_copts_cxx, |
| 112 | "//conditions:default": [], |
| 113 | }) |
| 114 | |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 115 | cc_library( |
| 116 | name = "crypto", |
| 117 | srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm, |
Garret Kelly | 0da939d | 2017-06-06 16:41:36 -0400 | [diff] [blame] | 118 | hdrs = crypto_headers + fips_fragments, |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 119 | copts = boringssl_copts_c11, |
| 120 | includes = ["src/include"], |
| 121 | linkopts = select({ |
| 122 | ":mac_x86_64": [], |
| 123 | "//conditions:default": ["-lpthread"], |
| 124 | }), |
| 125 | visibility = ["//visibility:public"], |
| 126 | ) |
| 127 | |
| 128 | cc_library( |
| 129 | name = "ssl", |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 130 | srcs = ssl_sources + ssl_internal_headers, |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 131 | hdrs = ssl_headers, |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 132 | copts = boringssl_copts_cxx, |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 133 | includes = ["src/include"], |
| 134 | visibility = ["//visibility:public"], |
Yun Peng | d363247 | 2017-07-28 13:17:13 +0200 | [diff] [blame] | 135 | deps = [ |
| 136 | ":crypto", |
| 137 | ], |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 138 | ) |
| 139 | |
| 140 | cc_binary( |
| 141 | name = "bssl", |
Matt Braithwaite | d17d74d | 2016-08-17 20:10:28 -0700 | [diff] [blame] | 142 | srcs = tool_sources + tool_headers, |
Adam Langley | 0186787 | 2016-06-30 14:16:59 -0700 | [diff] [blame] | 143 | copts = boringssl_copts_cxx, |
| 144 | visibility = ["//visibility:public"], |
| 145 | deps = [":ssl"], |
| 146 | ) |