Debian Codegraph @

bazel/bazel_BUILD

raw
1 # -*- mode: python; -*-
2
3 # nsync is a C library that exports synchronization primitives, such as reader
4 # writer locks with conditional critical sections, designed to be open sourced
5 # in portable C. See https://github.com/google/nsync
6 #
7 # See public/*.h for API. When compiled with C++11 rather than C, it's in the
8 # "nsync" name space.
9 #
10 # BUILD file usage:
11 # deps = "@nsync://nsync" for C version
12 # deps = "@nsync://nsync_cpp" for C++11 version.
13 # The latter uses no OS-specific system calls or architecture-specific atomic
14 # operations.
15
16 load(":bazel/pkg_path_name.bzl", "pkg_path_name")
17
18 package(default_visibility = ["//visibility:public"])
19
20 licenses(["notice"]) # Apache 2.0
21
22 exports_files([
23 "LICENSE",
24 "VERSION",
25 ])
26
27 # ---------------------------------------------
28 # Recent versions of bazel have @platforms config_settings for cpu type and
29 # operating system, replacing its slippery "cpu" value which conflated several
30 # platform-related concepts. However, bazel's @platforms still doesn't have
31 # standardized settings for the compiler type, so config_setting rules
32 # similar to those below can be found in many packages that use bazel.
33
34 config_setting(
35 name = "gcc",
36 flag_values = {"@bazel_tools//tools/cpp:compiler": "gcc"},
37 )
38
39 config_setting(
40 name = "clang",
41 flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
42 )
43
44 config_setting(
45 name = "msvc-cl",
46 flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
47 )
48
49 config_setting(
50 name = "mingw-gcc",
51 flag_values = {"@bazel_tools//tools/cpp:compiler": "mingw-gcc"},
52 )
53
54 config_setting(
55 name = "clang-cl",
56 flag_values = {"@bazel_tools//tools/cpp:compiler": "clang-cl"},
57 )
58
59 # ---------------------------------------------
60 # Compilation options.
61
62 # Compilation options that apply to both C++11 and C.
63 NSYNC_OPTS_GENERIC = select({
64 # Select the CPU architecture include directory.
65 # Some of bazel's CPU specifiers are unclear (e.g., what CPUs are "ppc" vs
66 # "ppc32"?) so the correspondences may not be quite right.
67 # This select() has no real effect in the C++11 build, but satisfies a
68 # #include that would otherwise need a #if.
69
70 # The following ought to work, but lead to errors on some versions of bazel:
71 # "@platforms//cpu:aarch32": ["-I" + pkg_path_name() + "/platform/arm"],
72 # "@platforms//cpu:armv6-m": ["-I" + pkg_path_name() + "/platform/arm"],
73 # "@platforms//cpu:armv7-m": ["-I" + pkg_path_name() + "/platform/arm"],
74 # "@platforms//cpu:armv7e-m": ["-I" + pkg_path_name() + "/platform/arm"],
75 # "@platforms//cpu:armv7e-mf": ["-I" + pkg_path_name() + "/platform/arm"],
76 # "@platforms//cpu:armv8-m": ["-I" + pkg_path_name() + "/platform/aarch64"],
77 # "@platforms//cpu:cortex-r52": ["-I" + pkg_path_name() + "/platform/aarch64"],
78 # "@platforms//cpu:cortex-r82": ["-I" + pkg_path_name() + "/platform/aarch64"],
79 # "@platforms//cpu:ppc32": ["-I" + pkg_path_name() + "/platform/ppc32"],
80 # "@platforms//cpu:ppc64le": ["-I" + pkg_path_name() + "/platform/ppc64"],
81 # "@platforms//cpu:riscv32": ["-I" + pkg_path_name() + "/platform/riscv"],
82 # nsync doesn't yet have a port for these:
83 # "@platforms//cpu:wasm32"
84 # "@platforms//cpu:wasm64"
85 "@platforms//cpu:aarch64": ["-I" + pkg_path_name() + "/platform/aarch64"],
86 "@platforms//cpu:arm64_32": ["-I" + pkg_path_name() + "/platform/aarch64"],
87 "@platforms//cpu:arm64e": ["-I" + pkg_path_name() + "/platform/aarch64"],
88 "@platforms//cpu:armv7": ["-I" + pkg_path_name() + "/platform/arm"],
89 "@platforms//cpu:armv7k": ["-I" + pkg_path_name() + "/platform/arm"],
90 "@platforms//cpu:i386": ["-I" + pkg_path_name() + "/platform/x86_32"],
91 "@platforms//cpu:mips64": ["-I" + pkg_path_name() + "/platform/mips"],
92 "@platforms//cpu:ppc": ["-I" + pkg_path_name() + "/platform/ppc32"],
93 "@platforms//cpu:riscv64": ["-I" + pkg_path_name() + "/platform/riscv"],
94 "@platforms//cpu:s390x": ["-I" + pkg_path_name() + "/platform/s390x"],
95 "@platforms//cpu:x86_32": ["-I" + pkg_path_name() + "/platform/x86_32"],
96 "@platforms//cpu:x86_64": ["-I" + pkg_path_name() + "/platform/x86_64"],
97 "//conditions:default": [],
98 }) + [
99 "-I" + pkg_path_name() + "/public",
100 "-I" + pkg_path_name() + "/internal",
101 "-I" + pkg_path_name() + "/platform/posix",
102 ] + select({
103 "@platforms//os:windows": [],
104 "@platforms//os:freebsd": ["-pthread"],
105 "//conditions:default": [
106 "-D_POSIX_C_SOURCE=200809L",
107 "-pthread",
108 ],
109 })
110
111 # Options for C build, rather then C++11 build.
112 NSYNC_OPTS = select({
113 # Select the OS include directory.
114
115 # The following ought to work, but lead to errors on some versions of bazel:
116 # "@platforms//os:chromiumos": ["-I" + pkg_path_name() + "/platform/linux"],
117 # "@platforms//os:netbsd": ["-I" + pkg_path_name() + "/platform/netbsd"],
118 # nsync doesn't yet have a port for these:
119 # "@platforms//os:emscripten"
120 # "@platforms//os:fuchsia"
121 # "@platforms//os:haiku"
122 # "@platforms//os:nixos"
123 # "@platforms//os:qnx"
124 # "@platforms//os:tvos"
125 # "@platforms//os:visionos"
126 # "@platforms//os:vxworks"
127 # "@platforms//os:wasi"
128 # "@platforms//os:watchos"
129 "@platforms//os:android": ["-I" + pkg_path_name() + "/platform/linux"],
130 "@platforms//os:freebsd": ["-I" + pkg_path_name() + "/platform/freebsd"],
131 "@platforms//os:ios": ["-I" + pkg_path_name() + "/platform/macos"],
132 "@platforms//os:linux": ["-I" + pkg_path_name() + "/platform/linux"],
133 "@platforms//os:macos": ["-I" + pkg_path_name() + "/platform/macos"],
134 "@platforms//os:openbsd": ["-I" + pkg_path_name() + "/platform/openbsd"],
135 "@platforms//os:windows": ["-I" + pkg_path_name() + "/platform/win32"],
136 "//conditions:default": [],
137 }) + select({
138 # Select the compiler include directory.
139 ":gcc": ["-I" + pkg_path_name() + "/platform/gcc"],
140 ":clang": ["-I" + pkg_path_name() + "/platform/clang"],
141 ":clang-cl": ["-I" + pkg_path_name() + "/platform/clang"],
142 ":msvc-cl": ["-I" + pkg_path_name() + "/platform/msvc"],
143 "//conditions:default": ["-I" + pkg_path_name() + "/platform/gcc"],
144 }) + select({
145 # Apple deprecated their atomics library, yet recent versions have no
146 # working version of stdatomic.h; so some recent versions need one, and
147 # other versions prefer the other. For the moment, just ignore the
148 # deprecation.
149 "@platforms//os:macos": ["-Wno-deprecated-declarations"],
150 "//conditions:default": [],
151 }) + NSYNC_OPTS_GENERIC
152
153 # Options for C++11 build, rather then C build.
154 NSYNC_OPTS_CPP = select({
155 ":msvc-cl": ["/TP"],
156 ":clang-cl": ["/TP"],
157 "//conditions:default": [
158 "-x",
159 "c++",
160 "-std=c++11",
161 ],
162 }) + select({
163 # Some versions of MacOS (notably Sierra) require -D_DARWIN_C_SOURCE
164 # to include some standard C++11 headers, like <mutex>.
165 "@platforms//os:macos": ["-D_DARWIN_C_SOURCE"],
166 "//conditions:default": [],
167 }) + select({
168 # On Linux, the C++11 library's synchronization primitives are
169 # surprisingly slow. See also NSYNC_SRC_PLATFORM_CPP, below.
170 "@platforms//os:linux": ["-I" + pkg_path_name() + "/platform/c++11.futex"],
171 "//conditions:default": [],
172 }) + [
173 "-DNSYNC_ATOMIC_CPP11",
174 "-DNSYNC_USE_CPP11_TIMEPOINT",
175 "-I" + pkg_path_name() + "/platform/c++11",
176 ] + select({
177 # This section must follow the -I...platform/c++11
178 # We assume here that msvc-cl, mingw-gcc, and clang-cl all imply windows.
179 # It might have been clearer to use a nested select(), but bazel disallows
180 # that.
181 "@platforms//os:ios": ["-I" + pkg_path_name() + "/platform/gcc_no_tls"],
182 ":msvc-cl": [
183 "-I" + pkg_path_name() + "/platform/win32",
184 "-I" + pkg_path_name() + "/platform/msvc",
185 ],
186 ":mingw-gcc": [
187 "-I" + pkg_path_name() + "/platform/win32",
188 "-I" + pkg_path_name() + "/platform/gcc",
189 ],
190 ":clang-cl": [
191 "-I" + pkg_path_name() + "/platform/win32",
192 "-I" + pkg_path_name() + "/platform/clang",
193 ],
194 ":clang": ["-I" + pkg_path_name() + "/platform/clang"],
195 ":gcc": ["-I" + pkg_path_name() + "/platform/gcc"],
196 # Hope that anything we do not recognize is gcc-compatible.
197 "//conditions:default": ["-I" + pkg_path_name() + "/platform/gcc"],
198 }) + NSYNC_OPTS_GENERIC
199
200 # Link options (for tests) built in C (rather than C++11).
201 NSYNC_LINK_OPTS = select({
202 ":msvc-cl": [],
203 ":clang-cl": [],
204 "//conditions:default": ["-pthread"],
205 })
206
207 # Link options (for tests) built in C++11 (rather than C).
208 NSYNC_LINK_OPTS_CPP = select({
209 ":msvc-cl": [],
210 ":clang-cl": [],
211 "//conditions:default": ["-pthread"],
212 })
213
214 # ---------------------------------------------
215 # Header files the source may include.
216
217 # Internal library headers.
218 NSYNC_INTERNAL_HEADERS = [
219 "internal/common.h",
220 "internal/dll.h",
221 "internal/headers.h",
222 "internal/sem.h",
223 "internal/wait_internal.h",
224 ]
225
226 # Internal test headers.
227 NSYNC_TEST_HEADERS = NSYNC_INTERNAL_HEADERS + [
228 "testing/array.h",
229 "testing/atm_log.h",
230 "testing/closure.h",
231 "testing/heap.h",
232 "testing/smprintf.h",
233 "testing/testing.h",
234 "testing/time_extra.h",
235 ]
236
237 # Platform specific headers.
238 # This declares headers for all platforms, not just the one
239 # we're building for, to avoid a more complex build file.
240 NSYNC_INTERNAL_HEADERS_PLATFORM = [
241 "platform/aarch64/cputype.h",
242 "platform/alpha/cputype.h",
243 "platform/arm/cputype.h",
244 "platform/atomic_ind/atomic.h",
245 "platform/c++11/atomic.h",
246 "platform/c++11/platform.h",
247 "platform/c++11.futex/platform.h",
248 "platform/c11/atomic.h",
249 "platform/clang/atomic.h",
250 "platform/clang/compiler.h",
251 "platform/cygwin/platform.h",
252 "platform/decc/compiler.h",
253 "platform/freebsd/platform.h",
254 "platform/gcc/atomic.h",
255 "platform/gcc/compiler.h",
256 "platform/gcc_new/atomic.h",
257 "platform/gcc_new_debug/atomic.h",
258 "platform/gcc_no_tls/compiler.h",
259 "platform/gcc_old/atomic.h",
260 "platform/lcc/compiler.h",
261 "platform/lcc/nsync_time_init.h",
262 "platform/linux/platform.h",
263 "platform/win32/atomic.h",
264 "platform/macos/platform_c++11_os.h",
265 "platform/msvc/compiler.h",
266 "platform/netbsd/atomic.h",
267 "platform/netbsd/platform.h",
268 "platform/openbsd/platform.h",
269 "platform/osf1/platform.h",
270 "platform/macos/atomic.h",
271 "platform/macos/platform.h",
272 "platform/pmax/cputype.h",
273 "platform/posix/cputype.h",
274 "platform/posix/nsync_time_init.h",
275 "platform/posix/platform_c++11_os.h",
276 "platform/ppc32/cputype.h",
277 "platform/ppc64/cputype.h",
278 "platform/s390x/cputype.h",
279 "platform/shark/cputype.h",
280 "platform/tcc/compiler.h",
281 "platform/win32/platform.h",
282 "platform/win32/platform_c++11_os.h",
283 "platform/x86_32/cputype.h",
284 "platform/x86_64/cputype.h",
285 ]
286
287 # ---------------------------------------------
288 # The nsync library.
289
290 # Linux-specific library source.
291 NSYNC_SRC_LINUX = [
292 "platform/linux/src/nsync_semaphore_futex.c",
293 "platform/posix/src/per_thread_waiter.c",
294 "platform/posix/src/yield.c",
295 "platform/posix/src/time_rep.c",
296 "platform/posix/src/nsync_panic.c",
297 ]
298
299 # Android-specific library source.
300 NSYNC_SRC_ANDROID = [
301 "platform/posix/src/nsync_semaphore_sem_t.c",
302 "platform/posix/src/per_thread_waiter.c",
303 "platform/posix/src/yield.c",
304 "platform/posix/src/time_rep.c",
305 "platform/posix/src/nsync_panic.c",
306 ]
307
308 # MacOS-specific library source.
309 NSYNC_SRC_MACOS = [
310 "platform/posix/src/clock_gettime.c",
311 "platform/posix/src/nsync_semaphore_mutex.c",
312 "platform/posix/src/per_thread_waiter.c",
313 "platform/posix/src/yield.c",
314 "platform/posix/src/time_rep.c",
315 "platform/posix/src/nsync_panic.c",
316 ]
317
318 # Windows-specific library source.
319 NSYNC_SRC_WINDOWS = [
320 "platform/posix/src/nsync_panic.c",
321 "platform/posix/src/per_thread_waiter.c",
322 "platform/posix/src/time_rep.c",
323 "platform/posix/src/yield.c",
324 "platform/win32/src/clock_gettime.c",
325 "platform/win32/src/init_callback_win32.c",
326 "platform/win32/src/nanosleep.c",
327 "platform/win32/src/nsync_semaphore_win32.c",
328 "platform/win32/src/pthread_cond_timedwait_win32.c",
329 "platform/win32/src/pthread_key_win32.cc",
330 ]
331
332 # FreeBSD-specific library source.
333 NSYNC_SRC_FREEBSD = [
334 "platform/posix/src/nsync_semaphore_sem_t.c",
335 "platform/posix/src/per_thread_waiter.c",
336 "platform/posix/src/yield.c",
337 "platform/posix/src/time_rep.c",
338 "platform/posix/src/nsync_panic.c",
339 ]
340
341 # NetBSD-specific library source.
342 NSYNC_SRC_NETBSD = [
343 "platform/posix/src/nsync_semaphore_sem_t.c",
344 "platform/posix/src/per_thread_waiter.c",
345 "platform/posix/src/yield.c",
346 "platform/posix/src/time_rep.c",
347 "platform/posix/src/nsync_panic.c",
348 ]
349
350 # OpenBSD-specific library source.
351 NSYNC_SRC_OPENBSD = [
352 "platform/posix/src/nsync_semaphore_sem_t.c",
353 "platform/posix/src/per_thread_waiter.c",
354 "platform/posix/src/yield.c",
355 "platform/posix/src/time_rep.c",
356 "platform/posix/src/nsync_panic.c",
357 ]
358
359 # OS-specific library source.
360 NSYNC_SRC_PLATFORM = select({
361
362 # The following ought to work, but lead to errors on some versions of bazel:
363 # "@platforms//os:netbsd": NSYNC_SRC_NETBSD,
364 # nsync doesn't yet have a port for these:
365 # "@platforms//os:chromiumos"
366 # "@platforms//os:emscripten"
367 # "@platforms//os:fuchsia"
368 # "@platforms//os:haiku"
369 # "@platforms//os:nixos"
370 # "@platforms//os:qnx"
371 # "@platforms//os:tvos"
372 # "@platforms//os:visionos"
373 # "@platforms//os:vxworks"
374 # "@platforms//os:wasi"
375 # "@platforms//os:watchos"
376 "@platforms//os:android": NSYNC_SRC_ANDROID,
377 "@platforms//os:freebsd": NSYNC_SRC_FREEBSD,
378 "@platforms//os:ios": NSYNC_SRC_MACOS,
379 "@platforms//os:linux": NSYNC_SRC_LINUX,
380 "@platforms//os:macos": NSYNC_SRC_MACOS,
381 "@platforms//os:openbsd": NSYNC_SRC_OPENBSD,
382 "@platforms//os:windows": NSYNC_SRC_WINDOWS,
383 })
384
385 # C++11-specific (OS and architecture independent) library source.
386 NSYNC_SRC_PLATFORM_CPP = [
387 "platform/c++11/src/time_rep_timespec.cc",
388 "platform/c++11/src/nsync_panic.cc",
389 "platform/c++11/src/yield.cc",
390 ] + select({
391 # On Linux, the C++11 library's synchronization primitives are surprisingly
392 # slow, at least at the time of writing (early 2018). Raw kernel
393 # primitives are ten times faster for wakeups.
394 "@platforms//os:linux": ["platform/linux/src/nsync_semaphore_futex.c"],
395 "//conditions:default": ["platform/c++11/src/nsync_semaphore_mutex.cc"],
396 }) + select({
397 # MacOS and Android don't have working C++11 thread local storage.
398 "@platforms//os:macos": ["platform/posix/src/per_thread_waiter.c"],
399 "@platforms//os:android": ["platform/posix/src/per_thread_waiter.c"],
400 "@platforms//os:ios": ["platform/posix/src/per_thread_waiter.c"],
401 "@platforms//os:windows": [
402 "platform/win32/src/clock_gettime.c",
403 # Windows has no thread-specific data with thread-exit destructors; we
404 # must emulate it with C++ per-thread class destructors.
405 "platform/win32/src/pthread_key_win32.cc",
406 "platform/win32/src/per_thread_waiter.c",
407 ],
408 # It's dangerous to use C++ class destructors if we can avoid it, because
409 # nsync may be linked into the address space multiple times.
410 "//conditions:default": ["platform/posix/src/per_thread_waiter.c"],
411 })
412
413 # Generic library source.
414 NSYNC_SRC_GENERIC = [
415 "internal/common.c",
416 "internal/counter.c",
417 "internal/cv.c",
418 "internal/debug.c",
419 "internal/dll.c",
420 "internal/mu.c",
421 "internal/mu_wait.c",
422 "internal/note.c",
423 "internal/once.c",
424 "internal/sem_wait.c",
425 "internal/time_internal.c",
426 "internal/wait.c",
427 ]
428
429 # Generic library header files.
430 NSYNC_HDR_GENERIC = [
431 "public/nsync.h",
432 "public/nsync_atomic.h",
433 "public/nsync_counter.h",
434 "public/nsync_cpp.h",
435 "public/nsync_cv.h",
436 "public/nsync_debug.h",
437 "public/nsync_mu.h",
438 "public/nsync_mu_wait.h",
439 "public/nsync_note.h",
440 "public/nsync_once.h",
441 "public/nsync_time.h",
442 "public/nsync_time_internal.h",
443 "public/nsync_waiter.h",
444 ]
445
446 # The library compiled in C, rather than C++11.
447 cc_library(
448 name = "nsync",
449 srcs = NSYNC_SRC_GENERIC + NSYNC_SRC_PLATFORM,
450 hdrs = NSYNC_HDR_GENERIC,
451 copts = NSYNC_OPTS,
452 includes = ["public"],
453 textual_hdrs = NSYNC_INTERNAL_HEADERS + NSYNC_INTERNAL_HEADERS_PLATFORM,
454 )
455
456 # The library compiled in C++11, rather than C.
457 cc_library(
458 name = "nsync_cpp",
459 srcs = NSYNC_SRC_GENERIC + NSYNC_SRC_PLATFORM_CPP,
460 hdrs = NSYNC_HDR_GENERIC,
461 copts = NSYNC_OPTS_CPP,
462 includes = ["public"],
463 textual_hdrs = NSYNC_INTERNAL_HEADERS + NSYNC_INTERNAL_HEADERS_PLATFORM,
464 )
465
466 # nsync_headers provides just the header files for use in projects that need to
467 # build shared libraries for dynamic loading. Bazel seems unable to cope
468 # otherwise.
469 cc_library(
470 name = "nsync_headers",
471 hdrs = glob(["public/*.h"]),
472 includes = ["public"],
473 )
474
475 # ---------------------------------------------
476 # Test code.
477
478 # Linux-specific test library source.
479 NSYNC_TEST_SRC_LINUX = [
480 "platform/posix/src/start_thread.c",
481 ]
482
483 # Android-specific test library source.
484 NSYNC_TEST_SRC_ANDROID = [
485 "platform/posix/src/start_thread.c",
486 ]
487
488 # MacOS-specific test library source.
489 NSYNC_TEST_SRC_MACOS = [
490 "platform/posix/src/start_thread.c",
491 ]
492
493 # Windows-specific test library source.
494 NSYNC_TEST_SRC_WINDOWS = [
495 "platform/win32/src/start_thread.c",
496 ]
497
498 # FreeBSD-specific test library source.
499 NSYNC_TEST_SRC_FREEBSD = [
500 "platform/posix/src/start_thread.c",
501 ]
502
503 # NetBSD-specific test library source.
504 NSYNC_TEST_SRC_NETBSD = [
505 "platform/posix/src/start_thread.c",
506 ]
507
508 # OpenBSD-specific test library source.
509 NSYNC_TEST_SRC_OPENBSD = [
510 "platform/posix/src/start_thread.c",
511 ]
512
513 # POSIX test library source.
514 NSYNC_TEST_SRC_POSIX = [
515 "platform/posix/src/start_thread.c",
516 ]
517
518 # OS-specific test library source.
519 NSYNC_TEST_SRC_PLATFORM = select({
520 # Select the OS include directory.
521
522 # The following ought to work, but lead to errors on some versions of bazel:
523 # "@platforms//os:netbsd": NSYNC_TEST_SRC_NETBSD,
524 # nsync doesn't yet have a port for these:
525 # "@platforms//os:chromiumos"
526 # "@platforms//os:emscripten"
527 # "@platforms//os:fuchsia"
528 # "@platforms//os:haiku"
529 # "@platforms//os:nixos"
530 # "@platforms//os:qnx"
531 # "@platforms//os:tvos"
532 # "@platforms//os:visionos"
533 # "@platforms//os:vxworks"
534 # "@platforms//os:wasi"
535 # "@platforms//os:watchos"
536 "@platforms//os:android": NSYNC_TEST_SRC_ANDROID,
537 "@platforms//os:freebsd": NSYNC_TEST_SRC_FREEBSD,
538 "@platforms//os:ios": NSYNC_TEST_SRC_MACOS,
539 "@platforms//os:linux": NSYNC_TEST_SRC_LINUX,
540 "@platforms//os:macos": NSYNC_TEST_SRC_MACOS,
541 "@platforms//os:openbsd": NSYNC_TEST_SRC_OPENBSD,
542 "@platforms//os:windows": NSYNC_TEST_SRC_WINDOWS,
543 "//conditions:default": NSYNC_TEST_SRC_POSIX,
544 })
545
546 # C++11-specific (OS and architecture independent) test library source.
547 NSYNC_TEST_SRC_PLATFORM_CPP = [
548 "platform/c++11/src/start_thread.cc",
549 ]
550
551 # Generic test library source.
552 NSYNC_TEST_SRC_GENERIC = [
553 "testing/array.c",
554 "testing/atm_log.c",
555 "testing/closure.c",
556 "testing/smprintf.c",
557 "testing/testing.c",
558 "testing/time_extra.c",
559 ]
560
561 # The test library compiled in C, rather than C++11.
562 cc_library(
563 name = "nsync_test_lib",
564 testonly = 1,
565 srcs = NSYNC_TEST_SRC_GENERIC + NSYNC_TEST_SRC_PLATFORM,
566 hdrs = ["testing/testing.h"],
567 copts = NSYNC_OPTS,
568 textual_hdrs = NSYNC_TEST_HEADERS + NSYNC_INTERNAL_HEADERS_PLATFORM,
569 deps = [":nsync"],
570 )
571
572 # The test library compiled in C++11, rather than C.
573 cc_library(
574 name = "nsync_test_lib_cpp",
575 testonly = 1,
576 srcs = NSYNC_TEST_SRC_GENERIC + NSYNC_TEST_SRC_PLATFORM_CPP,
577 hdrs = ["testing/testing.h"],
578 copts = NSYNC_OPTS_CPP,
579 textual_hdrs = NSYNC_TEST_HEADERS + NSYNC_INTERNAL_HEADERS_PLATFORM,
580 deps = [":nsync_cpp"],
581 )
582
583 # ---------------------------------------------
584 # The tests, compiled in C rather than C++11.
585
586 cc_test(
587 name = "counter_test",
588 size = "small",
589 srcs = ["testing/counter_test.c"],
590 copts = NSYNC_OPTS,
591 linkopts = NSYNC_LINK_OPTS,
592 deps = [
593 ":nsync",
594 ":nsync_test_lib",
595 ],
596 )
597
598 cc_test(
599 name = "cv_mu_timeout_stress_test",
600 size = "small",
601 srcs = ["testing/cv_mu_timeout_stress_test.c"],
602 copts = NSYNC_OPTS,
603 linkopts = NSYNC_LINK_OPTS,
604 deps = [
605 ":nsync",
606 ":nsync_test_lib",
607 ],
608 )
609
610 cc_test(
611 name = "cv_test",
612 size = "small",
613 srcs = ["testing/cv_test.c"],
614 copts = NSYNC_OPTS,
615 linkopts = NSYNC_LINK_OPTS,
616 deps = [
617 ":nsync",
618 ":nsync_test_lib",
619 ],
620 )
621
622 cc_test(
623 name = "cv_wait_example_test",
624 size = "small",
625 srcs = ["testing/cv_wait_example_test.c"],
626 copts = NSYNC_OPTS,
627 linkopts = NSYNC_LINK_OPTS,
628 deps = [
629 ":nsync",
630 ":nsync_test_lib",
631 ],
632 )
633
634 cc_test(
635 name = "dll_test",
636 size = "small",
637 srcs = ["testing/dll_test.c"],
638 copts = NSYNC_OPTS,
639 linkopts = NSYNC_LINK_OPTS,
640 deps = [
641 ":nsync",
642 ":nsync_test_lib",
643 ],
644 )
645
646 cc_test(
647 name = "mu_starvation_test",
648 size = "small",
649 srcs = ["testing/mu_starvation_test.c"],
650 copts = NSYNC_OPTS,
651 linkopts = NSYNC_LINK_OPTS,
652 deps = [
653 ":nsync",
654 ":nsync_test_lib",
655 ],
656 )
657
658 cc_test(
659 name = "mu_test",
660 size = "small",
661 srcs = ["testing/mu_test.c"],
662 copts = NSYNC_OPTS,
663 linkopts = NSYNC_LINK_OPTS,
664 deps = [
665 ":nsync",
666 ":nsync_test_lib",
667 ],
668 )
669
670 cc_test(
671 name = "mu_wait_example_test",
672 size = "small",
673 srcs = ["testing/mu_wait_example_test.c"],
674 copts = NSYNC_OPTS,
675 linkopts = NSYNC_LINK_OPTS,
676 deps = [
677 ":nsync",
678 ":nsync_test_lib",
679 ],
680 )
681
682 cc_test(
683 name = "mu_wait_test",
684 size = "small",
685 srcs = ["testing/mu_wait_test.c"],
686 copts = NSYNC_OPTS,
687 linkopts = NSYNC_LINK_OPTS,
688 deps = [
689 ":nsync",
690 ":nsync_test_lib",
691 ],
692 )
693
694 cc_test(
695 name = "note_test",
696 size = "small",
697 srcs = ["testing/note_test.c"],
698 copts = NSYNC_OPTS,
699 linkopts = NSYNC_LINK_OPTS,
700 deps = [
701 ":nsync",
702 ":nsync_test_lib",
703 ],
704 )
705
706 cc_test(
707 name = "once_test",
708 size = "small",
709 srcs = ["testing/once_test.c"],
710 copts = NSYNC_OPTS,
711 linkopts = NSYNC_LINK_OPTS,
712 deps = [
713 ":nsync",
714 ":nsync_test_lib",
715 ],
716 )
717
718 cc_test(
719 name = "pingpong_test",
720 size = "small",
721 srcs = ["testing/pingpong_test.c"],
722 copts = NSYNC_OPTS,
723 linkopts = NSYNC_LINK_OPTS,
724 deps = [
725 ":nsync",
726 ":nsync_test_lib",
727 ],
728 )
729
730 cc_test(
731 name = "wait_test",
732 size = "small",
733 srcs = ["testing/wait_test.c"],
734 copts = NSYNC_OPTS,
735 linkopts = NSYNC_LINK_OPTS,
736 deps = [
737 ":nsync",
738 ":nsync_test_lib",
739 ],
740 )
741
742 # ---------------------------------------------
743 # The tests, compiled in C++11, rather than C.
744
745 cc_test(
746 name = "counter_cpp_test",
747 size = "small",
748 srcs = ["testing/counter_test.c"],
749 copts = NSYNC_OPTS_CPP,
750 linkopts = NSYNC_LINK_OPTS_CPP,
751 deps = [
752 ":nsync_cpp",
753 ":nsync_test_lib_cpp",
754 ],
755 )
756
757 cc_test(
758 name = "cv_mu_timeout_stress_cpp_test",
759 size = "small",
760 srcs = ["testing/cv_mu_timeout_stress_test.c"],
761 copts = NSYNC_OPTS_CPP,
762 linkopts = NSYNC_LINK_OPTS_CPP,
763 deps = [
764 ":nsync_cpp",
765 ":nsync_test_lib_cpp",
766 ],
767 )
768
769 cc_test(
770 name = "cv_cpp_test",
771 size = "small",
772 srcs = ["testing/cv_test.c"],
773 copts = NSYNC_OPTS_CPP,
774 linkopts = NSYNC_LINK_OPTS_CPP,
775 deps = [
776 ":nsync_cpp",
777 ":nsync_test_lib_cpp",
778 ],
779 )
780
781 cc_test(
782 name = "cv_wait_example_cpp_test",
783 size = "small",
784 srcs = ["testing/cv_wait_example_test.c"],
785 copts = NSYNC_OPTS_CPP,
786 linkopts = NSYNC_LINK_OPTS_CPP,
787 deps = [
788 ":nsync_cpp",
789 ":nsync_test_lib_cpp",
790 ],
791 )
792
793 cc_test(
794 name = "dll_cpp_test",
795 size = "small",
796 srcs = ["testing/dll_test.c"],
797 copts = NSYNC_OPTS_CPP,
798 linkopts = NSYNC_LINK_OPTS_CPP,
799 deps = [
800 ":nsync_cpp",
801 ":nsync_test_lib_cpp",
802 ],
803 )
804
805 cc_test(
806 name = "mu_starvation_cpp_test",
807 size = "small",
808 srcs = ["testing/mu_starvation_test.c"],
809 copts = NSYNC_OPTS_CPP,
810 linkopts = NSYNC_LINK_OPTS_CPP,
811 deps = [
812 ":nsync_cpp",
813 ":nsync_test_lib_cpp",
814 ],
815 )
816
817 cc_test(
818 name = "mu_cpp_test",
819 size = "small",
820 srcs = ["testing/mu_test.c"],
821 copts = NSYNC_OPTS_CPP,
822 linkopts = NSYNC_LINK_OPTS_CPP,
823 deps = [
824 ":nsync_cpp",
825 ":nsync_test_lib_cpp",
826 ],
827 )
828
829 cc_test(
830 name = "mu_wait_example_cpp_test",
831 size = "small",
832 srcs = ["testing/mu_wait_example_test.c"],
833 copts = NSYNC_OPTS_CPP,
834 linkopts = NSYNC_LINK_OPTS_CPP,
835 deps = [
836 ":nsync_cpp",
837 ":nsync_test_lib_cpp",
838 ],
839 )
840
841 cc_test(
842 name = "mu_wait_cpp_test",
843 size = "small",
844 srcs = ["testing/mu_wait_test.c"],
845 copts = NSYNC_OPTS_CPP,
846 linkopts = NSYNC_LINK_OPTS_CPP,
847 deps = [
848 ":nsync_cpp",
849 ":nsync_test_lib_cpp",
850 ],
851 )
852
853 cc_test(
854 name = "note_cpp_test",
855 size = "small",
856 srcs = ["testing/note_test.c"],
857 copts = NSYNC_OPTS_CPP,
858 linkopts = NSYNC_LINK_OPTS_CPP,
859 deps = [
860 ":nsync_cpp",
861 ":nsync_test_lib_cpp",
862 ],
863 )
864
865 cc_test(
866 name = "once_cpp_test",
867 size = "small",
868 srcs = ["testing/once_test.c"],
869 copts = NSYNC_OPTS_CPP,
870 linkopts = NSYNC_LINK_OPTS_CPP,
871 deps = [
872 ":nsync_cpp",
873 ":nsync_test_lib_cpp",
874 ],
875 )
876
877 cc_test(
878 name = "pingpong_cpp_test",
879 size = "small",
880 srcs = ["testing/pingpong_test.c"],
881 copts = NSYNC_OPTS_CPP,
882 linkopts = NSYNC_LINK_OPTS_CPP,
883 deps = [
884 ":nsync_cpp",
885 ":nsync_test_lib_cpp",
886 ],
887 )
888
889 cc_test(
890 name = "wait_cpp_test",
891 size = "small",
892 srcs = ["testing/wait_test.c"],
893 copts = NSYNC_OPTS_CPP,
894 linkopts = NSYNC_LINK_OPTS_CPP,
895 deps = [
896 ":nsync_cpp",
897 ":nsync_test_lib_cpp",
898 ],
899 )