@@ -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
8891 [string ] $SourceCache = " S:\SourceCache" ,
8992 [string ] $BinaryCache = " S:\b" ,
9093 [string ] $ImageRoot = " S:" ,
91- [string ] $BuildType = " Release" ,
9294 [string ] $CDebugFormat = " dwarf" ,
9395 [string ] $SwiftDebugFormat = " dwarf" ,
9496 [string []] $SDKs = @ (" X64" , " X86" , " Arm64" ),
@@ -103,6 +105,8 @@ param(
103105 [string []] $Test = @ (),
104106 [string ] $Stage = " " ,
105107 [string ] $BuildTo = " " ,
108+ [switch ] $DebugInfo ,
109+ [switch ] $EnableCaching ,
106110 [switch ] $ToBatch
107111)
108112
@@ -528,21 +532,30 @@ function Build-CMakeProject {
528532 # Add additional defines (unless already present)
529533 $Defines = $Defines.Clone ()
530534
531- TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
535+ TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE Release
532536 TryAdd- KeyValue $Defines CMAKE_MT " mt"
533537
534- $GenerateDebugInfo = $Defines [" CMAKE_BUILD_TYPE" ] -ne " Release"
535-
536538 $CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
537- if ($GenerateDebugInfo ) { $CFlags += " / Zi" }
539+ if ($DebugInfo ) { $CFlags += if ( $EnableCaching ) { " /Z7 " } else { " / Zi" } }
538540 $CXXFlags = $CFlags.Clone () + " /Zc:__cplusplus"
539541
542+ if ($EnableCaching ) {
543+ $env: SCCACHE_DIRECT = " true"
544+ $env: SCCACHE_DIR = " $BinaryCache \sccache"
545+ }
546+
540547 if ($UseMSVCCompilers.Contains (" C" )) {
541548 TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
549+ if ($EnableCaching ) {
550+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER_LAUNCHER sccache
551+ }
542552 Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
543553 }
544554 if ($UseMSVCCompilers.Contains (" CXX" )) {
545555 TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER cl
556+ if ($EnableCaching ) {
557+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
558+ }
546559 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
547560 }
548561 if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
@@ -567,7 +580,7 @@ function Build-CMakeProject {
567580 TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
568581 }
569582
570- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
583+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
571584 Append- FlagsDefine $Defines CMAKE_C_FLAGS " -gdwarf"
572585 }
573586 Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
@@ -585,7 +598,7 @@ function Build-CMakeProject {
585598 TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
586599 }
587600
588- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
601+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
589602 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS " -gdwarf"
590603 }
591604 Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -615,7 +628,7 @@ function Build-CMakeProject {
615628 }
616629
617630 # Debug Information
618- if ($GenerateDebugInfo ) {
631+ if ($DebugInfo ) {
619632 if ($SwiftDebugFormat -eq " dwarf" ) {
620633 $SwiftArgs += @ (" -g" , " -Xlinker" , " /DEBUG:DWARF" , " -use-ld=lld-link" )
621634 } else {
@@ -730,14 +743,14 @@ function Build-SPMProject {
730743 " -Xcc" , " -I$SDKInstallRoot \usr\lib\swift" ,
731744 " -Xlinker" , " -L$SDKInstallRoot \usr\lib\swift\windows"
732745 )
733- if ($BuildType -eq " Release" ) {
734- $Arguments += @ (" -debug-info-format" , " none" )
735- } else {
746+ if ($DebugInfo ) {
736747 if ($SwiftDebugFormat -eq " dwarf" ) {
737748 $Arguments += @ (" -debug-info-format" , " dwarf" )
738749 } else {
739750 $Arguments += @ (" -debug-info-format" , " codeview" )
740751 }
752+ } else {
753+ $Arguments += @ (" -debug-info-format" , " none" )
741754 }
742755
743756 Invoke-Program " $ToolchainInstallRoot \usr\bin\swift.exe" " build" @Arguments @AdditionalArguments
@@ -798,6 +811,7 @@ function Build-BuildTools($Arch) {
798811 - Src $SourceCache \llvm- project\llvm `
799812 - Bin $BinaryCache \0 `
800813 - Arch $Arch `
814+ - UseMSVCCompilers C, CXX `
801815 - 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 `
802816 - Defines @ {
803817 LLDB_ENABLE_PYTHON = " NO" ;
@@ -845,11 +859,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
845859
846860 $env: Path = " $BinaryCache \toolchains\$PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin;${env: Path} "
847861
848- $LLVM_ENABLE_PDB = switch ($BuildType ) {
849- " Release" { " NO" }
850- default { " YES" }
851- }
852-
853862 Build-CMakeProject `
854863 - Src $SourceCache \llvm- project\llvm `
855864 - Bin $BinaryCache \1 `
@@ -860,10 +869,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
860869 - Defines ($TestingDefines + @ {
861870 CLANG_TABLEGEN = " $BinaryCache \0\bin\clang-tblgen.exe" ;
862871 CLANG_TIDY_CONFUSABLE_CHARS_GEN = " $BinaryCache \0\bin\clang-tidy-confusable-chars-gen.exe" ;
863- # LLVM plays tricks with flags and prefers to use `LLVM_ENABLE_PDB` for
864- # debug information on Windows rather than the CMake handling. This
865- # give us a sligtly faster build.
866- CMAKE_BUILD_TYPE = " Release" ;
867872 CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
868873 CMAKE_Swift_COMPILER = " $BinaryCache \toolchains\$PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe" ;
869874 CMAKE_Swift_FLAGS = @ (" -sdk" , " $BinaryCache \toolchains\$PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" );
@@ -872,7 +877,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
872877 LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
873878 LLDB_TABLEGEN = " $BinaryCache \0\bin\lldb-tblgen.exe" ;
874879 LLVM_CONFIG_PATH = " $BinaryCache \0\bin\llvm-config.exe" ;
875- LLVM_ENABLE_PDB = $LLVM_ENABLE_PDB ;
876880 LLVM_EXTERNAL_CMARK_SOURCE_DIR = " $SourceCache \cmark" ;
877881 LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
878882 LLVM_NATIVE_TOOL_DIR = " $BinaryCache \0\bin" ;
0 commit comments