@@ -2,42 +2,151 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
2
2
3
3
package (default_visibility = ["//visibility:public" ])
4
4
5
+ _COMMON_DEPS = [
6
+ "@boost.bind" ,
7
+ "@boost.config" ,
8
+ "@boost.core" ,
9
+ "@boost.date_time" ,
10
+ "@boost.move" ,
11
+ "@boost.system" ,
12
+ "@boost.type_traits" ,
13
+ "@boost.chrono" ,
14
+ ]
15
+
16
+ _COMMON_HDRS = [
17
+ "include/boost/thread/detail/*.hpp" ,
18
+ "include/boost/thread/*.hpp" ,
19
+ "include/boost/thread/futures/*.hpp" ,
20
+ "include/boost/thread/csbl/*.hpp" ,
21
+ "include/boost/thread/executors/*.hpp" ,
22
+ ]
23
+
24
+ _WINDOWS_HDRS = [
25
+ "include/boost/thread/win32/*.hpp" ,
26
+ ]
27
+
28
+ _POSIX_HDRS = [
29
+ "include/boost/thread/pthread/*.hpp" ,
30
+ ]
31
+
32
+ _MAC_HDRS = [
33
+ "include/boost/thread/pthread/*.hpp" ,
34
+ ]
35
+
36
+ _WINDOWS_SRCS = [
37
+ "src/win32/*.cpp" ,
38
+ ]
39
+
40
+ _MAC_SRCS = [
41
+ "src/pthread/once.cpp" ,
42
+ "src/pthread/thread.cpp" ,
43
+ ]
44
+
45
+ _POSIX_SRCS = [
46
+ "src/pthread/thread.cpp" ,
47
+ "src/pthread/once.cpp" ,
48
+ ]
49
+
50
+ _COMMON_SRCS = [
51
+ "src/future.cpp" ,
52
+ ]
53
+
54
+ _COMMON_EXCLUDE_SRCS = ["src/pthread/once_atomic.cpp" ]
55
+
56
+ cc_library (
57
+ name = "thread_posix" ,
58
+ target_compatible_with = select ({
59
+ "@platforms//os:windows" : ["@platforms//:incompatible" ],
60
+ "@platforms//os:macos" : ["@platforms//:incompatible" ],
61
+ "//conditions:default" : [],
62
+ }),
63
+ hdrs = glob (_POSIX_HDRS + _COMMON_HDRS ),
64
+ srcs = glob (_POSIX_SRCS + _COMMON_SRCS , exclude = _COMMON_EXCLUDE_SRCS ),
65
+ includes = ["include" ],
66
+ deps = _COMMON_DEPS ,
67
+ defines = [
68
+ "BOOST_THREAD_DONT_USE_ATOMIC" ,
69
+ ],
70
+ )
71
+
72
+ cc_library (
73
+ name = "thread_windows" ,
74
+ target_compatible_with = select ({
75
+ "@platforms//os:windows" : [],
76
+ "@platforms//os:macos" : ["@platforms//:incompatible" ],
77
+ "//conditions:default" : ["@platforms//:incompatible" ],
78
+ }),
79
+ hdrs = glob (_WINDOWS_HDRS + _COMMON_HDRS ),
80
+ srcs = glob (_WINDOWS_SRCS + _COMMON_SRCS , exclude = _COMMON_EXCLUDE_SRCS ),
81
+ includes = ["include" ],
82
+ linkopts = ["-DEFAULTLIB:shell32" ],
83
+ local_defines = [
84
+ "BOOST_THREAD_BUILD_LIB" ,
85
+ ],
86
+ defines = [
87
+ "BOOST_THREAD_WIN32" ,
88
+ "BOOST_THREAD_DONT_USE_ATOMIC" ,
89
+ ],
90
+ deps = _COMMON_DEPS + [
91
+ "@boost.atomic" ,
92
+ ],
93
+ )
94
+
95
+ cc_library (
96
+ name = "thread_mac" ,
97
+ target_compatible_with = select ({
98
+ "@platforms//os:windows" : ["@platforms//:incompatible" ],
99
+ "@platforms//os:macos" : [],
100
+ "//conditions:default" : ["@platforms//:incompatible" ],
101
+ }),
102
+ hdrs = glob (_MAC_HDRS + _COMMON_HDRS ),
103
+ srcs = glob (_MAC_SRCS + _COMMON_SRCS , exclude = _COMMON_EXCLUDE_SRCS ),
104
+ includes = ["include" ],
105
+ defines = [
106
+ "BOOST_THREAD_DONT_USE_ATOMIC" ,
107
+ ],
108
+ deps = _COMMON_DEPS ,
109
+ )
110
+
5
111
cc_library (
6
112
name = "boost.thread" ,
7
113
hdrs = glob ([
8
114
"include/**/*.hpp" ,
9
115
"include/**/*.h" ,
10
- ]),
116
+ ], exclude = _POSIX_HDRS + _WINDOWS_HDRS + _MAC_HDRS + _COMMON_HDRS ),
11
117
includes = ["include" ],
118
+ srcs = glob (["src/**/*.cpp" ], exclude = _POSIX_SRCS + _WINDOWS_SRCS + _MAC_SRCS + _COMMON_SRCS + _COMMON_EXCLUDE_SRCS ),
12
119
deps = [
13
120
"@boost.algorithm" ,
14
121
"@boost.assert" ,
15
122
"@boost.atomic" ,
16
- "@boost.bind" ,
17
- "@boost.chrono" ,
18
123
"@boost.concept_check" ,
19
- "@boost.config" ,
20
124
"@boost.container" ,
21
125
"@boost.container_hash" ,
22
- "@boost.core" ,
23
- "@boost.date_time" ,
24
126
"@boost.exception" ,
25
127
"@boost.function" ,
26
128
"@boost.intrusive" ,
27
129
"@boost.io" ,
28
130
"@boost.iterator" ,
29
131
"@boost.lexical_cast" ,
30
- "@boost.move" ,
31
132
"@boost.optional" ,
32
133
"@boost.predef" ,
33
134
"@boost.preprocessor" ,
34
135
"@boost.smart_ptr" ,
35
136
"@boost.static_assert" ,
36
- "@boost.system" ,
37
137
"@boost.throw_exception" ,
38
138
"@boost.tuple" ,
39
- "@boost.type_traits" ,
40
139
"@boost.utility" ,
41
- "@boost.winapi" ,
42
- ],
140
+ ] + select ({
141
+ "@platforms//os:windows" : [
142
+ ":thread_windows" ,
143
+ "@boost.winapi" ,
144
+ ],
145
+ "@platforms//os:macos" : [
146
+ ":thread_mac" ,
147
+ ],
148
+ "//conditions:default" : [
149
+ ":thread_posix" ,
150
+ ],
151
+ }) + _COMMON_DEPS ,
43
152
)
0 commit comments