Windows Build #20
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
name: "Windows Build" | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
- name: Setup CUDA Toolkit | |
id: cuda-toolkit | |
shell: pwsh | |
run: scripts/setup_cuda.ps1 | |
env: | |
INPUT_CUDA_VERSION: 12.4.0 | |
- name: Setup Developer Command Prompt | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Find cl.exe Path | |
shell: pwsh | |
run: | | |
Write-Host "User: $env:USERNAME" | |
Write-Host "Date: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | |
Write-Host "========== Finding cl.exe locations ==========" | |
# Check if cl.exe is available in PATH | |
try { | |
$clCommand = Get-Command cl.exe -ErrorAction Stop | |
Write-Host "cl.exe found in PATH:" -ForegroundColor Green | |
Write-Host $clCommand.Source | |
# Display the directory | |
Write-Host "Directory containing cl.exe:" -ForegroundColor Green | |
Write-Host (Split-Path -Parent $clCommand.Source) | |
# Set NVCC_CCBIN environment variable for current step | |
$env:NVCC_CCBIN = Split-Path -Parent $clCommand.Source | |
Write-Host "NVCC_CCBIN set to: $env:NVCC_CCBIN" | |
echo "NVCC_CCBIN=$env:NVCC_CCBIN" >> $env:GITHUB_ENV | |
} | |
catch { | |
Write-Host "cl.exe not found in PATH. Searching Visual Studio directories..." -ForegroundColor Yellow | |
# Search in common Visual Studio locations | |
$vsLocations = @( | |
"C:\Program Files\Microsoft Visual Studio", | |
"C:\Program Files (x86)\Microsoft Visual Studio" | |
) | |
$foundCl = $false | |
foreach ($location in $vsLocations) { | |
if (Test-Path $location) { | |
Write-Host "Searching in $location..." -ForegroundColor Blue | |
$clFiles = Get-ChildItem -Path $location -Recurse -Filter "cl.exe" -ErrorAction SilentlyContinue | Select-Object -First 5 | |
foreach ($file in $clFiles) { | |
Write-Host "Found: $($file.FullName)" -ForegroundColor Green | |
$foundCl = $true | |
# Set the first found cl.exe as NVCC_CCBIN | |
if (-not $env:NVCC_CCBIN) { | |
$env:NVCC_CCBIN = Split-Path -Parent $file.FullName | |
Write-Host "NVCC_CCBIN set to: $env:NVCC_CCBIN" | |
echo "NVCC_CCBIN=$env:NVCC_CCBIN" >> $env:GITHUB_ENV | |
} | |
} | |
} | |
} | |
if (-not $foundCl) { | |
Write-Host "cl.exe not found in Visual Studio directories!" -ForegroundColor Red | |
} | |
} | |
# List environment variables related to Visual Studio and CUDA | |
Write-Host "========== Environment Variables ==========" | |
Get-ChildItem env: | Where-Object { $_.Name -match "VS|MSVC|CUDA|NVCC" } | Format-Table -AutoSize | |
- name: Test CUDA Build Environment | |
shell: cmd | |
run: | | |
echo "Testing CUDA build environment with NVCC_CCBIN=%NVCC_CCBIN%" | |
if defined NVCC_CCBIN ( | |
echo NVCC_CCBIN is defined as %NVCC_CCBIN% | |
if exist "%NVCC_CCBIN%\cl.exe" ( | |
echo cl.exe found at %NVCC_CCBIN%\cl.exe | |
) else ( | |
echo ERROR: cl.exe not found at %NVCC_CCBIN%\cl.exe | |
) | |
) else ( | |
echo WARNING: NVCC_CCBIN is not defined | |
) | |
where cl.exe 2>nul && echo cl.exe is in PATH || echo cl.exe is NOT in PATH | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: 'stable' | |
cache: true | |
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache | |
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path | |
- run: flutter --version | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Rust Version | |
run: | | |
rustup --version | |
cargo --version | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "rust" | |
cache-all-crates: true | |
- name: Set up LLVM | |
uses: KyleMayes/install-llvm-action@v2 | |
with: | |
version: "18" | |
- name: Flutter pub get | |
run: flutter pub get | |
- name: Flutter build runner | |
run: dart run build_runner build --delete-conflicting-outputs | |
- name: Rust cargo update | |
run: cargo update | |
working-directory: rust | |
- name: Set up Flutter rust bridge | |
run: | | |
cargo install cargo-expand | |
cargo install 'flutter_rust_bridge_codegen@^2.9.0' | |
- name: Flutter Rust bridge generate | |
run: flutter_rust_bridge_codegen generate | |
# - name: flutter gen l10n | |
# run: | | |
# flutter pub global activate intl_utils | |
# flutter pub global run intl_utils:generate | |
- name: Setup Visual Studio environment And Flutter Build | |
shell: pwsh | |
run: | | |
& cmd /c "call `"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat`" && echo %PATH% >> ${env:GITHUB_PATH}" | |
$manifestPath = "D:/a/fl_caption/fl_caption/rust/Cargo.toml" -replace '\\', '/' | |
$targetDir = "D:/a/fl_caption/fl_caption/build/windows/x64/plugins/rust_lib_fl_caption/cargokit_build" -replace '\\', '/' | |
rustup run stable cargo build --manifest-path $manifestPath -p "rust_lib_fl_caption" --release --target "x86_64-pc-windows-msvc" --target-dir $targetDir | |
flutter build windows -v | |
- name: Archive build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows | |
path: build/windows/x64/runner/Release |