@@ -43,9 +43,54 @@ if ($missing.count -ge 1) {
4343$project_root = (Get-Item - Path " .\" - Verbose).FullName -replace " \\" , " /"
4444$vcpkg_root = Install-Vcpkg " ${project_root} " " "
4545$binary_dir = " cmake-out/${BuildName} "
46- # Install all dependencies from the vcpkg.json manifest file.
47- # This mirrors the behavior of our GHA builds.
48- & " ${vcpkg_root} /vcpkg.exe" install -- triplet " ${env: VCPKG_TRIPLET} "
46+
47+ # The VCPKG_ROOT env var is mismatched with the vcpkg we are running,
48+ # which causes vcpkg to ignore other env vars.
49+ # We'll unset them both and pass the overlay-triplets path manually.
50+ Remove-Item env:VCPKG_ROOT - ErrorAction SilentlyContinue
51+ Remove-Item env:VCPKG_OVERLAY_TRIPLETS - ErrorAction SilentlyContinue
52+
53+ # Define the correct path to our custom triplets.
54+ $overlay_triplets_path = " ${project_root} /ci/kokoro/windows/triplets"
55+
56+ # Install all dependencies, now passing the overlay path on the command line
57+ & " ${vcpkg_root} /vcpkg.exe" install -- triplet " ${env: VCPKG_TRIPLET} " -- overlay- triplets= " ${overlay_triplets_path} "
58+
59+ # Manually check the exit code. vcpkg might not be throwing a terminating error.
60+ if ($LastExitCode -ne 0 ) {
61+ Write-Host - ForegroundColor Red " ----------------------------------------------------------------"
62+ Write-Host - ForegroundColor Red " vcpkg install FAILED with exit code $LastExitCode ."
63+ Write-Host - ForegroundColor Red " Dumping vcpkg buildtree logs for known failing packages..."
64+ Write-Host - ForegroundColor Red " ----------------------------------------------------------------"
65+
66+ # We'll check logs for *all* known problematic packages
67+ $problem_packages = @ (" crc32c" , " yaml-cpp" )
68+
69+ foreach ($pkg in $problem_packages ) {
70+ Write-Host - ForegroundColor Magenta " --- Checking logs for $pkg ---"
71+ $log1 = " ${vcpkg_root} /buildtrees/${pkg} /config-x64-windows-static-out.log"
72+ $log2 = " ${vcpkg_root} /buildtrees/${pkg} /config-x64-windows-static-dbg-CMakeCache.txt.log"
73+ $log3 = " ${vcpkg_root} /buildtrees/${pkg} /config-x64-windows-static-rel-CMakeCache.txt.log"
74+
75+ foreach ($logFile in @ ($log1 , $log2 , $log3 )) {
76+ if (Test-Path $logFile ) {
77+ Write-Host - ForegroundColor Red " ========= Contents of $logFile ========="
78+ Get-Content $logFile
79+ Write-Host - ForegroundColor Red " ========= End of $logFile ========="
80+ } else {
81+ Write-Host - ForegroundColor Yellow " Log file not found, skipping: $logFile "
82+ }
83+ }
84+ }
85+
86+ Write-Host - ForegroundColor Red " ----------------------------------------------------------------"
87+ Write-Host - ForegroundColor Red " Dumping complete. Forcing build failure."
88+ Write-Host - ForegroundColor Red " ----------------------------------------------------------------"
89+ # Manually fail the build with the exit code from vcpkg
90+ exit $LastExitCode
91+ }
92+
93+ Write-Host - ForegroundColor Green " vcpkg install SUCCEEDED."
4994
5095$cmake_args = @ (
5196 " -G$env: GENERATOR " ,
@@ -54,15 +99,23 @@ $cmake_args=@(
5499 " -DCMAKE_TOOLCHAIN_FILE=`" ${vcpkg_root} /scripts/buildsystems/vcpkg.cmake`" "
55100 " -DCMAKE_BUILD_TYPE=${env: CONFIG} " ,
56101 " -DVCPKG_TARGET_TRIPLET=${env: VCPKG_TRIPLET} " ,
102+ " -DVCPKG_OVERLAY_TRIPLETS=${project_root} /ci/kokoro/windows/triplets" ,
57103 " -DCMAKE_C_COMPILER=cl.exe" ,
58104 " -DCMAKE_CXX_COMPILER=cl.exe" ,
59105 " -DGOOGLE_CLOUD_CPP_ENABLE_WERROR=ON" ,
60106 " -DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON" ,
61- " -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>"
107+ " -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" ,
108+ " -DGOOGLE_CLOUD_CPP_ENABLE=universe_domain"
62109)
63110
64111# Configure CMake and create the build directory.
65112Write-Host - ForegroundColor Yellow " `n $ ( Get-Date - Format o) Configuring CMake with $cmake_args "
113+
114+ # The VCPKG_ROOT env var is mismatched with the vcpkg we are running,
115+ # which causes vcpkg to ignore other env vars.
116+ # Unset the env var just before the cmake call, which also calls vcpkg.
117+ Remove-Item env:VCPKG_ROOT - ErrorAction SilentlyContinue
118+
66119cmake $cmake_args
67120if ($LastExitCode ) {
68121 Write-Host - ForegroundColor Red " cmake config failed with exit code $LastExitCode "
0 commit comments