From c4204b5ea640551c547cbb1542e4e5ba8f2912af Mon Sep 17 00:00:00 2001 From: L-Sun Date: Wed, 29 Apr 2026 05:11:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20[ci]=20Fix=20Windows=20clang=20C?= =?UTF-8?q?I=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/windows.yaml | 28 +++++++++++++++++++++++++++- examples/playground/main.cpp | 30 ++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index ed78fd0e..18594b78 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -9,6 +9,9 @@ on: jobs: build: runs-on: ${{ matrix.os }} + env: + CCACHE_DISABLE: "1" + SCCACHE_DISABLE: "1" strategy: matrix: @@ -36,9 +39,32 @@ jobs: xmake-version: latest actions-cache-folder: ".xmake-cache" + - name: Disable compiler cache + run: | + $filteredPathEntries = foreach ($entry in ($env:Path -split ';')) { + if ([string]::IsNullOrWhiteSpace($entry)) { + continue + } + + $pathEntry = $entry.Trim('"') + $hasCompilerCache = (Test-Path (Join-Path $pathEntry 'ccache.exe')) -or (Test-Path (Join-Path $pathEntry 'sccache.exe')) + if (-not $hasCompilerCache) { + $entry + } + } + $env:Path = $filteredPathEntries -join ';' + "Path=$env:Path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + if (Get-Command ccache -ErrorAction SilentlyContinue) { + throw "ccache is still on PATH" + } + if (Get-Command sccache -ErrorAction SilentlyContinue) { + throw "sccache is still on PATH" + } + xmake g --ccache=n + - name: Config run: | - xmake f -y -a x64 -m release ${{ matrix.compiler }} + xmake f -y -a x64 -m release ${{ matrix.compiler }} --ccache=n --policies=package.build.ccache:n,build.ccache:n - name: Build run: | diff --git a/examples/playground/main.cpp b/examples/playground/main.cpp index 7bb4dc33..1421edbd 100644 --- a/examples/playground/main.cpp +++ b/examples/playground/main.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include import engine; @@ -7,33 +9,45 @@ import asset; using namespace hitagi; -static auto GetLatestWinPixGpuCapturerPath_Cpp17() { +static auto GetLatestWinPixGpuCapturerPath_Cpp17() -> std::filesystem::path { LPWSTR programFilesPath = nullptr; - SHGetKnownFolderPath(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &programFilesPath); + if (FAILED(SHGetKnownFolderPath(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &programFilesPath)) || + programFilesPath == nullptr) { + return {}; + } std::filesystem::path pixInstallationPath = programFilesPath; + CoTaskMemFree(programFilesPath); + pixInstallationPath /= "Microsoft PIX"; + if (!std::filesystem::exists(pixInstallationPath)) { + return {}; + } - std::string newestVersionFound; + std::wstring newestVersionFound; for (auto const& directory_entry : std::filesystem::directory_iterator(pixInstallationPath)) { if (directory_entry.is_directory()) { - if (newestVersionFound.empty() || newestVersionFound < directory_entry.path().filename().string()) { - newestVersionFound = directory_entry.path().filename().string(); + const auto version = directory_entry.path().filename().wstring(); + if (newestVersionFound.empty() || newestVersionFound < version) { + newestVersionFound = version; } } } if (newestVersionFound.empty()) { - // TODO: Error, no PIX installation found + return {}; } return pixInstallationPath / newestVersionFound / L"WinPixGpuCapturer.dll"; } auto main(int argc, char** argv) -> int { - if (GetModuleHandle("WinPixGpuCapturer.dll") == nullptr) { - LoadLibrary(GetLatestWinPixGpuCapturerPath_Cpp17().string().c_str()); + if (GetModuleHandleW(L"WinPixGpuCapturer.dll") == nullptr) { + const auto pixCapturerPath = GetLatestWinPixGpuCapturerPath_Cpp17(); + if (!pixCapturerPath.empty()) { + LoadLibraryW(pixCapturerPath.c_str()); + } } spdlog::set_level(spdlog::level::trace);