Skip to content

Commit cadb8e5

Browse files
andrewkatsonzaucy
andauthored
feat: add bazel tests and defines (#1)
Co-authored-by: Ezekiel Warren <[email protected]>
1 parent f2bf974 commit cadb8e5

File tree

10 files changed

+5441
-4
lines changed

10 files changed

+5441
-4
lines changed

.bazelrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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

.github/workflows/bazel.yml

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

BUILD.bazel

+64-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,63 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
22

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

5+
_WINDOWS_HDRS = [
6+
"**/win/*.hpp"
7+
]
8+
9+
_POSIX_HDRS = [
10+
"**/posix/*.hpp"
11+
]
12+
13+
_MAC_HDRS = [
14+
"**/mac/*.hpp"
15+
]
16+
17+
18+
cc_library(
19+
name = "chrono_posix",
20+
target_compatible_with = select({
21+
"@platforms//os:windows": ["@platforms//:incompatible"],
22+
"@platforms//os:macos": ["@platforms//:incompatible"],
23+
"//conditions:default": [],
24+
}),
25+
hdrs = glob(_POSIX_HDRS),
26+
includes = ["include"],
27+
defines = ["BOOST_THREAD_DONT_USE_ATOMIC"],
28+
)
29+
30+
cc_library(
31+
name = "chrono_windows",
32+
target_compatible_with = select({
33+
"@platforms//os:windows": [],
34+
"@platforms//os:macos": ["@platforms//:incompatible"],
35+
"//conditions:default": ["@platforms//:incompatible"],
36+
}),
37+
hdrs = glob(_WINDOWS_HDRS),
38+
includes = ["include"],
39+
linkopts = ["-DEFAULTLIB:shell32"],
40+
)
41+
42+
cc_library(
43+
name = "chrono_mac",
44+
target_compatible_with = select({
45+
"@platforms//os:windows": ["@platforms//:incompatible"],
46+
"@platforms//os:macos": [],
47+
"//conditions:default": ["@platforms//:incompatible"],
48+
}),
49+
hdrs = glob(_MAC_HDRS),
50+
includes = ["include"],
51+
linkopts = ["-DEFAULTLIB:shell32"],
52+
)
53+
554
cc_library(
655
name = "boost.chrono",
756
hdrs = glob([
857
"include/**/*.hpp",
958
"include/**/*.h",
10-
]),
59+
], exclude = _POSIX_HDRS + _WINDOWS_HDRS + _MAC_HDRS),
60+
srcs = glob(["src/**/*.cpp"]),
61+
defines = ["BOOST_ALL_NO_LIB"],
1162
includes = ["include"],
1263
deps = [
1364
"@boost.assert",
@@ -24,6 +75,16 @@ cc_library(
2475
"@boost.type_traits",
2576
"@boost.typeof",
2677
"@boost.utility",
27-
"@boost.winapi",
28-
],
78+
] + select({
79+
"@platforms//os:windows": [
80+
":chrono_windows",
81+
"@boost.winapi",
82+
],
83+
"@platforms//os:macos": [
84+
":chrono_mac",
85+
],
86+
"//conditions:default": [
87+
":chrono_posix",
88+
],
89+
})
2990
)

MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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.assert", version = "1.83.0.bzl.1")
910
bazel_dep(name = "boost.config", version = "1.83.0.bzl.6")
1011
bazel_dep(name = "boost.core", version = "1.83.0.bzl.1")

0 commit comments

Comments
 (0)