Skip to content

Commit 12c79ce

Browse files
committed
Fix Windows build MSYS2 integration and error capture
- Fix CMake MSYS2 bash detection to use setup-msys2 wrapper instead of Git bash - Add proper handling for GitHub Actions setup-msys2 location - Improve build error capture with detailed stdout/stderr logging - Use correct MSYS2 command format for GitHub Actions environment This should resolve the bash detection issue where CMake was finding Git's bash.exe instead of the proper MSYS2 environment.
1 parent 6bb4f46 commit 12c79ce

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

.github/workflows/build-windows.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,33 @@ jobs:
100100
msbuild -version
101101
echo "=== Starting build with detailed logging ==="
102102
103-
# Try build with detailed diagnostics
104-
if (-not (cmake --build . --config Release --parallel 4 --verbose -- /verbosity:diagnostic /consoleloggerparameters:ShowTimestamp)) {
103+
# Try build with detailed diagnostics - capture full output
104+
$buildOutput = ""
105+
$buildError = ""
106+
try {
107+
# Use Start-Process to capture all output
108+
$process = Start-Process -FilePath "cmake" -ArgumentList "--build", ".", "--config", "Release", "--parallel", "4", "--verbose", "--", "/verbosity:detailed" -NoNewWindow -Wait -PassThru -RedirectStandardOutput "build-output.log" -RedirectStandardError "build-error.log"
109+
$buildOutput = Get-Content "build-output.log" -Raw -ErrorAction SilentlyContinue
110+
$buildError = Get-Content "build-error.log" -Raw -ErrorAction SilentlyContinue
111+
112+
if ($process.ExitCode -ne 0) {
113+
echo "=== BUILD FAILED - Exit Code: $($process.ExitCode) ==="
114+
echo "=== STDOUT OUTPUT ==="
115+
if ($buildOutput) { echo $buildOutput } else { echo "No stdout output" }
116+
echo "=== STDERR OUTPUT ==="
117+
if ($buildError) { echo $buildError } else { echo "No stderr output" }
118+
$buildFailed = $true
119+
} else {
120+
echo "=== BUILD SUCCEEDED ==="
121+
$buildFailed = $false
122+
}
123+
} catch {
124+
echo "=== BUILD PROCESS EXCEPTION ==="
125+
echo $_.Exception.Message
126+
$buildFailed = $true
127+
}
128+
129+
if ($buildFailed) {
105130
echo "=== First build attempt failed, checking atari800 status ==="
106131
107132
# Check if libatari800 was actually built despite the error

CMakeLists.txt

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,37 @@ set(ATARI800_LIBRARY "${ATARI800_SOURCE_DIR}/src/libatari800.a")
5252
if(WIN32)
5353
# Windows: Use MSYS2 environment for building atari800
5454
# GitHub Actions uses setup-msys2 which sets up environment differently
55-
find_program(MSYS2_BASH bash.exe PATHS
56-
"$ENV{MSYSTEM_PREFIX}/bin"
57-
"D:/a/_temp/msys64/usr/bin"
58-
"C:/tools/msys64/usr/bin"
59-
"C:/msys64/usr/bin"
60-
DOC "MSYS2 bash executable")
55+
# Look for MSYS2 bash in GitHub Actions setup-msys2 location
56+
find_program(MSYS2_BASH NAMES msys2.cmd msys2.CMD PATHS
57+
"D:/a/_temp/setup-msys2"
58+
DOC "MSYS2 wrapper script")
59+
60+
if(NOT MSYS2_BASH)
61+
# Fallback to traditional bash.exe locations
62+
find_program(MSYS2_BASH bash.exe PATHS
63+
"$ENV{MSYSTEM_PREFIX}/bin"
64+
"D:/a/_temp/msys64/usr/bin"
65+
"C:/tools/msys64/usr/bin"
66+
"C:/msys64/usr/bin"
67+
NO_DEFAULT_PATH
68+
DOC "MSYS2 bash executable")
69+
endif()
6170
if(NOT MSYS2_BASH)
6271
message(FATAL_ERROR "MSYS2 bash not found. Please install MSYS2 or ensure it's in the expected location.")
6372
endif()
6473

6574
message(STATUS "Found MSYS2 bash: ${MSYS2_BASH}")
6675

6776
# Use msys2 shell environment with proper PATH for MinGW gcc
68-
set(ATARI800_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} --login -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && '${CMAKE_CURRENT_SOURCE_DIR}/scripts/configure-atari800.sh' '<SOURCE_DIR>'")
69-
set(ATARI800_BUILD_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} --login -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && make -j4")
77+
if(MSYS2_BASH MATCHES "msys2\.(cmd|CMD)$")
78+
# GitHub Actions setup-msys2 wrapper
79+
set(ATARI800_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && '${CMAKE_CURRENT_SOURCE_DIR}/scripts/configure-atari800.sh' '<SOURCE_DIR>'")
80+
set(ATARI800_BUILD_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && make -j4")
81+
else()
82+
# Traditional bash.exe
83+
set(ATARI800_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} --login -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && '${CMAKE_CURRENT_SOURCE_DIR}/scripts/configure-atari800.sh' '<SOURCE_DIR>'")
84+
set(ATARI800_BUILD_COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} --login -c "export PATH='/mingw64/bin:$PATH' && cd '<SOURCE_DIR>' && make -j4")
85+
endif()
7086
else()
7187
# Unix/macOS: Use native tools
7288
set(ATARI800_CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/configure-atari800.sh <SOURCE_DIR>)
@@ -116,7 +132,7 @@ if(WIN32)
116132
COMMAND ${CMAKE_COMMAND} -E echo "=== Verifying libatari800 build on Windows ==="
117133
COMMAND ${CMAKE_COMMAND} -E echo "Expected library: ${ATARI800_LIBRARY}"
118134
COMMAND ${CMAKE_COMMAND} -E echo "Checking if library exists..."
119-
COMMAND ${MSYS2_BASH} -l -c "export PATH='/mingw64/bin:$PATH' && if [ -f '${ATARI800_LIBRARY}' ]; then echo 'SUCCESS: libatari800.a exists'; ls -la '${ATARI800_LIBRARY}'; else echo 'ERROR: libatari800.a missing'; ls -la '${ATARI800_SOURCE_DIR}/src/'; fi"
135+
COMMAND ${CMAKE_COMMAND} -E env MSYSTEM=MSYS ${MSYS2_BASH} -c "export PATH='/mingw64/bin:$PATH' && if [ -f '${ATARI800_LIBRARY}' ]; then echo 'SUCCESS: libatari800.a exists'; ls -la '${ATARI800_LIBRARY}'; else echo 'ERROR: libatari800.a missing'; ls -la '${ATARI800_SOURCE_DIR}/src/'; fi"
120136
COMMENT "Verifying libatari800 library creation"
121137
)
122138
endif()

0 commit comments

Comments
 (0)