@@ -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" ,
@@ -394,6 +396,34 @@ $KnownNDKs = @{
394
396
}
395
397
}
396
398
399
+ $KnownSCCache = @ {
400
+ " 0.9.1" = @ {
401
+ AMD64 = @ {
402
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.9.1/sccache-v0.9.1-x86_64-pc-windows-msvc.zip"
403
+ SHA256 = " 9C862BCAEF62804F2124DFC2605A0204F4FE0C5FA337BA4264E9BCAE9D2BA487"
404
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.9.1\sccache-v0.9.1-x86_64-pc-windows-msvc" , " sccache.exe" );
405
+ }
406
+ ARM64 = @ {
407
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.9.1/sccache-v0.9.1-aarch64-pc-windows-msvc.tar.gz"
408
+ SHA256 = " 99BD024919430DE3C741658ADC60334305A61C0A109F7A334C030F0BB56007A6"
409
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.9.1\sccache-v0.9.1-aarch64-pc-windows-msvc" , " sccache.exe" )
410
+ }
411
+ }
412
+
413
+ " 0.10.0" = @ {
414
+ AMD64 = @ {
415
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-pc-windows-msvc.zip"
416
+ SHA256 = " 6D8823B5C13E0DBA776D88C537229256ECB2F01A1D775B507FD141CB55D30578"
417
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.10.0\sccache-v0.10.0-x86_64-pc-windows-msvc" , " sccache.exe" )
418
+ }
419
+ ARM64 = @ {
420
+ URL = " https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-aarch64-pc-windows-msvc.tar.gz"
421
+ SHA256 = " 5FD6CD6DD474E91C37510719BF27CFE1826F929E40DD383C22A7B96DA9A5458D"
422
+ Path = [IO.Path ]::Combine(" $BinaryCache \sccache-0.10.0\sccache-v0.10.0-aarch64-pc-windows-msvc" , " sccache.exe" )
423
+ }
424
+ }
425
+ }
426
+
397
427
$BuildArchName = if ($env: PROCESSOR_ARCHITEW6432 ) { $env: PROCESSOR_ARCHITEW6432 } else { $env: PROCESSOR_ARCHITECTURE }
398
428
# TODO: Support other cross-compilation scenarios.
399
429
$BuildOS = [OS ]::Windows
@@ -559,6 +589,10 @@ function Get-BisonExecutable {
559
589
return Join-Path - Path $BinaryCache - ChildPath " win_flex_bison\win_bison.exe"
560
590
}
561
591
592
+ function Get-SCCache {
593
+ return $KnownSCCache [$SCCacheVersion ][$BuildArchName ]
594
+ }
595
+
562
596
function Get-PythonPath ([Hashtable ] $Platform ) {
563
597
return [IO.Path ]::Combine(" $BinaryCache \" , " Python$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
564
598
}
@@ -990,6 +1024,12 @@ function Get-Dependencies {
990
1024
991
1025
if ($SkipBuild ) { return }
992
1026
1027
+ if ($EnableCaching ) {
1028
+ $SCCache = Get-SCCache
1029
+ DownloadAndVerify $SCCache.URL " $BinaryCache \sccache-$SCCacheVersion .zip" $SCCache.SHA256
1030
+ Expand-ZipFile sccache- $SCCacheVersion.zip $BinaryCache sccache- $SCCacheVersion
1031
+ }
1032
+
993
1033
DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
994
1034
995
1035
if ($Test -contains " lldb" ) {
@@ -1183,20 +1223,6 @@ function Add-FlagsDefine([hashtable]$Defines, [string]$Name, [string[]]$Value) {
1183
1223
}
1184
1224
}
1185
1225
1186
- function Test-SCCacheAtLeast ([int ]$Major , [int ]$Minor , [int ]$Patch = 0 ) {
1187
- if ($ToBatch ) { return $false }
1188
-
1189
- $SCCacheVersionString = @ (& sccache.exe -- version)[0 ]
1190
- if (-not ($SCCacheVersionString -match " sccache (\d+)\.(\d+)(?:\.(\d+))?" )) {
1191
- throw " Unexpected SCCache version string format"
1192
- }
1193
-
1194
- if ([int ]$Matches.1 -ne $Major ) { return [int ]$Matches.1 -gt $Major }
1195
- if ([int ]$Matches.2 -ne $Minor ) { return [int ]$Matches.2 -gt $Minor }
1196
- if ($null -eq $Matches.3 ) { return 0 -gt $Patch }
1197
- return [int ]$Matches.3 -ge $Patch
1198
- }
1199
-
1200
1226
function Get-PlatformRoot ([OS ] $OS ) {
1201
1227
return ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" , " $ ( $OS.ToString ()) .platform" ))
1202
1228
}
@@ -1325,14 +1351,14 @@ function Build-CMakeProject {
1325
1351
if ($UseMSVCCompilers.Contains (" C" )) {
1326
1352
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER cl
1327
1353
if ($EnableCaching ) {
1328
- Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER sccache
1354
+ Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
1329
1355
}
1330
1356
Add-FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
1331
1357
}
1332
1358
if ($UseMSVCCompilers.Contains (" CXX" )) {
1333
1359
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER cl
1334
1360
if ($EnableCaching ) {
1335
- Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
1361
+ Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
1336
1362
}
1337
1363
Add-FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
1338
1364
}
@@ -3283,10 +3309,7 @@ if ($Clean) {
3283
3309
3284
3310
if (-not $SkipBuild ) {
3285
3311
if ($EnableCaching ) {
3286
- if (-Not (Test-SCCacheAtLeast - Major 0 - Minor 7 - Patch 4 )) {
3287
- throw " Minimum required sccache version is 0.7.4"
3288
- }
3289
- & sccache.exe -- zero- stats
3312
+ Invoke-Program (Get-SCCache ).Path -- zero- stats
3290
3313
}
3291
3314
3292
3315
Remove-Item - Force - Recurse ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" )) - ErrorAction Ignore
0 commit comments