• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The BoringSSL Authors
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
15load(
16    ":gen/sources.bzl",
17    "bcm_internal_headers",
18    "bcm_sources",
19    "bcm_sources_asm",
20    "bssl_internal_headers",
21    "bssl_sources",
22    "crypto_headers",
23    "crypto_internal_headers",
24    "crypto_sources",
25    "crypto_sources_asm",
26    "crypto_test_data",
27    "crypto_test_sources",
28    "decrepit_internal_headers",
29    "decrepit_sources",
30    "decrepit_test_sources",
31    "pki_headers",
32    "pki_internal_headers",
33    "pki_sources",
34    "pki_test_data",
35    "pki_test_sources",
36    "ssl_headers",
37    "ssl_internal_headers",
38    "ssl_sources",
39    "ssl_test_sources",
40    "test_support_internal_headers",
41    "test_support_sources",
42    "test_support_sources_asm",
43    "urandom_test_sources",
44)
45load(":util/util.bzl", "bssl_cc_binary", "bssl_cc_library", "bssl_cc_test")
46load("@rules_license//rules:license.bzl", "license")
47
48package(
49    default_applicable_licenses = [":license"],
50    # Disable the parse_headers feature. It does not work well in C right now.
51    # See https://github.com/bazelbuild/bazel/issues/23460 for details. When
52    # that is fixed, if enabled, we likely also need to rename some headers to
53    # .inc per
54    # https://google.github.io/styleguide/cppguide.html#Self_contained_Headers
55    features = ["-parse_headers"],
56)
57
58license(
59    name = "license",
60    package_name = "BoringSSL",
61    # TODO(crbug.com/364634028): Update this once we've aligned with OpenSSL's
62    # new license.
63    license_kinds = [
64        "@rules_license//licenses/spdx:ISC",
65        "@rules_license//licenses/spdx:OpenSSL",
66        "@rules_license//licenses/spdx:MIT",
67        "@rules_license//licenses/spdx:SSLeay-standalone",
68    ],
69    license_text = "LICENSE",
70)
71
72exports_files(["LICENSE"])
73
74bssl_cc_library(
75    name = "crypto",
76    srcs = bcm_sources + crypto_sources,
77    hdrs = crypto_headers,
78    asm_srcs = bcm_sources_asm + crypto_sources_asm,
79    copts = ["-DBORINGSSL_IMPLEMENTATION"],
80    includes = ["include"],
81    internal_hdrs = bcm_internal_headers + crypto_internal_headers,
82    linkopts = select({
83        "@platforms//os:windows": [
84            "-defaultlib:advapi32.lib",
85            "-defaultlib:ws2_32.lib",
86        ],
87        "//conditions:default": ["-pthread"],
88    }),
89    visibility = ["//visibility:public"],
90)
91
92bssl_cc_library(
93    name = "ssl",
94    srcs = ssl_sources,
95    hdrs = ssl_headers,
96    copts = ["-DBORINGSSL_IMPLEMENTATION"],
97    internal_hdrs = ssl_internal_headers,
98    visibility = ["//visibility:public"],
99    deps = [":crypto_internal"],
100)
101
102bssl_cc_library(
103    name = "test_support",
104    testonly = True,
105    srcs = test_support_sources,
106    asm_srcs = test_support_sources_asm,
107    copts = ["-DBORINGSSL_USE_BAZEL_RUNFILES"],
108    internal_hdrs = test_support_internal_headers,
109    deps = [
110        ":crypto_internal",
111        "@bazel_tools//tools/cpp/runfiles",
112        "@googletest//:gtest",
113    ],
114)
115
116bssl_cc_test(
117    name = "crypto_test",
118    size = "large",
119    srcs = crypto_test_sources,
120    data = crypto_test_data,
121    # crypto_test references assembly symbols directly and thus must be linked
122    # statically.
123    linkstatic = True,
124    shard_count = 32,
125    deps = [
126        ":crypto_internal",
127        ":test_support",
128        "@googletest//:gtest",
129    ],
130)
131
132bssl_cc_test(
133    name = "urandom_test",
134    srcs = urandom_test_sources,
135    deps = [
136        ":crypto_internal",
137        ":test_support",
138        "@googletest//:gtest",
139    ],
140)
141
142bssl_cc_test(
143    name = "ssl_test",
144    srcs = ssl_test_sources,
145    deps = [
146        ":crypto_internal",
147        ":ssl_internal",
148        ":test_support",
149        "@googletest//:gtest",
150    ],
151)
152
153bssl_cc_binary(
154    name = "bssl",
155    srcs = bssl_sources + bssl_internal_headers,
156    visibility = ["//visibility:public"],
157    deps = [
158        ":crypto_internal",
159        ":ssl_internal",
160    ],
161)
162
163# Build, but do not export libdecrepit.
164bssl_cc_library(
165    name = "decrepit",
166    srcs = decrepit_sources,
167    copts = ["-DBORINGSSL_IMPLEMENTATION"],
168    internal_hdrs = decrepit_internal_headers,
169    deps = [
170        ":crypto_internal",
171        ":ssl_internal",
172    ],
173)
174
175bssl_cc_test(
176    name = "decrepit_test",
177    srcs = decrepit_test_sources,
178    deps = [
179        ":crypto_internal",
180        ":decrepit",
181        ":test_support",
182        "@googletest//:gtest",
183    ],
184)
185
186# Build, but do not (yet) export libpki.
187bssl_cc_library(
188    name = "pki",
189    srcs = pki_sources,
190    hdrs = pki_headers,
191    copts = ["-DBORINGSSL_IMPLEMENTATION"],
192    internal_hdrs = pki_internal_headers,
193    deps = [":crypto"],
194)
195
196bssl_cc_test(
197    name = "pki_test",
198    srcs = pki_test_sources,
199    data = pki_test_data,
200    deps = [
201        ":crypto_internal",
202        ":pki",
203        ":test_support",
204        "@googletest//:gtest",
205    ],
206)
207