Skip to content

Commit 420c982

Browse files
authored
Improve bazel build for Windows. (#1100)
Windows builds need some defines being set to use the static linking. Also add bazel builds and test to Github-CI.
1 parent 13626af commit 420c982

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

.github/workflows/build.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches: [ master ]
77
workflow_dispatch:
88
jobs:
9-
build:
9+
cmake-build:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -39,3 +39,24 @@ jobs:
3939
- name: Test
4040
shell: bash
4141
run: cd build && ctest --output-on-failure
42+
43+
bazel-build:
44+
strategy:
45+
matrix:
46+
os: [ubuntu-latest, windows-latest, macos-latest]
47+
runs-on: ${{ matrix.os }}
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Build
52+
shell: bash
53+
run: |
54+
cd "${{ github.workspace }}"
55+
bazel build :all
56+
57+
- name: Test
58+
shell: bash
59+
run: |
60+
cd "${{ github.workspace }}"
61+
bazel test test
62+

BUILD.bazel

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
yaml_cpp_defines = select({
2+
# On Windows, ensure static linking is used.
3+
"@platforms//os:windows": ["YAML_CPP_STATIC_DEFINE", "YAML_CPP_NO_CONTRIB"],
4+
"//conditions:default": [],
5+
})
6+
17
cc_library(
28
name = "yaml-cpp_internal",
39
visibility = ["//:__subpackages__"],
@@ -11,4 +17,5 @@ cc_library(
1117
includes = ["include"],
1218
hdrs = glob(["include/**/*.h"]),
1319
srcs = glob(["src/**/*.cpp", "src/**/*.h"]),
20+
defines = yaml_cpp_defines,
1421
)

0 commit comments

Comments
 (0)