From 420c98231094b1cd2e5de3a714c4e3ee9b4f1118 Mon Sep 17 00:00:00 2001 From: "Dr. Andre Vehreschild" <101638173+vehre-x41@users.noreply.github.com> Date: Wed, 27 Apr 2022 16:10:13 +0200 Subject: [PATCH] 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. --- .github/workflows/build.yml | 23 ++++++++++++++++++++++- BUILD.bazel | 7 +++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0495461..581c559 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ on: branches: [ master ] workflow_dispatch: jobs: - build: + cmake-build: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] @@ -39,3 +39,24 @@ jobs: - name: Test shell: bash run: cd build && ctest --output-on-failure + + bazel-build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + + - name: Build + shell: bash + run: | + cd "${{ github.workspace }}" + bazel build :all + + - name: Test + shell: bash + run: | + cd "${{ github.workspace }}" + bazel test test + diff --git a/BUILD.bazel b/BUILD.bazel index b0b9016..23e847e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,3 +1,9 @@ +yaml_cpp_defines = select({ + # On Windows, ensure static linking is used. + "@platforms//os:windows": ["YAML_CPP_STATIC_DEFINE", "YAML_CPP_NO_CONTRIB"], + "//conditions:default": [], +}) + cc_library( name = "yaml-cpp_internal", visibility = ["//:__subpackages__"], @@ -11,4 +17,5 @@ cc_library( includes = ["include"], hdrs = glob(["include/**/*.h"]), srcs = glob(["src/**/*.cpp", "src/**/*.h"]), + defines = yaml_cpp_defines, )