@@ -152,6 +152,8 @@ param
152
152
[string ] $Variant = " Asserts" ,
153
153
[switch ] $Clean ,
154
154
[switch ] $DebugInfo ,
155
+ [ValidatePattern (' ^\d+(\.\d+)*$' )]
156
+ [string ] $SCCacheVersion = " 0.10.0" ,
155
157
[switch ] $EnableCaching ,
156
158
[ValidateSet (" debug" , " release" )]
157
159
[string ] $FoundationTestConfiguration = " debug" ,
@@ -374,6 +376,34 @@ $KnownNDKs = @{
374
376
}
375
377
}
376
378
379
+ $KnownSCCache = @ {
380
+ " 0.9.1" = @ {
381
+ AMD64 = @ {
382
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.9.1/sccache-v0.9.1-x86_64-pc-windows-msvc.zip"
383
+ SHA256 = " 9C862BCAEF62804F2124DFC2605A0204F4FE0C5FA337BA4264E9BCAE9D2BA487"
384
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.9.1\sccache-v0.9.1-x86_64-pc-windows-msvc" , " sccache.exe" );
385
+ }
386
+ ARM64 = @ {
387
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.9.1/sccache-v0.9.1-aarch64-pc-windows-msvc.tar.gz"
388
+ SHA256 = " 99BD024919430DE3C741658ADC60334305A61C0A109F7A334C030F0BB56007A6"
389
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.9.1\sccache-v0.9.1-aarch64-pc-windows-msvc" , " sccache.exe" )
390
+ }
391
+ }
392
+
393
+ " 0.10.0" = @ {
394
+ AMD64 = @ {
395
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-pc-windows-msvc.zip"
396
+ SHA256 = " 6D8823B5C13E0DBA776D88C537229256ECB2F01A1D775B507FD141CB55D30578"
397
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.10.0\sccache-v0.10.0-x86_64-pc-windows-msvc" , " sccache.exe" )
398
+ }
399
+ ARM64 = @ {
400
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-aarch64-pc-windows-msvc.tar.gz"
401
+ SHA256 = " 5FD6CD6DD474E91C37510719BF27CFE1826F929E40DD383C22A7B96DA9A5458D"
402
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.10.0\sccache-v0.10.0-aarch64-pc-windows-msvc" , " sccache.exe" )
403
+ }
404
+ }
405
+ }
406
+
377
407
$BuildArchName = if ($env: PROCESSOR_ARCHITEW6432 ) { $env: PROCESSOR_ARCHITEW6432 } else { $env: PROCESSOR_ARCHITECTURE }
378
408
# TODO: Support other cross-compilation scenarios.
379
409
$BuildOS = [OS ]::Windows
@@ -539,6 +569,10 @@ function Get-BisonExecutable {
539
569
return Join-Path - Path $BinaryCache - ChildPath " win_flex_bison\win_bison.exe"
540
570
}
541
571
572
+ function Get-SCCache {
573
+ return $KnownSCCache [$SCCacheVersion ][$BuildArchName ]
574
+ }
575
+
542
576
function Get-PythonPath ([Hashtable ] $Platform ) {
543
577
return [IO.Path ]::Combine(" $BinaryCache \" , " Python$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
544
578
}
@@ -967,6 +1001,12 @@ function Get-Dependencies {
967
1001
968
1002
if ($SkipBuild ) { return }
969
1003
1004
+ if ($EnableCaching ) {
1005
+ $SCCache = Get-SCCache
1006
+ DownloadAndVerify $SCCache.URL " $BinaryCache \sccache-$SCCacheVersion .zip" $SCCache.SHA256
1007
+ Expand-ZipFile sccache- $SCCacheVersion.zip $BinaryCache sccache- $SCCacheVersion
1008
+ }
1009
+
970
1010
DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
971
1011
972
1012
if ($Test -contains " lldb" ) {
@@ -1147,20 +1187,6 @@ function Add-FlagsDefine([hashtable]$Defines, [string]$Name, [string[]]$Value) {
1147
1187
}
1148
1188
}
1149
1189
1150
- function Test-SCCacheAtLeast ([int ]$Major , [int ]$Minor , [int ]$Patch = 0 ) {
1151
- if ($ToBatch ) { return $false }
1152
-
1153
- $SCCacheVersionString = @ (& sccache.exe -- version)[0 ]
1154
- if (-not ($SCCacheVersionString -match " sccache (\d+)\.(\d+)(?:\.(\d+))?" )) {
1155
- throw " Unexpected SCCache version string format"
1156
- }
1157
-
1158
- if ([int ]$Matches.1 -ne $Major ) { return [int ]$Matches.1 -gt $Major }
1159
- if ([int ]$Matches.2 -ne $Minor ) { return [int ]$Matches.2 -gt $Minor }
1160
- if ($null -eq $Matches.3 ) { return 0 -gt $Patch }
1161
- return [int ]$Matches.3 -ge $Patch
1162
- }
1163
-
1164
1190
function Get-PlatformRoot ([OS ] $OS ) {
1165
1191
return ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" , " $ ( $OS.ToString ()) .platform" ))
1166
1192
}
@@ -1289,14 +1315,14 @@ function Build-CMakeProject {
1289
1315
if ($UseMSVCCompilers.Contains (" C" )) {
1290
1316
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER cl
1291
1317
if ($EnableCaching ) {
1292
- Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER sccache
1318
+ Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
1293
1319
}
1294
1320
Add-FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
1295
1321
}
1296
1322
if ($UseMSVCCompilers.Contains (" CXX" )) {
1297
1323
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER cl
1298
1324
if ($EnableCaching ) {
1299
- Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
1325
+ Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
1300
1326
}
1301
1327
Add-FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
1302
1328
}
@@ -3192,10 +3218,7 @@ if ($Clean) {
3192
3218
3193
3219
if (-not $SkipBuild ) {
3194
3220
if ($EnableCaching ) {
3195
- if (-Not (Test-SCCacheAtLeast - Major 0 - Minor 7 - Patch 4 )) {
3196
- throw " Minimum required sccache version is 0.7.4"
3197
- }
3198
- & sccache.exe -- zero- stats
3221
+ Invoke-Program (Get-SCCache ).Path -- zero- stats
3199
3222
}
3200
3223
3201
3224
Remove-Item - Force - Recurse ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" )) - ErrorAction Ignore
0 commit comments