| 1 |
# Copyright 2021 gRPC authors. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
load("@bazel_skylib//lib:selects.bzl", "selects") |
| 16 |
|
| 17 |
config_setting( |
| 18 |
name = "darwin", |
| 19 |
values = {"cpu": "darwin"}, |
| 20 |
) |
| 21 |
|
| 22 |
config_setting( |
| 23 |
name = "darwin_x86_64", |
| 24 |
values = {"cpu": "darwin_x86_64"}, |
| 25 |
) |
| 26 |
|
| 27 |
config_setting( |
| 28 |
name = "darwin_arm64", |
| 29 |
values = {"cpu": "darwin_arm64"}, |
| 30 |
) |
| 31 |
|
| 32 |
config_setting( |
| 33 |
name = "darwin_arm64e", |
| 34 |
values = {"cpu": "darwin_arm64e"}, |
| 35 |
) |
| 36 |
|
| 37 |
config_setting( |
| 38 |
name = "windows", |
| 39 |
values = {"cpu": "x64_windows"}, |
| 40 |
) |
| 41 |
|
| 42 |
config_setting( |
| 43 |
name = "freebsd", |
| 44 |
constraint_values = ["@platforms//os:freebsd"], |
| 45 |
) |
| 46 |
|
| 47 |
# Android is not officially supported through C++. |
| 48 |
# This just helps with the build for now. |
| 49 |
config_setting( |
| 50 |
name = "android", |
| 51 |
values = { |
| 52 |
"crosstool_top": "//external:android/crosstool", |
| 53 |
}, |
| 54 |
) |
| 55 |
|
| 56 |
# iOS is not officially supported through C++. |
| 57 |
# This just helps with the build for now. |
| 58 |
config_setting( |
| 59 |
name = "ios_x86_64", |
| 60 |
values = {"cpu": "ios_x86_64"}, |
| 61 |
) |
| 62 |
|
| 63 |
config_setting( |
| 64 |
name = "ios_armv7", |
| 65 |
values = {"cpu": "ios_armv7"}, |
| 66 |
) |
| 67 |
|
| 68 |
config_setting( |
| 69 |
name = "ios_armv7s", |
| 70 |
values = {"cpu": "ios_armv7s"}, |
| 71 |
) |
| 72 |
|
| 73 |
config_setting( |
| 74 |
name = "ios_arm64", |
| 75 |
values = {"cpu": "ios_arm64"}, |
| 76 |
) |
| 77 |
|
| 78 |
# The following architectures are found in |
| 79 |
# https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java |
| 80 |
config_setting( |
| 81 |
name = "tvos_x86_64", |
| 82 |
values = {"cpu": "tvos_x86_64"}, |
| 83 |
) |
| 84 |
|
| 85 |
config_setting( |
| 86 |
name = "tvos_arm64", |
| 87 |
values = {"cpu": "tvos_arm64"}, |
| 88 |
) |
| 89 |
|
| 90 |
config_setting( |
| 91 |
name = "watchos_i386", |
| 92 |
values = {"cpu": "watchos_i386"}, |
| 93 |
) |
| 94 |
|
| 95 |
config_setting( |
| 96 |
name = "watchos_x86_64", |
| 97 |
values = {"cpu": "watchos_x86_64"}, |
| 98 |
) |
| 99 |
|
| 100 |
config_setting( |
| 101 |
name = "watchos_armv7k", |
| 102 |
values = {"cpu": "watchos_armv7k"}, |
| 103 |
) |
| 104 |
|
| 105 |
config_setting( |
| 106 |
name = "watchos_arm64_32", |
| 107 |
values = {"cpu": "watchos_arm64_32"}, |
| 108 |
) |
| 109 |
|
| 110 |
selects.config_setting_group( |
| 111 |
name = "apple", |
| 112 |
match_any = [ |
| 113 |
":darwin", |
| 114 |
":darwin_x86_64", |
| 115 |
":darwin_arm64", |
| 116 |
":darwin_arm64e", |
| 117 |
"ios_x86_64", |
| 118 |
"ios_armv7", |
| 119 |
"ios_armv7s", |
| 120 |
"ios_arm64", |
| 121 |
"tvos_x86_64", |
| 122 |
"tvos_arm64", |
| 123 |
"watchos_i386", |
| 124 |
"watchos_x86_64", |
| 125 |
"watchos_armv7k", |
| 126 |
"watchos_arm64_32", |
| 127 |
], |
| 128 |
) |
| 129 |
|
| 130 |
COMMON_LIBUV_HEADERS = [ |
| 131 |
"include/uv.h", |
| 132 |
"include/uv/errno.h", |
| 133 |
"include/uv/threadpool.h", |
| 134 |
"include/uv/version.h", |
| 135 |
"include/uv/tree.h", |
| 136 |
] |
| 137 |
|
| 138 |
UNIX_LIBUV_HEADERS = [ |
| 139 |
"include/uv/unix.h", |
| 140 |
"src/unix/atomic-ops.h", |
| 141 |
"src/unix/internal.h", |
| 142 |
"src/unix/spinlock.h", |
| 143 |
] |
| 144 |
|
| 145 |
LINUX_LIBUV_HEADERS = [ |
| 146 |
"include/uv/linux.h", |
| 147 |
"src/unix/linux-syscalls.h", |
| 148 |
] |
| 149 |
|
| 150 |
ANDROID_LIBUV_HEADERS = [ |
| 151 |
"include/uv/android-ifaddrs.h", |
| 152 |
] |
| 153 |
|
| 154 |
DARWIN_LIBUV_HEADERS = [ |
| 155 |
"include/uv/darwin.h", |
| 156 |
] |
| 157 |
|
| 158 |
WINDOWS_LIBUV_HEADERS = [ |
| 159 |
"include/uv/win.h", |
| 160 |
"src/win/atomicops-inl.h", |
| 161 |
"src/win/handle-inl.h", |
| 162 |
"src/win/internal.h", |
| 163 |
"src/win/req-inl.h", |
| 164 |
"src/win/stream-inl.h", |
| 165 |
"src/win/winapi.h", |
| 166 |
"src/win/winsock.h", |
| 167 |
] |
| 168 |
|
| 169 |
COMMON_LIBUV_SOURCES = [ |
| 170 |
"src/fs-poll.c", |
| 171 |
"src/heap-inl.h", |
| 172 |
"src/idna.c", |
| 173 |
"src/idna.h", |
| 174 |
"src/inet.c", |
| 175 |
"src/queue.h", |
| 176 |
"src/strscpy.c", |
| 177 |
"src/strscpy.h", |
| 178 |
"src/threadpool.c", |
| 179 |
"src/timer.c", |
| 180 |
"src/uv-data-getter-setters.c", |
| 181 |
"src/uv-common.c", |
| 182 |
"src/uv-common.h", |
| 183 |
"src/version.c", |
| 184 |
] |
| 185 |
|
| 186 |
UNIX_LIBUV_SOURCES = [ |
| 187 |
"src/unix/async.c", |
| 188 |
"src/unix/atomic-ops.h", |
| 189 |
"src/unix/core.c", |
| 190 |
"src/unix/dl.c", |
| 191 |
"src/unix/fs.c", |
| 192 |
"src/unix/getaddrinfo.c", |
| 193 |
"src/unix/getnameinfo.c", |
| 194 |
"src/unix/internal.h", |
| 195 |
"src/unix/loop.c", |
| 196 |
"src/unix/loop-watcher.c", |
| 197 |
"src/unix/pipe.c", |
| 198 |
"src/unix/poll.c", |
| 199 |
"src/unix/process.c", |
| 200 |
"src/unix/signal.c", |
| 201 |
"src/unix/spinlock.h", |
| 202 |
"src/unix/stream.c", |
| 203 |
"src/unix/tcp.c", |
| 204 |
"src/unix/thread.c", |
| 205 |
"src/unix/tty.c", |
| 206 |
"src/unix/udp.c", |
| 207 |
] |
| 208 |
|
| 209 |
LINUX_LIBUV_SOURCES = [ |
| 210 |
"src/unix/linux-core.c", |
| 211 |
"src/unix/linux-inotify.c", |
| 212 |
"src/unix/linux-syscalls.c", |
| 213 |
"src/unix/linux-syscalls.h", |
| 214 |
"src/unix/procfs-exepath.c", |
| 215 |
"src/unix/proctitle.c", |
| 216 |
"src/unix/sysinfo-loadavg.c", |
| 217 |
"src/unix/sysinfo-memory.c", |
| 218 |
] |
| 219 |
|
| 220 |
ANDROID_LIBUV_SOURCES = [ |
| 221 |
"src/unix/android-ifaddrs.c", |
| 222 |
"src/unix/pthread-fixes.c", |
| 223 |
] |
| 224 |
|
| 225 |
DARWIN_LIBUV_SOURCES = [ |
| 226 |
"src/unix/bsd-ifaddrs.c", |
| 227 |
"src/unix/darwin.c", |
| 228 |
"src/unix/fsevents.c", |
| 229 |
"src/unix/kqueue.c", |
| 230 |
"src/unix/darwin-proctitle.c", |
| 231 |
"src/unix/proctitle.c", |
| 232 |
] |
| 233 |
|
| 234 |
WINDOWS_LIBUV_SOURCES = [ |
| 235 |
"src/win/async.c", |
| 236 |
"src/win/atomicops-inl.h", |
| 237 |
"src/win/core.c", |
| 238 |
"src/win/detect-wakeup.c", |
| 239 |
"src/win/dl.c", |
| 240 |
"src/win/error.c", |
| 241 |
"src/win/fs-event.c", |
| 242 |
"src/win/fs.c", |
| 243 |
"src/win/getaddrinfo.c", |
| 244 |
"src/win/getnameinfo.c", |
| 245 |
"src/win/handle.c", |
| 246 |
"src/win/handle-inl.h", |
| 247 |
"src/win/internal.h", |
| 248 |
"src/win/loop-watcher.c", |
| 249 |
"src/win/pipe.c", |
| 250 |
"src/win/poll.c", |
| 251 |
"src/win/process-stdio.c", |
| 252 |
"src/win/process.c", |
| 253 |
"src/win/req-inl.h", |
| 254 |
"src/win/signal.c", |
| 255 |
"src/win/stream.c", |
| 256 |
"src/win/stream-inl.h", |
| 257 |
"src/win/tcp.c", |
| 258 |
"src/win/thread.c", |
| 259 |
"src/win/tty.c", |
| 260 |
"src/win/udp.c", |
| 261 |
"src/win/util.c", |
| 262 |
"src/win/winapi.c", |
| 263 |
"src/win/winapi.h", |
| 264 |
"src/win/winsock.c", |
| 265 |
"src/win/winsock.h", |
| 266 |
] |
| 267 |
|
| 268 |
cc_library( |
| 269 |
name = "libuv", |
| 270 |
srcs = select({ |
| 271 |
":android": COMMON_LIBUV_SOURCES + UNIX_LIBUV_SOURCES + LINUX_LIBUV_SOURCES + ANDROID_LIBUV_SOURCES, |
| 272 |
":apple": COMMON_LIBUV_SOURCES + UNIX_LIBUV_SOURCES + DARWIN_LIBUV_SOURCES, |
| 273 |
":windows": COMMON_LIBUV_SOURCES + WINDOWS_LIBUV_SOURCES, |
| 274 |
"//conditions:default": COMMON_LIBUV_SOURCES + UNIX_LIBUV_SOURCES + LINUX_LIBUV_SOURCES, |
| 275 |
}), |
| 276 |
hdrs = select({ |
| 277 |
":android": COMMON_LIBUV_HEADERS + UNIX_LIBUV_HEADERS + LINUX_LIBUV_HEADERS + ANDROID_LIBUV_HEADERS, |
| 278 |
":apple": COMMON_LIBUV_HEADERS + UNIX_LIBUV_HEADERS + DARWIN_LIBUV_HEADERS, |
| 279 |
":windows": COMMON_LIBUV_HEADERS + WINDOWS_LIBUV_HEADERS, |
| 280 |
"//conditions:default": COMMON_LIBUV_HEADERS + UNIX_LIBUV_HEADERS + LINUX_LIBUV_HEADERS, |
| 281 |
}), |
| 282 |
copts = [ |
| 283 |
"-D_LARGEFILE_SOURCE", |
| 284 |
"-D_FILE_OFFSET_BITS=64", |
| 285 |
"-D_GNU_SOURCE", |
| 286 |
"-pthread", |
| 287 |
"--std=gnu89", |
| 288 |
"-pedantic", |
| 289 |
"-Wno-error", |
| 290 |
"-Wno-strict-aliasing", |
| 291 |
"-Wstrict-aliasing", |
| 292 |
"-O2", |
| 293 |
"-Wno-implicit-function-declaration", |
| 294 |
"-Wno-unused-function", |
| 295 |
"-Wno-unused-variable", |
| 296 |
] + select({ |
| 297 |
":apple": [], |
| 298 |
":windows": [ |
| 299 |
"-DWIN32_LEAN_AND_MEAN", |
| 300 |
"-D_WIN32_WINNT=0x0600", |
| 301 |
], |
| 302 |
"//conditions:default": [ |
| 303 |
"-Wno-tree-vrp", |
| 304 |
"-Wno-omit-frame-pointer", |
| 305 |
"-D_DARWIN_USE_64_BIT_INODE=1", |
| 306 |
"-D_DARWIN_UNLIMITED_SELECT=1", |
| 307 |
], |
| 308 |
}), |
| 309 |
includes = [ |
| 310 |
"include", |
| 311 |
"src", |
| 312 |
], |
| 313 |
linkopts = select({ |
| 314 |
":windows": [ |
| 315 |
"-Xcrosstool-compilation-mode=$(COMPILATION_MODE)", |
| 316 |
"-Wl,Iphlpapi.lib", |
| 317 |
"-Wl,Psapi.lib", |
| 318 |
"-Wl,User32.lib", |
| 319 |
"-Wl,Userenv.lib", |
| 320 |
], |
| 321 |
"//conditions:default": [], |
| 322 |
}), |
| 323 |
visibility = [ |
| 324 |
"//visibility:public", |
| 325 |
], |
| 326 |
) |
| 327 |
|
| 328 |
cc_library( |
| 329 |
name = "libuv_test", |
| 330 |
srcs = [ |
| 331 |
"test/test-timer.c", |
| 332 |
"test/test-timer-again.c", |
| 333 |
"test/test-timer-from-check.c", |
| 334 |
"test/test-getaddrinfo.c", |
| 335 |
"test/test-gethostname.c", |
| 336 |
"test/test-getnameinfo.c", |
| 337 |
"test/test-getsockname.c", |
| 338 |
], |
| 339 |
hdrs = [ |
| 340 |
"test/runner.h", |
| 341 |
"test/runner-unix.h", |
| 342 |
"test/task.h", |
| 343 |
], |
| 344 |
includes = [ |
| 345 |
"include", |
| 346 |
"src", |
| 347 |
], |
| 348 |
deps = [ |
| 349 |
":libuv" |
| 350 |
], |
| 351 |
copts = [ |
| 352 |
"-D_LARGEFILE_SOURCE", |
| 353 |
"-D_FILE_OFFSET_BITS=64", |
| 354 |
"-D_GNU_SOURCE", |
| 355 |
"-pthread", |
| 356 |
"--std=gnu89", |
| 357 |
"-pedantic", |
| 358 |
"-Wno-error", |
| 359 |
"-Wno-strict-aliasing", |
| 360 |
"-Wstrict-aliasing", |
| 361 |
"-O2", |
| 362 |
"-Wno-implicit-function-declaration", |
| 363 |
"-Wno-unused-function", |
| 364 |
"-Wno-unused-variable", |
| 365 |
] + select({ |
| 366 |
":apple": [], |
| 367 |
":windows": [ |
| 368 |
"-DWIN32_LEAN_AND_MEAN", |
| 369 |
"-D_WIN32_WINNT=0x0600", |
| 370 |
], |
| 371 |
"//conditions:default": [ |
| 372 |
"-Wno-tree-vrp", |
| 373 |
"-Wno-omit-frame-pointer", |
| 374 |
"-D_DARWIN_USE_64_BIT_INODE=1", |
| 375 |
"-D_DARWIN_UNLIMITED_SELECT=1", |
| 376 |
], |
| 377 |
}), |
| 378 |
linkopts = select({ |
| 379 |
":windows": [ |
| 380 |
"-Xcrosstool-compilation-mode=$(COMPILATION_MODE)", |
| 381 |
"-Wl,Iphlpapi.lib", |
| 382 |
"-Wl,Psapi.lib", |
| 383 |
"-Wl,User32.lib", |
| 384 |
"-Wl,Userenv.lib", |
| 385 |
], |
| 386 |
"//conditions:default": [], |
| 387 |
}), |
| 388 |
visibility = [ |
| 389 |
"//visibility:public", |
| 390 |
], |
| 391 |
) |