Skip to content

Commit 209ff53

Browse files
authored
chore: add boost bazel tests (#3)
One minor source change, but it was sent as a PR upstream boostorg#401
1 parent f339fa2 commit 209ff53

File tree

15 files changed

+7298
-15
lines changed

15 files changed

+7298
-15
lines changed

.bazelignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

.bazelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22
common --enable_bzlmod
3-
build --incompatible_use_platforms_repo_for_constraints
43
build --incompatible_enable_cc_toolchain_resolution
54
build --incompatible_strict_action_env
65
build --enable_runfiles
76
build --registry=https://raw.githubusercontent.com/bazelboost/registry/main
87
build --registry=https://bcr.bazel.build
8+
query --registry=https://raw.githubusercontent.com/bazelboost/registry/main
9+
query --registry=https://bcr.bazel.build
910

1011
try-import %workspace%/user.bazelrc

.github/workflows/bazel.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: bazel
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os:
11+
- ubuntu-latest
12+
- windows-latest
13+
- macos-latest
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- run: bazelisk test ... -k
18+
working-directory: test

BUILD.bazel

+120-11
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,151 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
22

33
package(default_visibility = ["//visibility:public"])
44

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+
5111
cc_library(
6112
name = "boost.thread",
7113
hdrs = glob([
8114
"include/**/*.hpp",
9115
"include/**/*.h",
10-
]),
116+
], exclude = _POSIX_HDRS + _WINDOWS_HDRS + _MAC_HDRS + _COMMON_HDRS),
11117
includes = ["include"],
118+
srcs = glob(["src/**/*.cpp"], exclude = _POSIX_SRCS + _WINDOWS_SRCS + _MAC_SRCS + _COMMON_SRCS + _COMMON_EXCLUDE_SRCS),
12119
deps = [
13120
"@boost.algorithm",
14121
"@boost.assert",
15122
"@boost.atomic",
16-
"@boost.bind",
17-
"@boost.chrono",
18123
"@boost.concept_check",
19-
"@boost.config",
20124
"@boost.container",
21125
"@boost.container_hash",
22-
"@boost.core",
23-
"@boost.date_time",
24126
"@boost.exception",
25127
"@boost.function",
26128
"@boost.intrusive",
27129
"@boost.io",
28130
"@boost.iterator",
29131
"@boost.lexical_cast",
30-
"@boost.move",
31132
"@boost.optional",
32133
"@boost.predef",
33134
"@boost.preprocessor",
34135
"@boost.smart_ptr",
35136
"@boost.static_assert",
36-
"@boost.system",
37137
"@boost.throw_exception",
38138
"@boost.tuple",
39-
"@boost.type_traits",
40139
"@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,
43152
)

MODULE.bazel

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ module(
55
)
66

77
bazel_dep(name = "rules_cc", version = "0.0.8")
8+
bazel_dep(name = "platforms", version = "0.0.7")
89
bazel_dep(name = "boost.algorithm", version = "1.83.0.bzl.1")
910
bazel_dep(name = "boost.assert", version = "1.83.0.bzl.1")
1011
bazel_dep(name = "boost.atomic", version = "1.83.0.bzl.1")
1112
bazel_dep(name = "boost.bind", version = "1.83.0.bzl.1")
12-
bazel_dep(name = "boost.chrono", version = "1.83.0.bzl.1")
13+
bazel_dep(name = "boost.chrono", version = "1.83.0.bzl.2")
1314
bazel_dep(name = "boost.concept_check", version = "1.83.0.bzl.1")
1415
bazel_dep(name = "boost.config", version = "1.83.0.bzl.6")
1516
bazel_dep(name = "boost.container", version = "1.83.0.bzl.1")
1617
bazel_dep(name = "boost.container_hash", version = "1.83.0.bzl.1")
1718
bazel_dep(name = "boost.core", version = "1.83.0.bzl.1")
18-
bazel_dep(name = "boost.date_time", version = "1.83.0.bzl.1")
19+
bazel_dep(name = "boost.date_time", version = "1.83.0.bzl.2")
1920
bazel_dep(name = "boost.exception", version = "1.83.0.bzl.1")
2021
bazel_dep(name = "boost.function", version = "1.83.0.bzl.1")
2122
bazel_dep(name = "boost.intrusive", version = "1.83.0.bzl.1")
@@ -28,7 +29,7 @@ bazel_dep(name = "boost.predef", version = "1.83.0.bzl.1")
2829
bazel_dep(name = "boost.preprocessor", version = "1.83.0.bzl.1")
2930
bazel_dep(name = "boost.smart_ptr", version = "1.83.0.bzl.1")
3031
bazel_dep(name = "boost.static_assert", version = "1.83.0.bzl.1")
31-
bazel_dep(name = "boost.system", version = "1.83.0.bzl.1")
32+
bazel_dep(name = "boost.system", version = "1.83.0.bzl.2")
3233
bazel_dep(name = "boost.throw_exception", version = "1.83.0.bzl.1")
3334
bazel_dep(name = "boost.tuple", version = "1.83.0.bzl.1")
3435
bazel_dep(name = "boost.type_traits", version = "1.83.0.bzl.1")

0 commit comments

Comments
 (0)