Skip to content

Native Windows support#1

Open
mekwall wants to merge 15 commits intomasterfrom
native-windows-support
Open

Native Windows support#1
mekwall wants to merge 15 commits intomasterfrom
native-windows-support

Conversation

@mekwall
Copy link
Owner

@mekwall mekwall commented Jul 5, 2025

This pull request introduces significant changes to add native Windows compatibility to the project while maintaining support for other platforms. The changes include updates to the build system, platform-specific handling in the codebase, and various compatibility adjustments for Windows. Below is a categorized summary of the most important changes:

Build System Updates

  • Added support for Windows in the GitHub Actions workflow (.github/workflows/cmake.yml). This includes adding a Windows runner and modifying the CMake configuration, build, and test steps to handle Windows-specific paths and commands.

Platform-Specific Code Adjustments

  • Updated CXXSniffer.cmake to use appropriate compiler flags for Windows (/W4) and other platforms (-Wall -Wextra).
  • Modified Datetime::timegm in src/Datetime.cpp to handle timezone environment variables differently on Windows using _putenv_s and _tzset. [1] [2]

Windows-Specific Implementations in FS.cpp

  • Introduced platform-specific headers and macros in src/FS.cpp to handle file system operations like directory creation, file locking, and path expansion on Windows. [1] [2]
  • Replaced POSIX-specific functions (e.g., realpath, access, unlink) with Windows equivalents (e.g., GetFullPathNameA, _access, _unlink) where applicable. [1] [2] [3]
  • Implemented Windows-specific logic for directory listing, recursive removal, and globbing using FindFirstFileA and FindNextFileA. [1] [2] [3]

File and Directory Operations

  • Added Windows-compatible alternatives for file and directory operations such as mkdir, rmdir, chdir, and file truncation using _mkdir, _rmdir, _chdir, and _chsize. [1] [2] [3]
  • Adjusted file synchronization logic to use FlushFileBuffers on Windows instead of fsync or fdatasync.

Minor Fixes

  • Replaced logical operators and with && in src/PEG.cpp as MSVC doesn't recognize them when using Windows headers.

Copilot AI review requested due to automatic review settings July 5, 2025 15:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Windows compatibility across the build system, filesystem utilities, and environment handling so the project can build and run on both Windows and Unix-like platforms.

  • Updated GitHub Actions and CMake to detect and configure MSVC/Windows builds
  • Introduced #ifdef _WIN32 branches for POSIX APIs in filesystem and shared logic
  • Added Windows-specific headers, typedefs, and WinAPI calls for file, directory, and time functions

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/shared.cpp Wrapped POSIX includes and execute() with Windows stubs
src/format.cpp Guarded strings.h include under _WIN32
src/Table.cpp Added Windows headers and _isatty logic
src/FS.h Introduced windows.h include and mode_t typedef
src/FS.cpp Implemented Windows fallbacks for access, mkdir, etc.
src/Datetime.cpp Switched to _putenv_s/_tzset for timegm on Windows
cmake/CXXSniffer.cmake Set /W4 flags when MSVC is detected
.github/workflows/cmake.yml Added windows-latest runner and ctest invocation
Comments suppressed due to low confidence (1)

.github/workflows/cmake.yml:41

  • On Windows runners the default shell is PowerShell, so this Bash-style if may not execute. Use ${{ runner.os }} expressions or a PowerShell step for Windows-specific logic.
          if [ "$RUNNER_OS" = "Windows" ]; then

@mekwall mekwall changed the title Native windows support Native Windows support Jul 5, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants