@@ -26,9 +26,6 @@ The path to a directory that mimics a file system image root,
2626under which "Library" and "Program Files" subdirectories will be created
2727with the files installed by CMake.
2828
29- . PARAMETER BuildType
30- The CMake build type to use, one of: Release, RelWithDebInfo, Debug.
31-
3229. PARAMETER CDebugFormat
3330The debug information format for C/C++ code: dwarf or codeview.
3431
@@ -62,6 +59,12 @@ If set, skips building the msi's and installer
6259. PARAMETER DefaultsLLD
6360If false, use `link.exe` as the default linker with the SDK (with SPM)
6461
62+ . PARAMETER DebugInfo
63+ If set, debug information will be generated for the builds.
64+
65+ . PARAMETER EnableCaching
66+ If true, use `sccache` to cache the build rules.
67+
6568. PARAMETER Test
6669An array of names of projects to run tests for.
6770'*' runs all tests
9194 [string ] $SourceCache = " S:\SourceCache" ,
9295 [string ] $BinaryCache = " S:\b" ,
9396 [string ] $ImageRoot = " S:" ,
94- [string ] $BuildType = " Release" ,
9597 [string ] $CDebugFormat = " dwarf" ,
9698 [string ] $SwiftDebugFormat = " dwarf" ,
9799 [string []] $SDKs = @ (" X64" , " X86" , " Arm64" ),
@@ -106,6 +108,8 @@ param(
106108 [string []] $Test = @ (),
107109 [string ] $Stage = " " ,
108110 [string ] $BuildTo = " " ,
111+ [switch ] $DebugInfo ,
112+ [switch ] $EnableCaching ,
109113 [switch ] $ToBatch ,
110114 [string ] $PinnedLayout = " old"
111115)
@@ -577,21 +581,30 @@ function Build-CMakeProject {
577581 # Add additional defines (unless already present)
578582 $Defines = $Defines.Clone ()
579583
580- TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
584+ TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE Release
581585 TryAdd- KeyValue $Defines CMAKE_MT " mt"
582586
583- $GenerateDebugInfo = $Defines [" CMAKE_BUILD_TYPE" ] -ne " Release"
584-
585587 $CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
586- if ($GenerateDebugInfo ) { $CFlags += " / Zi" }
588+ if ($DebugInfo ) { $CFlags += if ( $EnableCaching ) { " /Z7 " } else { " / Zi" } }
587589 $CXXFlags = $CFlags.Clone () + " /Zc:__cplusplus"
588590
591+ if ($EnableCaching ) {
592+ $env: SCCACHE_DIRECT = " true"
593+ $env: SCCACHE_DIR = " $BinaryCache \sccache"
594+ }
595+
589596 if ($UseMSVCCompilers.Contains (" C" )) {
590597 TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
598+ if ($EnableCaching ) {
599+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER_LAUNCHER sccache
600+ }
591601 Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
592602 }
593603 if ($UseMSVCCompilers.Contains (" CXX" )) {
594604 TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER cl
605+ if ($EnableCaching ) {
606+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
607+ }
595608 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
596609 }
597610 if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
@@ -616,7 +629,7 @@ function Build-CMakeProject {
616629 TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
617630 }
618631
619- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
632+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
620633 Append- FlagsDefine $Defines CMAKE_C_FLAGS " -gdwarf"
621634 }
622635 Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
@@ -634,7 +647,7 @@ function Build-CMakeProject {
634647 TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
635648 }
636649
637- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
650+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
638651 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS " -gdwarf"
639652 }
640653 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -664,7 +677,7 @@ function Build-CMakeProject {
664677 }
665678
666679 # Debug Information
667- if ($GenerateDebugInfo ) {
680+ if ($DebugInfo ) {
668681 if ($SwiftDebugFormat -eq " dwarf" ) {
669682 $SwiftArgs += @ (" -g" , " -Xlinker" , " /DEBUG:DWARF" , " -use-ld=lld-link" )
670683 } else {
@@ -779,14 +792,14 @@ function Build-SPMProject {
779792 " -Xcc" , " -I$SDKInstallRoot \usr\lib\swift" ,
780793 " -Xlinker" , " -L$SDKInstallRoot \usr\lib\swift\windows"
781794 )
782- if ($BuildType -eq " Release" ) {
783- $Arguments += @ (" -debug-info-format" , " none" )
784- } else {
795+ if ($DebugInfo ) {
785796 if ($SwiftDebugFormat -eq " dwarf" ) {
786797 $Arguments += @ (" -debug-info-format" , " dwarf" )
787798 } else {
788799 $Arguments += @ (" -debug-info-format" , " codeview" )
789800 }
801+ } else {
802+ $Arguments += @ (" -debug-info-format" , " none" )
790803 }
791804
792805 Invoke-Program " $ToolchainInstallRoot \usr\bin\swift.exe" " build" @Arguments @AdditionalArguments
@@ -847,6 +860,7 @@ function Build-BuildTools($Arch) {
847860 - Src $SourceCache \llvm- project\llvm `
848861 - Bin $BinaryCache \0 `
849862 - Arch $Arch `
863+ - UseMSVCCompilers C, CXX `
850864 - BuildTargets llvm- tblgen, clang- tblgen, clang- pseudo- gen, clang- tidy- confusable- chars- gen, lldb- tblgen, llvm- config, swift- def- to- strings- converter, swift- serialize- diagnostics, swift- compatibility- symbols `
851865 - Defines @ {
852866 LLDB_ENABLE_PYTHON = " NO" ;
@@ -898,11 +912,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
898912
899913 $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
900914
901- $LLVM_ENABLE_PDB = switch ($BuildType ) {
902- " Release" { " NO" }
903- default { " YES" }
904- }
905-
906915 Build-CMakeProject `
907916 - Src $SourceCache \llvm- project\llvm `
908917 - Bin $BinaryCache \1 `
@@ -913,10 +922,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
913922 - Defines ($TestingDefines + @ {
914923 CLANG_TABLEGEN = " $BinaryCache \0\bin\clang-tblgen.exe" ;
915924 CLANG_TIDY_CONFUSABLE_CHARS_GEN = " $BinaryCache \0\bin\clang-tidy-confusable-chars-gen.exe" ;
916- # LLVM plays tricks with flags and prefers to use `LLVM_ENABLE_PDB` for
917- # debug information on Windows rather than the CMake handling. This
918- # give us a sligtly faster build.
919- CMAKE_BUILD_TYPE = " Release" ;
920925 CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
921926 CMAKE_Swift_COMPILER = (Join-Path - Path (Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" );
922927 CMAKE_Swift_FLAGS = @ (" -sdk" , (Get-PinnedToolchainSDK ));
@@ -925,7 +930,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
925930 LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
926931 LLDB_TABLEGEN = " $BinaryCache \0\bin\lldb-tblgen.exe" ;
927932 LLVM_CONFIG_PATH = " $BinaryCache \0\bin\llvm-config.exe" ;
928- LLVM_ENABLE_PDB = $LLVM_ENABLE_PDB ;
929933 LLVM_EXTERNAL_CMARK_SOURCE_DIR = " $SourceCache \cmark" ;
930934 LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
931935 LLVM_NATIVE_TOOL_DIR = " $BinaryCache \0\bin" ;
0 commit comments