-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUILD.bazel
112 lines (105 loc) · 3.32 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all",
srcs = glob(["**"]),
# Putting private visibility breaks the build whenever we use libcurl
# as a dependency somewhere else because this target stops being
# visible to other targets provided in here.
# By providing visibility to targets inside @com_github_curl_curl
# we can provide the needed visibility to targets in here but not to any
# other packages.
visibility = ["@com_github_curl_curl//:__pkg__"],
)
libcurl_boringssl_cache_entries_common = {
"BUILD_SHARED_LIBS": "OFF",
"BUILD_TESTING": "OFF",
"BUILD_CURL_EXE": "OFF",
"CURL_USE_OPENSSL": "ON",
# NOTE: Disable unused dependencies so we won't have any linker issues.
# At least on MacOS if libssh or libssh2 happens to be installed then
# cmake will attempt to link against the library but Bazel will expect
# all the symbols to be available and then the binary will crash
# when it attempts to dynamically find the symbols at runtime.
"CURL_USE_LIBSSH": "OFF",
"CURL_USE_LIBSSH2": "OFF",
"CURL_USE_BEARSSL": "OFF",
"CURL_USE_WOLFSSL": "OFF",
"CURL_USE_MBEDTLS": "OFF",
"CURL_USE_NSS": "OFF",
}
libcurl_defines = [
"CURL_STATICLIB",
]
cmake(
name = "libcurl_boringssl_windows",
cache_entries = libcurl_boringssl_cache_entries_common,
defines = libcurl_defines,
lib_source = "//:all",
linkopts = [
"WS2_32.Lib",
"Advapi32.lib",
"Iphlpapi.lib",
"Userenv.lib",
"User32.lib",
"Wldap32.lib",
"Crypt32.lib",
],
out_static_libs = select({
"//:debug_build": [
"libcurl-d.lib",
],
"//conditions:default": [
"libcurl.lib",
],
}),
# Just using "@boringssl//:crypto" and "@boringssl//:ssl" as our 'deps'
# as in linux and macos variant doesn't work because the 'cmake' rule seems to
# try and force boringssl to create BOTH static and shared libraries the
# latter of which does not work on Windows. Our workaround is to create
# our own "//:boringssl_lib" which only has the static libraries.
deps = [
"@boringssl_with_bazel_rules_curl_build_file//:boringssl_lib",
],
)
cmake(
name = "libcurl_boringssl_linux_macos",
cache_entries = dict(libcurl_boringssl_cache_entries_common.items() + {
# Disable linkage to an OpenLDAP library, since it's currently not
# being built by us.
"CURL_DISABLE_LDAP": "ON",
"CURL_DISABLE_LDAPS": "ON",
}.items()),
defines = libcurl_defines,
lib_source = "//:all",
linkopts = [
# NOTE: We are relying on user-installed libdl and zlib.
"-ldl",
"-lz",
],
out_static_libs = select({
"//:debug_build": [
"libcurl-d.a",
],
"//conditions:default": [
"libcurl.a",
],
}),
deps = [
"@boringssl//:crypto",
"@boringssl//:ssl",
],
)
alias(
name = "libcurl_boringssl",
actual = select({
"@bazel_tools//src/conditions:windows": "libcurl_boringssl_windows",
"//conditions:default": "libcurl_boringssl_linux_macos",
}),
visibility = ["//visibility:public"],
)
config_setting(
name = "debug_build",
values = {
"compilation_mode": "dbg",
},
)