David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [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", |
| 26 | "ssl_headers", |
| 27 | "ssl_internal_headers", |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 28 | "ssl_c_sources", |
| 29 | "ssl_cc_sources", |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [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 | |
| 44 | boringssl_copts = [ |
| 45 | # Assembler option --noexecstack adds .note.GNU-stack to each object to |
| 46 | # ensure that binaries can be built with non-executable stack. |
| 47 | "-Wa,--noexecstack", |
| 48 | |
| 49 | # This is needed on Linux systems (at least) to get rwlock in pthread. |
| 50 | "-D_XOPEN_SOURCE=700", |
| 51 | |
| 52 | # This list of warnings should match those in the top-level CMakeLists.txt. |
| 53 | "-Wall", |
| 54 | "-Werror", |
| 55 | "-Wformat=2", |
| 56 | "-Wsign-compare", |
| 57 | "-Wmissing-field-initializers", |
| 58 | "-Wwrite-strings", |
| 59 | "-Wshadow", |
| 60 | "-fno-common", |
| 61 | |
| 62 | # Modern build environments should be able to set this to use atomic |
| 63 | # operations for reference counting rather than locks. However, it's |
| 64 | # known not to work on some Android builds. |
| 65 | # "-DOPENSSL_C11_ATOMIC", |
| 66 | ] + select({ |
| 67 | ":linux_x86_64": [], |
| 68 | ":mac_x86_64": [], |
| 69 | "//conditions:default": ["-DOPENSSL_NO_ASM"], |
| 70 | }) |
| 71 | |
| 72 | crypto_sources_asm = select({ |
| 73 | ":linux_x86_64": crypto_sources_linux_x86_64, |
| 74 | ":mac_x86_64": crypto_sources_mac_x86_64, |
| 75 | "//conditions:default": [], |
| 76 | }) |
| 77 | |
| 78 | # For C targets only (not C++), compile with C11 support. |
| 79 | boringssl_copts_c11 = boringssl_copts + [ |
| 80 | "-std=c11", |
| 81 | "-Wmissing-prototypes", |
| 82 | "-Wold-style-definition", |
| 83 | "-Wstrict-prototypes", |
| 84 | ] |
| 85 | |
| 86 | # For C targets only (not C++), compile with C11 support. |
| 87 | boringssl_copts_cxx = boringssl_copts + [ |
| 88 | "-std=c++11", |
| 89 | "-Wmissing-declarations", |
| 90 | ] |
| 91 | |
| 92 | cc_library( |
| 93 | name = "crypto", |
| 94 | srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm, |
| 95 | hdrs = crypto_headers, |
| 96 | copts = boringssl_copts_c11, |
| 97 | includes = ["src/include"], |
| 98 | linkopts = select({ |
| 99 | ":mac_x86_64": [], |
| 100 | "//conditions:default": ["-lpthread"], |
| 101 | }), |
| 102 | visibility = ["//visibility:public"], |
| 103 | ) |
| 104 | |
| 105 | cc_library( |
| 106 | name = "ssl", |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 107 | srcs = ssl_c_sources + ssl_internal_headers, |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 108 | hdrs = ssl_headers, |
| 109 | copts = boringssl_copts_c11, |
| 110 | includes = ["src/include"], |
| 111 | visibility = ["//visibility:public"], |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 112 | deps = [":crypto", ":ssl_cc"], |
| 113 | ) |
| 114 | |
| 115 | cc_library( |
| 116 | name = "ssl_cc", |
| 117 | srcs = ssl_cc_sources + ssl_internal_headers, |
| 118 | hdrs = ssl_headers, |
| 119 | copts = boringssl_copts, |
| 120 | includes = ["src/include"], |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 121 | deps = [":crypto"], |
| 122 | ) |
| 123 | |
| 124 | cc_binary( |
| 125 | name = "bssl", |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 126 | srcs = tool_sources + tool_headers, |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 127 | copts = boringssl_copts_cxx, |
| 128 | visibility = ["//visibility:public"], |
| 129 | deps = [":ssl"], |
| 130 | ) |