From 8850a01b0c5453ec4707da31f4d808bf809fc819 Mon Sep 17 00:00:00 2001 From: Mike Mueller Date: Tue, 5 May 2026 07:13:31 +0200 Subject: [PATCH] ci(windows): switch bridge codegen step to pwsh to dodge msys path conversion --- .gitea/workflows/build-windows.yml | 61 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/.gitea/workflows/build-windows.yml b/.gitea/workflows/build-windows.yml index 8af453b81..77c4d6a29 100644 --- a/.gitea/workflows/build-windows.yml +++ b/.gitea/workflows/build-windows.yml @@ -123,47 +123,46 @@ jobs: Add-Content -Path $env:GITHUB_PATH -Value "$tools\bin" - name: Generate Rust <-> Dart bridge - shell: bash + # Run in pwsh, NOT bash. Git-Bash-on-Windows mangles entries like + # `C:\Program Files\Git\cmd` during MSYS PATH conversion -- when bash + # spawns dart.exe, dart sees a malformed PATH and `pub` fails with + # "Unable to find git in your PATH" even though `which git` works in bash. + shell: pwsh env: - # ffigen searches a hardcoded list of locations for libclang.dll and does - # not honor LIBCLANG_PATH; the --llvm-path flag below is what matters. - # Setting LIBCLANG_PATH anyway because some other Rust crates (e.g. bindgen) - # do read it during the build that follows. LIBCLANG_PATH: '${{ env.LLVM_HOME }}\bin' run: | - set -e + $ErrorActionPreference = 'Stop' - # Belt-and-suspenders: explicitly prepend the dirs we need so we don't - # depend on whatever PATH act_runner hands the bash step. Forward-slash - # form is what MSYS bash expects. - export PATH="/c/cargo-tools/bin:/c/Program Files/Git/cmd:/c/Program Files/Git/bin:$PATH" + # Belt-and-suspenders for the cargo-installed tools. + $env:PATH = "C:\cargo-tools\bin;$env:PATH" - echo "== PATH visibility check ==" - echo "PATH=$PATH" - echo - echo "which git -> $(which git 2>&1 || echo MISSING)" - echo "which git.exe -> $(which git.exe 2>&1 || echo MISSING)" - echo "which flutter -> $(which flutter 2>&1 || echo MISSING)" - echo "which flutter_rust_bridge_codegen -> $(which flutter_rust_bridge_codegen 2>&1 || echo MISSING)" - echo "git --version -> $(git --version 2>&1 || echo FAILED)" - echo + Write-Host "== PATH visibility check ==" + foreach ($t in 'git','flutter','flutter_rust_bridge_codegen','dart') { + $cmd = Get-Command $t -ErrorAction SilentlyContinue + if ($cmd) { Write-Host ("{0,-30} {1}" -f $t, $cmd.Source) } + else { Write-Host ("{0,-30} MISSING" -f $t) } + } + Write-Host ("git --version -> " + ((git --version) 2>&1)) - if [ ! -f "${LIBCLANG_PATH}/libclang.dll" ]; then - echo "libclang.dll not found at ${LIBCLANG_PATH}" - ls "${LIBCLANG_PATH}" || true - exit 1 - fi + if (-not (Test-Path "$env:LIBCLANG_PATH\libclang.dll")) { + throw "libclang.dll not found at $env:LIBCLANG_PATH" + } - pushd flutter + Push-Location flutter flutter pub get - popd + if ($LASTEXITCODE -ne 0) { throw "flutter pub get failed ($LASTEXITCODE)" } + Pop-Location - flutter_rust_bridge_codegen \ - --llvm-path "${LLVM_HOME}" \ - --rust-input ./src/flutter_ffi.rs \ - --dart-output ./flutter/lib/generated_bridge.dart \ + flutter_rust_bridge_codegen ` + --llvm-path "$env:LLVM_HOME" ` + --rust-input ./src/flutter_ffi.rs ` + --dart-output ./flutter/lib/generated_bridge.dart ` --c-output ./flutter/macos/Runner/bridge_generated.h - cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h + if ($LASTEXITCODE -ne 0) { throw "flutter_rust_bridge_codegen failed ($LASTEXITCODE)" } + + Copy-Item -Force ` + ./flutter/macos/Runner/bridge_generated.h ` + ./flutter/ios/Runner/bridge_generated.h - name: Replace Flutter engine with rustdesk custom engine shell: pwsh