Skip to content

Commit a91f82c

Browse files
Merge pull request #60 from supervoidcoder/command-and-git-peb
2 parents 6256e00 + 7ddec09 commit a91f82c

5 files changed

Lines changed: 701 additions & 64 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ permissions:
55
jobs:
66
build-and-test:
77
strategy:
8+
fail-fast: false
89
matrix:
910
include:
1011
- arch: x64
@@ -65,14 +66,16 @@ jobs:
6566
# Verify the exe is accessible
6667
Write-Host "Checking win-witr.exe availability..."
6768
win-witr --version
69+
if ($LASTEXITCODE -ne 0) {
70+
Write-Error "it's broken 💥"
71+
exit 1
72+
}
6873
6974
# Run all test .bat files
75+
$env:force_ansi = 1
7076
Get-ChildItem -Path tests -Recurse -Filter *.bat | ForEach-Object {
7177
Write-Host "Running test: $($_.FullName)"
7278
& $_.FullName
73-
if ($LASTEXITCODE -ne 0) {
74-
Write-Error "Test failed: $($_.Name)"
75-
exit 1
76-
}
79+
7780
}
7881

.github/workflows/release.yml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -310,33 +310,32 @@ jobs:
310310
- uses: actions/checkout@v4
311311

312312
- name: Compile for ${{ matrix.arch }}
313-
shell: cmd
313+
shell: pwsh
314314
run: |
315-
@echo off
316-
REM Find vcvarsall.bat dynamically
317-
for /f "usebackq tokens=*" %%i in (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
318-
set "VS_PATH=%%i"
319-
)
320-
321-
if not exist "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" (
322-
echo Error: vcvarsall.bat not found.
323-
exit /b 1
324-
)
325-
326-
REM Map architecture for cross-compilation (host_target)
327-
REM GitHub Actions windows-latest runners are x64, so we need x64_<target> for cross-compilation
328-
set "TARGET_ARCH=${{ matrix.arch }}"
329-
set "VCVARS_ARCH=%TARGET_ARCH%"
330-
if "%TARGET_ARCH%"=="x86" set "VCVARS_ARCH=x64_x86"
331-
if "%TARGET_ARCH%"=="arm64" set "VCVARS_ARCH=x64_arm64"
332-
333-
REM Initialize environment for the target architecture
334-
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" %VCVARS_ARCH%
335-
336-
set outName=win-witr-${{ matrix.arch }}.exe
337-
echo Compiling %outName%...
338-
cl /O2 /Ot /GL /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:%outName%
339-
if errorlevel 1 exit /b 1
315+
# Set version as environment variable
316+
$env:VERSION_NUMBER = "${{ needs.prepare.outputs.version }}"
317+
318+
# Find and initialize MSVC
319+
$vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" `
320+
-latest -products * `
321+
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
322+
-property installationPath
323+
324+
$vcvarsPath = Join-Path $vsPath "VC\Auxiliary\Build\vcvarsall.bat"
325+
326+
$targetArch = "${{ matrix.arch }}"
327+
$vcvarsArch = $targetArch
328+
if ($targetArch -eq "x86") { $vcvarsArch = "x64_x86" }
329+
if ($targetArch -eq "arm64") { $vcvarsArch = "x64_arm64" }
330+
331+
# Use cmd to call vcvarsall and then cl
332+
$outName = "win-witr-${{ matrix.arch }}.exe"
333+
$ver = "${{ needs.prepare.outputs.version_number }}"
334+
cmd /c "`"$vcvarsPath`" $vcvarsArch && cl /O2 /Ot /GL /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /DVERSION_NUMBER=\"$ver\" /Fe:$outName"
335+
if ($LASTEXITCODE -ne 0) {
336+
Write-Host "Build failed with exit code $LASTEXITCODE"
337+
Exit $LASTEXITCODE
338+
}
340339
341340
- name: Upload build artifact for ${{ matrix.arch }}
342341
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)