Skip to content

build: ci: enable Ninja/MSVC and use it in CI #10343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/call-build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,16 @@ jobs:
config:
- name: "Windows 32bit"
arch: x86
openssl_dir: C:\vcpkg\packages\openssl_x86-windows-static
cmake_additional_opt: ""
vcpkg_triplet: x86-windows-static
cmake_version: "3.31.6"
- name: "Windows 64bit"
arch: x64
openssl_dir: C:\vcpkg\packages\openssl_x64-windows-static
cmake_additional_opt: ""
vcpkg_triplet: x64-windows-static
cmake_version: "3.31.6"
- name: "Windows 64bit (Arm64)"
arch: amd64_arm64
openssl_dir: C:\vcpkg\packages\openssl_arm64-windows-static
cmake_additional_opt: "-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_SYSTEM_PROCESSOR=ARM64"
vcpkg_triplet: arm64-windows-static
cmake_version: "3.31.6"
Expand Down Expand Up @@ -143,10 +140,10 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
C:\vcpkg\packages
key: ${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-${{ steps.get-date.outputs.date }}
C:\vcpkg\installed
key: ${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-installed-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-
${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-installed-
enableCrossOsArchive: false

- name: Build openssl with vcpkg
Expand All @@ -159,12 +156,17 @@ jobs:
C:\vcpkg\vcpkg install --recurse libyaml --triplet ${{ matrix.config.vcpkg_triplet }}
shell: cmd

- name: Upgrade any outdated vcpkg packages
run: |
C:\vcpkg\vcpkg upgrade --no-dry-run
shell: cmd

- name: Save packages of vcpkg
id: save-vcpkg-sources
uses: actions/cache/save@v4
with:
path: |
C:\vcpkg\packages
C:\vcpkg\installed
key: ${{ steps.cache-vcpkg-sources.outputs.cache-primary-key }}
enableCrossOsArchive: false

Expand All @@ -174,7 +176,7 @@ jobs:
# This is only supposed to be a workaround for now so can be easily removed later.
if: ${{ matrix.config.arch != 'amd64_arm64' || needs.call-build-windows-get-meta.outputs.armSupported == 'true' }}
run: |
cmake -G "NMake Makefiles" -DFLB_NIGHTLY_BUILD='${{ inputs.unstable }}' -DOPENSSL_ROOT_DIR='${{ matrix.config.openssl_dir }}' ${{ matrix.config.cmake_additional_opt }} -DFLB_LIBYAML_DIR=C:\vcpkg\packages\libyaml_${{ matrix.config.vcpkg_triplet }} ../
cmake -G "Ninja" -DFLB_NIGHTLY_BUILD='${{ inputs.unstable }}' -DOPENSSL_ROOT_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' ${{ matrix.config.cmake_additional_opt }} -DFLB_LIBYAML_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' ../
cmake --build .
cpack
working-directory: build
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/call-windows-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ jobs:
config:
- name: "Windows 32bit"
arch: x86
openssl_dir: C:\vcpkg\packages\openssl_x86-windows-static
cmake_additional_opt: ""
vcpkg_triplet: x86-windows-static
cmake_version: "3.31.6"
- name: "Windows 64bit"
arch: x64
openssl_dir: C:\vcpkg\packages\openssl_x64-windows-static
cmake_additional_opt: ""
vcpkg_triplet: x64-windows-static
cmake_version: "3.31.6"
Expand Down Expand Up @@ -91,10 +89,10 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
C:\vcpkg\packages
key: ${{ runner.os }}-${{ matrix.config.arch }}-wintest-vcpkg-${{ steps.get-date.outputs.date }}
C:\vcpkg\installed
key: ${{ runner.os }}-${{ matrix.config.arch }}-wintest-vcpkg-installed-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.config.arch }}-wintest-vcpkg-
${{ runner.os }}-${{ matrix.config.arch }}-wintest-vcpkg-installed-
enableCrossOsArchive: false

- name: Build openssl with vcpkg
Expand All @@ -107,23 +105,28 @@ jobs:
C:\vcpkg\vcpkg install --recurse libyaml --triplet ${{ matrix.config.vcpkg_triplet }}
shell: cmd

- name: Upgrade any outdated vcpkg packages
run: |
C:\vcpkg\vcpkg upgrade --no-dry-run
shell: cmd

- name: Save packages of vcpkg
id: save-vcpkg-sources
uses: actions/cache/save@v4
with:
path: |
C:\vcpkg\packages
C:\vcpkg\installed
key: ${{ steps.cache-unit-test-vcpkg-sources.outputs.cache-primary-key }}
enableCrossOsArchive: false

- name: Build unit-test for Fluent Bit packages (only for x86 and x64)
run: |
cmake -G "NMake Makefiles" `
cmake -G "Ninja" `
-D FLB_TESTS_INTERNAL=On `
-D FLB_NIGHTLY_BUILD='${{ inputs.unstable }}' `
-D OPENSSL_ROOT_DIR='${{ matrix.config.openssl_dir }}' `
-D OPENSSL_ROOT_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' `
${{ matrix.config.cmake_additional_opt }} `
-D FLB_LIBYAML_DIR=C:\vcpkg\packages\libyaml_${{ matrix.config.vcpkg_triplet }} `
-D FLB_LIBYAML_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' `
-D FLB_WITHOUT_flb-rt-out_elasticsearch=On `
-D FLB_WITHOUT_flb-rt-out_td=On `
-D FLB_WITHOUT_flb-rt-out_forward=On `
Expand Down
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ if (MSVC)
# /wd4100 .. C4100 (unreferenced formal parameter)
# /wd5045 .. C5045 (Spectre mitigation)
#
# Restore /OPT:REF after setting /Debug, enable /OPT:ICF for 64-bit
# builds per Microsoft recommended best practices.
set(CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS /DNDEBUG /O2 /Zi /wd4100 /wd4711 /wd5045")
set(CMAKE_EXE_LINKER_FLAGS "/Debug /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS "/DEBUG /OPT:REF /INCREMENTAL:NO")
set(CMAKE_SHARED_LINKER_FLAGS "/DEBUG /OPT:REF /INCREMENTAL:NO")
set(CMAKE_BUILD_TYPE None)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:ICF")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:ICF")
endif()

# Use add_compile_options() to set /MT since Visual Studio
# Generator does not notice /MT in CMAKE_C_FLAGS.
Expand Down Expand Up @@ -1029,12 +1036,8 @@ else()
set(AUTOCONF_HOST_OPT "--host=${GNU_HOST}")
endif()

if(CMAKE_GENERATOR MATCHES "Ninja")
if(FLB_SYSTEM_WINDOWS)
MESSAGE(FATAL_ERROR "Building with Ninja is not supported on Windows")
else()
set(EXTERNAL_BUILD_TOOL "make")
endif()
if(CMAKE_GENERATOR MATCHES "Ninja" AND NOT FLB_SYSTEM_WINDOWS)
set(EXTERNAL_BUILD_TOOL "make")
else()
set(EXTERNAL_BUILD_TOOL "$(MAKE)")
endif()
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ COPY . /src/
ARG BUILD_PARALLEL=1
SHELL ["cmd", "/S", "/C"]
RUN call "%MSVS_HOME%\VC\Auxiliary\Build\vcvars64.bat" && `
cmake -G "NMake Makefiles" `
cmake -G "Ninja" `
-DOPENSSL_ROOT_DIR='C:\dev\vcpkg\packages\openssl_x64-windows-static' `
-DFLB_LIBYAML_DIR='C:\dev\vcpkg\packages\libyaml_x64-windows-static' `
-DCMAKE_BUILD_TYPE=Release `
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ if(FLB_SHARED_LIB)
if (MSVC)
set_target_properties(fluent-bit-shared
PROPERTIES PDB_NAME fluent-bit.dll)
target_link_options(fluent-bit-shared
PUBLIC /pdb:$<TARGET_PDB_FILE:fluent-bit-shared>)
endif()

# Library install routines
Expand Down Expand Up @@ -521,9 +519,11 @@ if(FLB_BINARY)
else()
add_executable(fluent-bit-bin fluent-bit.c flb_dump.c)
endif()
if (MSVC)
set_target_properties(fluent-bit-bin PROPERTIES IMPORT_SUFFIX ".exe.lib")
endif(MSVC)
add_sanitizers(fluent-bit-bin)


if(FLB_STATIC_CONF)
add_dependencies(fluent-bit-bin flb-static-conf)
endif()
Expand Down
Loading