Skip to content

Commit 07d690c

Browse files
committed
Enable MSVC builds in CI
This also refactors how cflags are propageted somewhat.
1 parent 6de0e5f commit 07d690c

File tree

5 files changed

+115
-93
lines changed

5 files changed

+115
-93
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,26 @@ jobs:
3434
- uses: actions/checkout@v2
3535

3636
- name: bazel build
37-
run: CC=clang bazel build //...
37+
run: CC=clang bazel build --verbose_failures //...
3838
- name: bazel test
39-
run: CC=clang bazel test //...
39+
run: CC=clang bazel test --verbose_failures --test_output=streamed //...
4040

4141
gcc-tests:
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v2
4545

4646
- name: bazel build
47-
run: CC=gcc bazel build //...
47+
run: CC=gcc bazel build --verbose_failures //...
4848
- name: bazel test
49-
run: CC=gcc bazel test //...
49+
run: CC=gcc bazel test --verbose_failures --test_output=streamed //...
50+
51+
msvc-tests:
52+
runs-on: windows-2022
53+
steps:
54+
- uses: actions/checkout@v2
55+
56+
- name: bazel build
57+
run: bazel.exe build --verbose_failures //...
58+
- name: bazel test
59+
run: bazel.exe test --verbose_failures --test_output=streamed //...

BUILD

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515
load(
16-
"//:copts.bzl",
17-
"CWISS_DEFAULT_COPTS",
18-
"CWISS_DEFAULT_LINKOPTS",
19-
"CWISS_SAN_COPTS",
20-
"CWISS_TEST_COPTS",
21-
"CWISS_C_VERSION",
22-
"CWISS_CXX_VERSION",
16+
"//toolchain:copts.bzl",
17+
"DEFAULT_COPTS",
18+
"DEFAULT_LINKOPTS",
19+
"SAN_COPTS",
20+
"TEST_COPTS",
21+
"C_VERSION",
22+
"CXX_VERSION",
2323
)
2424

2525
filegroup(
@@ -49,8 +49,8 @@ cc_library(
4949
name = "cwisstable_split",
5050
hdrs = [":public_headers"],
5151
srcs = [":private_headers"],
52-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
53-
linkopts = CWISS_DEFAULT_LINKOPTS,
52+
copts = DEFAULT_COPTS + C_VERSION,
53+
linkopts = DEFAULT_LINKOPTS,
5454
visibility = ["//visibility:public"],
5555
)
5656

@@ -74,26 +74,26 @@ genrule(
7474
cc_library(
7575
name = "cwisstable",
7676
hdrs = ["cwisstable.h"],
77-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
78-
linkopts = CWISS_DEFAULT_LINKOPTS,
77+
copts = DEFAULT_COPTS + C_VERSION,
78+
linkopts = DEFAULT_LINKOPTS,
7979
visibility = ["//visibility:public"],
8080
)
8181

8282
cc_library(
8383
name = "debug",
8484
hdrs = ["cwisstable/internal/debug.h"],
8585
srcs = ["cwisstable/internal/debug.cc"],
86-
copts = CWISS_DEFAULT_COPTS + CWISS_CXX_VERSION,
87-
linkopts = CWISS_DEFAULT_LINKOPTS,
86+
copts = DEFAULT_COPTS + CXX_VERSION,
87+
linkopts = DEFAULT_LINKOPTS,
8888
deps = [":cwisstable"],
8989
visibility = ["//:__subpackages__"],
9090
)
9191

9292
cc_library(
9393
name = "test_helpers",
9494
hdrs = ["cwisstable/internal/test_helpers.h"],
95-
copts = CWISS_DEFAULT_COPTS + CWISS_CXX_VERSION,
96-
linkopts = CWISS_DEFAULT_LINKOPTS,
95+
copts = DEFAULT_COPTS + CXX_VERSION,
96+
linkopts = DEFAULT_LINKOPTS,
9797
deps = ["//:cwisstable"],
9898
visibility = ["//:__subpackages__"],
9999
)
@@ -109,8 +109,8 @@ cc_test(
109109
"@com_google_absl//absl/cleanup",
110110
"@com_google_googletest//:gtest_main",
111111
],
112-
copts = CWISS_TEST_COPTS + CWISS_CXX_VERSION + CWISS_SAN_COPTS,
113-
linkopts = CWISS_DEFAULT_LINKOPTS + CWISS_SAN_COPTS,
112+
copts = TEST_COPTS + CXX_VERSION + SAN_COPTS,
113+
linkopts = DEFAULT_LINKOPTS + SAN_COPTS,
114114
)
115115

116116
cc_test(
@@ -128,8 +128,8 @@ cc_test(
128128
"CWISS_HAVE_SSE2=0",
129129
"CWISS_HAVE_SSSE3=0",
130130
],
131-
copts = CWISS_TEST_COPTS + CWISS_CXX_VERSION + CWISS_SAN_COPTS,
132-
linkopts = CWISS_DEFAULT_LINKOPTS + CWISS_SAN_COPTS,
131+
copts = TEST_COPTS + CXX_VERSION + SAN_COPTS,
132+
linkopts = DEFAULT_LINKOPTS + SAN_COPTS,
133133
)
134134

135135

@@ -146,25 +146,7 @@ cc_binary(
146146
"@com_google_absl//absl/strings:str_format",
147147
"@com_github_google_benchmark//:benchmark_main",
148148
],
149-
copts = CWISS_TEST_COPTS + CWISS_CXX_VERSION,
150-
linkopts = CWISS_DEFAULT_LINKOPTS,
149+
copts = TEST_COPTS + CXX_VERSION,
150+
linkopts = DEFAULT_LINKOPTS,
151151
testonly = 1,
152-
)
153-
154-
config_setting(
155-
name = "clang_compiler",
156-
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
157-
visibility = [":__subpackages__"],
158-
)
159-
160-
config_setting(
161-
name = "msvc_compiler",
162-
flag_values = {"@bazel_tools//tools/cpp:compiler": "mscv-cl"},
163-
visibility = [":__subpackages__"],
164-
)
165-
166-
config_setting(
167-
name = "clang-cl_compiler",
168-
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang-cl"},
169-
visibility = [":__subpackages__"],
170152
)

examples/BUILD

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,80 +13,80 @@
1313
# limitations under the License.
1414

1515
load(
16-
"//:copts.bzl",
17-
"CWISS_DEFAULT_COPTS",
18-
"CWISS_DEFAULT_LINKOPTS",
19-
"CWISS_C_VERSION",
16+
"//toolchain:copts.bzl",
17+
"DEFAULT_COPTS",
18+
"DEFAULT_LINKOPTS",
19+
"C_VERSION",
2020
)
2121

2222
cc_binary(
2323
name = "arraymap",
2424
srcs = ["arraymap.c"],
2525
deps = ["//:cwisstable"],
26-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
27-
linkopts = CWISS_DEFAULT_LINKOPTS,
26+
copts = DEFAULT_COPTS + C_VERSION,
27+
linkopts = DEFAULT_LINKOPTS,
2828
defines = ["CWISS_EXAMPLE_UNIFIED"],
2929
)
3030

3131
cc_binary(
3232
name = "arraymap_split",
3333
srcs = ["arraymap.c"],
3434
deps = ["//:cwisstable_split"],
35-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
36-
linkopts = CWISS_DEFAULT_LINKOPTS,
35+
copts = DEFAULT_COPTS + C_VERSION,
36+
linkopts = DEFAULT_LINKOPTS,
3737
defines = ["CWISS_EXAMPLE_SPLIT"],
3838
)
3939

4040
cc_binary(
4141
name = "hashset",
4242
srcs = ["hashset.c"],
4343
deps = ["//:cwisstable"],
44-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
45-
linkopts = CWISS_DEFAULT_LINKOPTS,
44+
copts = DEFAULT_COPTS + C_VERSION,
45+
linkopts = DEFAULT_LINKOPTS,
4646
defines = ["CWISS_EXAMPLE_UNIFIED"],
4747
)
4848

4949
cc_binary(
5050
name = "hashset_split",
5151
srcs = ["hashset.c"],
5252
deps = ["//:cwisstable_split"],
53-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
54-
linkopts = CWISS_DEFAULT_LINKOPTS,
53+
copts = DEFAULT_COPTS + C_VERSION,
54+
linkopts = DEFAULT_LINKOPTS,
5555
defines = ["CWISS_EXAMPLE_SPLIT"],
5656
)
5757

5858
cc_binary(
5959
name = "hashmap",
6060
srcs = ["hashmap.c"],
6161
deps = ["//:cwisstable"],
62-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
63-
linkopts = CWISS_DEFAULT_LINKOPTS,
62+
copts = DEFAULT_COPTS + C_VERSION,
63+
linkopts = DEFAULT_LINKOPTS,
6464
defines = ["CWISS_EXAMPLE_UNIFIED"],
6565
)
6666

6767
cc_binary(
6868
name = "hashmap_split",
6969
srcs = ["hashmap.c"],
7070
deps = ["//:cwisstable_split"],
71-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
72-
linkopts = CWISS_DEFAULT_LINKOPTS,
71+
copts = DEFAULT_COPTS + C_VERSION,
72+
linkopts = DEFAULT_LINKOPTS,
7373
defines = ["CWISS_EXAMPLE_SPLIT"],
7474
)
7575

7676
cc_binary(
7777
name = "stringmap",
7878
srcs = ["stringmap.c"],
7979
deps = ["//:cwisstable"],
80-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
81-
linkopts = CWISS_DEFAULT_LINKOPTS,
80+
copts = DEFAULT_COPTS + C_VERSION,
81+
linkopts = DEFAULT_LINKOPTS,
8282
defines = ["CWISS_EXAMPLE_UNIFIED"],
8383
)
8484

8585
cc_binary(
8686
name = "stringmap_split",
8787
srcs = ["stringmap.c"],
8888
deps = ["//:cwisstable_split"],
89-
copts = CWISS_DEFAULT_COPTS + CWISS_C_VERSION,
90-
linkopts = CWISS_DEFAULT_LINKOPTS,
89+
copts = DEFAULT_COPTS + C_VERSION,
90+
linkopts = DEFAULT_LINKOPTS,
9191
defines = ["CWISS_EXAMPLE_SPLIT"],
9292
)

toolchain/BUILD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2022 Google LLC
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+
exports_files(["copts.bzl"])
16+
17+
config_setting(
18+
name = "is_clang",
19+
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
20+
)
21+
22+
config_setting(
23+
name = "is_msvc",
24+
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
25+
)
26+
27+
config_setting(
28+
name = "is_clang_cl",
29+
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang-cl"},
30+
)

0 commit comments

Comments
 (0)