-
Notifications
You must be signed in to change notification settings - Fork 259
CI: Add WinAPI header compatibility workflow #2630
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
Merged
annihilatorq
merged 17 commits into
stephenberry:main
from
annihilatorq:ci/windows-header-compatibility-workflow
Jun 18, 2026
+257
−0
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eacf8bf
ci(windows): add <Windows.h> compatibility workflow
annihilatorq 36ceb50
fix(ci): use a single target for all glaze includes
annihilatorq d6d9835
ci: switch Windows header compatibility workflow to windows-latest
annihilatorq 6d23e80
fix(ci): compile glaze/eetf headers with installed erlang
annihilatorq c37ecd2
fix(ci): specify OS verison for erlang setup
annihilatorq 718eb85
fix(ci): install asio and eigen via vcpkg
annihilatorq 1da9f17
fix(ci): build glaze/net headers with WIN32_LEAN_AND_MEAN
annihilatorq b79a173
fix(ci): define ssize_t for erlang headers on Windows
annihilatorq dbeff21
fix(ci): split winsock.h-sensitive header compatibility checks
annihilatorq ad7feb2
fix(ci): remove /Zs compile option
annihilatorq 2e9d354
refactor(ci): move windows-header-compatibility CMake to cmake/ci dir…
annihilatorq 0c40575
refactor(ci): make CMake code and workflow more readable
annihilatorq dc9d3bc
chore(ci): remove redundant CMAKE_CXX_STANDARD option
annihilatorq 2a8e664
chore(ci): remove redundant vcpkg triplet selection
annihilatorq 32570fc
chore(ci): remove redundant CMake architecture option
annihilatorq b9548f2
fix(ci): vcpkg installation typo
annihilatorq 9c4df1b
chore(ci): remove redundant vcpkg triplet in CMake configuration
annihilatorq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # This workflow verifies that Glaze headers can be compiled after including | ||
| # <Windows.h> in an unsanitized Windows project. | ||
| # | ||
| # NOMINMAX and WIN32_LEAN_AND_MEAN are manually disabled before including <Windows.h> | ||
| # The workflow generates a single aggregate translation unit that recursively | ||
| # includes every .hpp file inside include/glaze. | ||
| # This will catch collisions with Windows macros such as 'min', 'max', 'ERROR', | ||
| # 'near', 'far', and 'small', and will also prevent fixes that silently mutate | ||
| # the user's macro environment by undefining those macros. | ||
| # DELETE is a special case for 'net' which undefs it, so this macro is not checked. | ||
|
|
||
| name: windows-header-compatibility | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - feature/* | ||
| paths: | ||
| - 'include/**' | ||
| - 'cmake/**' | ||
| - 'CMakeLists.txt' | ||
| - '.github/workflows/windows-header-compatibility.yml' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'include/**' | ||
| - 'cmake/**' | ||
| - 'CMakeLists.txt' | ||
| - '.github/workflows/windows-header-compatibility.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: windows-2025-vs2026 | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Create CMake project | ||
| run: | | ||
| $projectRoot = "${{github.workspace}}" | ||
| $compatibilitySourceDir = Join-Path $projectRoot "build/windows-header-compatibility/source" | ||
| New-Item -ItemType Directory -Force -Path $compatibilitySourceDir | Out-Null | ||
|
|
||
| $cmakeLists = @' | ||
| cmake_minimum_required(VERSION 3.21) | ||
|
|
||
| project(glaze_windows_header_compatibility LANGUAGES CXX) | ||
|
|
||
| set(GLAZE_SOURCE_DIR "" CACHE PATH "Glaze source directory") | ||
|
|
||
| if(NOT GLAZE_SOURCE_DIR) | ||
| message(FATAL_ERROR "GLAZE_SOURCE_DIR is required") | ||
| endif() | ||
|
|
||
| get_filename_component(GLAZE_SOURCE_DIR "${GLAZE_SOURCE_DIR}" ABSOLUTE) | ||
|
|
||
| if(NOT EXISTS "${GLAZE_SOURCE_DIR}/CMakeLists.txt") | ||
| message(FATAL_ERROR "GLAZE_SOURCE_DIR must point to the Glaze source tree") | ||
| endif() | ||
|
|
||
| add_subdirectory("${GLAZE_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/glaze") | ||
|
|
||
| file(GLOB_RECURSE glaze_public_headers CONFIGURE_DEPENDS "${GLAZE_SOURCE_DIR}/include/glaze/*.hpp") | ||
| list(SORT glaze_public_headers) | ||
| list(LENGTH glaze_public_headers glaze_public_header_count) | ||
|
|
||
| if(glaze_public_header_count EQUAL 0) | ||
| message(FATAL_ERROR "No Glaze public headers were found") | ||
| endif() | ||
|
|
||
| message(STATUS "Found ${glaze_public_header_count} Glaze public headers") | ||
|
|
||
| file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated") | ||
|
|
||
| set(source_path "${CMAKE_CURRENT_BINARY_DIR}/generated/glaze_windows_header_compatibility.cpp") | ||
|
|
||
| string(CONCAT source_content | ||
| "#ifdef _WINDOWS_\n" | ||
| "#error Windows.h must not be included before this compatibility source\n" | ||
| "#endif\n" | ||
| "#undef NOMINMAX\n" | ||
| "#undef WIN32_LEAN_AND_MEAN\n" | ||
| "#undef NOGDI\n" | ||
| "#include <Windows.h>\n" | ||
| "#ifndef min\n" | ||
| "#error min macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifndef max\n" | ||
| "#error max macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifndef ERROR\n" | ||
| "#error ERROR macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifndef DELETE\n" | ||
| "#error DELETE macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifndef near\n" | ||
| "#error near macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifndef far\n" | ||
| "#error far macro is expected after including Windows.h\n" | ||
| "#endif\n" | ||
| "#ifdef small\n" | ||
| "#define GLAZE_WINDOWS_HEADER_HAS_SMALL 1\n" | ||
| "#endif\n" | ||
| ) | ||
|
|
||
| foreach(header_path IN LISTS glaze_public_headers) | ||
| file(RELATIVE_PATH header_relative_path "${GLAZE_SOURCE_DIR}/include" "${header_path}") | ||
| string(REPLACE "\\" "/" header_include_path "${header_relative_path}") | ||
|
|
||
| string(APPEND source_content | ||
| "#include <${header_include_path}>\n" | ||
| "#ifndef min\n" | ||
| "#error min macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#ifndef max\n" | ||
| "#error max macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#ifndef ERROR\n" | ||
| "#error ERROR macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#ifndef near\n" | ||
| "#error near macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#ifndef far\n" | ||
| "#error far macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#ifdef GLAZE_WINDOWS_HEADER_HAS_SMALL\n" | ||
| "#ifndef small\n" | ||
| "#error small macro was not preserved after including ${header_include_path}\n" | ||
| "#endif\n" | ||
| "#endif\n" | ||
| ) | ||
| endforeach() | ||
|
|
||
| file(WRITE "${source_path}" "${source_content}") | ||
|
|
||
| add_library(glaze_windows_header_compatibility OBJECT "${source_path}") | ||
| target_compile_features(glaze_windows_header_compatibility PRIVATE cxx_std_23) | ||
|
|
||
| # From Microsoft documentation - /Zs (Syntax Check Only): | ||
| # When using this option, no output files are created, and error messages are written to standard output. | ||
| # The /Zs option provides a quick way to find and correct syntax errors before you compile and link a source file. | ||
| target_compile_options(glaze_windows_header_compatibility PRIVATE /Zs) | ||
|
|
||
| if(TARGET glaze::glaze) | ||
| target_link_libraries(glaze_windows_header_compatibility PRIVATE glaze::glaze) | ||
| elseif(TARGET glaze) | ||
| target_link_libraries(glaze_windows_header_compatibility PRIVATE glaze) | ||
| else() | ||
| target_include_directories(glaze_windows_header_compatibility PRIVATE "${GLAZE_SOURCE_DIR}/include") | ||
| endif() | ||
| '@ | ||
|
|
||
| Set-Content -Path (Join-Path $compatibilitySourceDir "CMakeLists.txt") -Value $cmakeLists -Encoding UTF8 | ||
|
|
||
| - name: Configure CMake | ||
| run: cmake -S ${{github.workspace}}/build/windows-header-compatibility/source -B ${{github.workspace}}/build/windows-header-compatibility/build -DGLAZE_SOURCE_DIR=${{github.workspace}} -DCMAKE_CXX_STANDARD=23 | ||
|
|
||
| - name: Build | ||
| run: cmake --build build/windows-header-compatibility/build --config Debug --target glaze_windows_header_compatibility --parallel | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.