Support for Windows through MSYS2 - #57
Merged
Merged
Conversation
- Add Inno Setup script (setup.iss) for creating Windows installer - Add MSYS2 provisioning script for CI builds - Add Windows launcher batch file (StartOpenPLC.bat) - Add GitHub Actions workflow for automated installer builds - Workflow triggers on version tags and manual dispatch - Installer bundles pre-provisioned MSYS2 with GCC, Python, and dependencies - Per-user installation (no admin rights required) - Creates Start Menu shortcuts automatically Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Add is_msys2() function to detect MSYS2/MinGW/Cygwin environments - Skip root check on MSYS2 (not required/meaningful on Windows) - Add install_deps_msys2() function for pacman-based package installation - Handle runtime directory creation appropriately for MSYS2 - Update check_installation() message to not suggest sudo on MSYS2 Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Add environment marker to requirements.txt to skip psutil on cygwin platforms - Add conditional import with HAS_PSUTIL flag in runtimemanager.py - Gracefully degrade when psutil is not available: - find_running_process() returns None (cannot detect existing processes) - is_runtime_alive() and stop() handle subprocess.Popen only - Log informational message when psutil is not available Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Add conditional compilation for Linux-specific real-time features: - mlockall/MCL_CURRENT/MCL_FUTURE (memory locking) - sched_setscheduler/SCHED_FIFO (real-time scheduling) - clock_nanosleep with TIMER_ABSTIME (absolute time sleep) - Use HAS_REALTIME_FEATURES macro to detect platform support - Provide fallback implementations for MSYS2/Cygwin: - sleep_until() uses nanosleep with relative time calculation - set_realtime_priority() and lock_memory() log info message and return - Add -Wno-error=cpp flag on Cygwin/MSYS2 to handle _POSIX_C_SOURCE redefinition warning from Python headers Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Use CMAKE_SYSTEM_NAME MATCHES instead of CYGWIN/MSYS variables - Use -Wno-error to disable all warnings-as-errors on MSYS2/Cygwin - The -Werror=format-security is still applied after -Wno-error Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Add OPENPLC_CLOCK macro to use CLOCK_MONOTONIC on MSYS2/Cygwin (CLOCK_MONOTONIC_RAW is Linux-specific) - Use proper #ifdef blocks instead of CMake -Wno-error workaround - Change CMake from -Wno-error to -Wno-cpp to only suppress the _POSIX_C_SOURCE redefinition warning from Python headers Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Wrap Python.h includes with GCC diagnostic push/pop to suppress the _POSIX_C_SOURCE redefinition warning on MSYS2/Cygwin - Fix applied to python_plugin_bridge.h and plugin_driver.c - Remove CMake -Wno-cpp workaround since the fix is now in the code - This is more robust than CMake platform detection which was unreliable Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Use WIN32 AND UNIX detection which is more reliable than CMAKE_SYSTEM_NAME - WIN32 AND UNIX is true on MSYS2/Cygwin but not on native Windows or Linux - Keep GCC diagnostic pragmas in Python.h includes as additional safety - The -Wno-error flag comes after -Werror to properly override it Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Wrap priority inheritance mutex code with conditional compilation - Use __CYGWIN__ and __MSYS__ preprocessor definitions for detection - On MSYS2/Cygwin, use a regular mutex without priority inheritance - Priority inheritance is a Linux-specific feature not available on MSYS2 Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- Patch ssl.SSLSocket.recv to handle EAGAIN/EWOULDBLOCK (errno 11) errors - On non-Linux platforms, return empty bytes instead of raising exception - This fixes 'Resource temporarily unavailable' error on MSYS2/Cygwin - Same fix as applied in OpenPLC_v3 commit 3ac3252 Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
- GitHub Actions workflow now uses install.sh instead of manual dependency installation - provision-msys2.sh now delegates to install.sh for consistent installation - This ensures all MSYS2-specific fixes in install.sh are used during CI builds Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
…nstaller Add Windows installer infrastructure with GitHub Actions workflow
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces comprehensive support for building and running the OpenPLC Runtime on Windows via MSYS2/Cygwin environments. The changes include a new GitHub Actions workflow for building a Windows installer, numerous portability fixes across the codebase, and adjustments to installation and runtime scripts to handle platform-specific differences. The most important changes are grouped below by theme.
Windows/MSYS2 Platform Support:
.github/workflows/windows-installer.ymlGitHub Actions workflow to automate building a Windows installer using MSYS2 and Inno Setup, including dependency installation, payload preparation, and artifact upload.install.shandstart_openplc.shscripts to detect MSYS2/Cygwin environments, skip root checks where not applicable, install dependencies usingpacman, and adjust runtime directory creation for Windows. [1] [2] [3] [4] [5] [6]Portability and Platform Conditionals in C Code:
core/src/CMakeLists.txtto disable treating warnings as errors on Cygwin/MSYS2 due to header conflicts, improving build reliability on these platforms.plugin_driver.c,python_plugin_bridge.h,scan_cycle_manager.c,utils.c) to handle MSYS2/Cygwin-specific issues such as missing real-time features, header redefinition warnings, and mutex attribute differences. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Python Webserver Robustness on Windows:
recvmethod inwebserver/app.pyto handle EAGAIN/EWOULDBLOCK errors on non-Linux platforms (such as MSYS2), preventing "Resource temporarily unavailable" issues. [1] [2]psutilan optional import inwebserver/runtimemanager.py, logging a message if unavailable, to support platforms wherepsutilcannot be installed.These changes collectively enable seamless building, installation, and running of OpenPLC Runtime on Windows environments, while maintaining compatibility and feature parity with Linux systems.