Skip to content

Commit 09664ee

Browse files
committed
Add remote caching option
When setting up sccache we can choose between local disk caching or remote caching via an S3-ish blob storage engine. To allow for backward compatibility for anyone that might be using the existing option for disk caching we leave it place and instead provide a new remote caching option. This option assumes you've read the sccache documentation for setting up the correct environment variables for telling sccache where to find the bucket and how to authenticate to it.
1 parent 3b18849 commit 09664ee

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

utils/build.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ If true, use `sccache` to cache the build rules.
8585
.PARAMETER Cache
8686
The path to a directory where the `sccache` stores the cache. By default, it will point to `$BinaryCache\sccache`.
8787
88+
.PARAMETER EnableRemoteCaching
89+
If true, use `sccache` to cache the build rules remotely. If set, ensure that you configure the appropriate
90+
remote caching backend location and credentials environment variables for sccache.
91+
8892
.PARAMETER Clean
8993
If true, clean non-compiler builds while building.
9094
@@ -167,9 +171,13 @@ param
167171
[string] $Variant = "Asserts",
168172
[switch] $Clean,
169173
[switch] $DebugInfo,
174+
[parameter(ParameterSetName = "LocalCaching")]
170175
[switch] $EnableCaching,
176+
[parameter(ParameterSetName = "RemoteCaching")]
177+
[switch] $EnableRemoteCaching,
171178
[ValidateSet("debug", "release")]
172179
[string] $FoundationTestConfiguration = "debug",
180+
[parameter(ParameterSetName = "LocalCaching")]
173181
[string] $Cache = "",
174182
[switch] $Summary,
175183
[switch] $ToBatch
@@ -1290,14 +1298,14 @@ function Build-CMakeProject {
12901298

12911299
if ($UseMSVCCompilers.Contains("C")) {
12921300
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER cl
1293-
if ($EnableCaching) {
1301+
if ($EnableCaching -or $EnableRemoteCaching) {
12941302
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_LAUNCHER sccache
12951303
}
12961304
Add-FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
12971305
}
12981306
if ($UseMSVCCompilers.Contains("CXX")) {
12991307
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER cl
1300-
if ($EnableCaching) {
1308+
if ($EnableCaching -or $EnableRemoteCaching) {
13011309
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
13021310
}
13031311
Add-FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -3155,7 +3163,7 @@ if ($Clean) {
31553163
}
31563164

31573165
if (-not $SkipBuild) {
3158-
if ($EnableCaching -And (-Not (Test-SCCacheAtLeast -Major 0 -Minor 7 -Patch 4))) {
3166+
if ($EnableCaching -or $EnableRemoteCaching) -And (-Not (Test-SCCacheAtLeast -Major 0 -Minor 7 -Patch 4))) {
31593167
throw "Minimum required sccache version is 0.7.4"
31603168
}
31613169

0 commit comments

Comments
 (0)