@@ -158,6 +158,10 @@ param
158158 [ValidatePattern (' ^\d+(\.\d+)*$' )]
159159 [string ] $SCCacheVersion = " 0.10.0" ,
160160
161+ # Build with CAS
162+ [switch ] $EnableCAS = $false ,
163+ [string ] $CASPath = " $ImageRoot \cas" ,
164+
161165 # SBoM Support
162166 [switch ] $IncludeSBoM = $false ,
163167 [string ] $SyftVersion = " 1.29.1" ,
@@ -560,6 +564,10 @@ if (-not $PinnedBuild) {
560564
561565$PinnedToolchain = [IO.Path ]::GetFileNameWithoutExtension($PinnedBuild )
562566
567+ if ($EnableCAS -and ($UseHostToolchain -or ($PinnedVersion -ne " 0.0.0" ))) {
568+ throw " CAS currently requires using a main-branch pinned toolchain."
569+ }
570+
563571$HostPlatform = switch ($HostArchName ) {
564572 " AMD64" { $KnownPlatforms [$HostOS.ToString () + " X64" ] }
565573 " ARM64" { $KnownPlatforms [$HostOS.ToString () + " ARM64" ] }
@@ -1569,6 +1577,14 @@ function Build-CMakeProject {
15691577 @ (" /GS-" , " /Gw" , " /Gy" , " /Oy" , " /Oi" , " /Zc:inline" )
15701578 }
15711579
1580+ if ($EnableCAS -and $UsePinnedCompilers.Contains (" C" )) {
1581+ $CFLAGS += if ($UseGNUDriver ) {
1582+ @ (" -fdepscan=inline" , " -fdepscan-include-tree" , " -Xclang" , " -fcas-path" , " -Xclang" , $CASPath )
1583+ } else {
1584+ @ (" /clang:-fdepscan=inline" , " /clang:-fdepscan-include-tree" , " -Xclang" , " -fcas-path" , " -Xclang" , $CASPath )
1585+ }
1586+ }
1587+
15721588 if ($DebugInfo ) {
15731589 if ($UsePinnedCompilers.Contains (" C" ) -or $UseBuiltCompilers.Contains (" C" )) {
15741590 if ($CDebugFormat -eq " dwarf" ) {
@@ -1609,6 +1625,14 @@ function Build-CMakeProject {
16091625 @ (" /GS-" , " /Gw" , " /Gy" , " /Oy" , " /Oi" , " /Zc:inline" , " /Zc:__cplusplus" )
16101626 }
16111627
1628+ if ($EnableCAS -and $UsePinnedCompilers.Contains (" CXX" )) {
1629+ $CXXFLAGS += if ($UseGNUDriver ) {
1630+ @ (" -fdepscan=inline" , " -fdepscan-include-tree" , " -Xclang" , " -fcas-path" , " -Xclang" , $CASPath )
1631+ } else {
1632+ @ (" /clang:-fdepscan=inline" , " /clang:-fdepscan-include-tree" , " -Xclang" , " -fcas-path" , " -Xclang" , $CASPath )
1633+ }
1634+ }
1635+
16121636 if ($DebugInfo ) {
16131637 if ($UsePinnedCompilers.Contains (" CXX" ) -or $UseBuiltCompilers.Contains (" CXX" )) {
16141638 if ($CDebugFormat -eq " dwarf" ) {
@@ -2156,6 +2180,12 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
21562180 $SwiftFlags += @ (" -use-ld=lld" );
21572181 }
21582182
2183+ $CMakeStaticLibPrefixSwiftDefine = if ((Get-PinnedToolchainVersion ) -eq " 0.0.0" ) {
2184+ @ { CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ; }
2185+ } else {
2186+ @ {}
2187+ }
2188+
21592189 return $TestDefines + $DebugDefines + @ {
21602190 CLANG_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " clang-tblgen.exe" );
21612191 CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path - Path $BuildTools - ChildPath " clang-tidy-confusable-chars-gen.exe" );
@@ -2207,7 +2237,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
22072237 SWIFT_STDLIB_ASSERTIONS = " NO" ;
22082238 SWIFTSYNTAX_ENABLE_ASSERTIONS = " NO" ;
22092239 " cmark-gfm_DIR" = " $ ( $Platform.ToolchainInstallRoot ) \usr\lib\cmake" ;
2210- }
2240+ } + $CMakeStaticLibPrefixSwiftDefine
22112241}
22122242
22132243function Build-Compilers ([Hashtable ] $Platform , [string ] $Variant ) {
0 commit comments