@@ -152,6 +152,8 @@ param
152152 [string ] $Variant = " Asserts" ,
153153 [switch ] $Clean ,
154154 [switch ] $DebugInfo ,
155+ [ValidatePattern (' ^\d+(\.\d+)*$' )]
156+ [string ] $SCCacheVersion = " 0.10.0" ,
155157 [switch ] $EnableCaching ,
156158 [ValidateSet (" debug" , " release" )]
157159 [string ] $FoundationTestConfiguration = " debug" ,
@@ -394,6 +396,34 @@ $KnownNDKs = @{
394396 }
395397}
396398
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+
397427$BuildArchName = if ($env: PROCESSOR_ARCHITEW6432 ) { $env: PROCESSOR_ARCHITEW6432 } else { $env: PROCESSOR_ARCHITECTURE }
398428# TODO: Support other cross-compilation scenarios.
399429$BuildOS = [OS ]::Windows
@@ -559,6 +589,10 @@ function Get-BisonExecutable {
559589 return Join-Path - Path $BinaryCache - ChildPath " win_flex_bison\win_bison.exe"
560590}
561591
592+ function Get-SCCache {
593+ return $KnownSCCache [$SCCacheVersion ][$BuildArchName ]
594+ }
595+
562596function Get-PythonPath ([Hashtable ] $Platform ) {
563597 return [IO.Path ]::Combine(" $BinaryCache \" , " Python$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
564598}
@@ -990,6 +1024,12 @@ function Get-Dependencies {
9901024
9911025 if ($SkipBuild ) { return }
9921026
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+
9931033 DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
9941034
9951035 if ($Test -contains " lldb" ) {
@@ -1183,20 +1223,6 @@ function Add-FlagsDefine([hashtable]$Defines, [string]$Name, [string[]]$Value) {
11831223 }
11841224}
11851225
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-
12001226function Get-PlatformRoot ([OS ] $OS ) {
12011227 return ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" , " $ ( $OS.ToString ()) .platform" ))
12021228}
@@ -1325,14 +1351,14 @@ function Build-CMakeProject {
13251351 if ($UseMSVCCompilers.Contains (" C" )) {
13261352 Add-KeyValueIfNew $Defines CMAKE_C_COMPILER cl
13271353 if ($EnableCaching ) {
1328- Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER sccache
1354+ Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
13291355 }
13301356 Add-FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
13311357 }
13321358 if ($UseMSVCCompilers.Contains (" CXX" )) {
13331359 Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER cl
13341360 if ($EnableCaching ) {
1335- Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
1361+ Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER $ ( Get-SCCache ).Path
13361362 }
13371363 Add-FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
13381364 }
@@ -3283,10 +3309,7 @@ if ($Clean) {
32833309
32843310if (-not $SkipBuild ) {
32853311 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
32903313 }
32913314
32923315 Remove-Item - Force - Recurse ([IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Platforms" )) - ErrorAction Ignore
0 commit comments