@@ -26,9 +26,6 @@ The path to a directory that mimics a file system image root,
26
26
under which "Library" and "Program Files" subdirectories will be created
27
27
with the files installed by CMake.
28
28
29
- . PARAMETER BuildType
30
- The CMake build type to use, one of: Release, RelWithDebInfo, Debug.
31
-
32
29
. PARAMETER CDebugFormat
33
30
The debug information format for C/C++ code: dwarf or codeview.
34
31
@@ -62,6 +59,12 @@ If set, skips building the msi's and installer
62
59
. PARAMETER DefaultsLLD
63
60
If false, use `link.exe` as the default linker with the SDK (with SPM)
64
61
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
+
65
68
. PARAMETER Test
66
69
An array of names of projects to run tests for.
67
70
'*' runs all tests
88
91
[string ] $SourceCache = " S:\SourceCache" ,
89
92
[string ] $BinaryCache = " S:\b" ,
90
93
[string ] $ImageRoot = " S:" ,
91
- [string ] $BuildType = " Release" ,
92
94
[string ] $CDebugFormat = " dwarf" ,
93
95
[string ] $SwiftDebugFormat = " dwarf" ,
94
96
[string []] $SDKs = @ (" X64" , " X86" , " Arm64" ),
@@ -103,6 +105,8 @@ param(
103
105
[string []] $Test = @ (),
104
106
[string ] $Stage = " " ,
105
107
[string ] $BuildTo = " " ,
108
+ [switch ] $DebugInfo ,
109
+ [switch ] $EnableCaching ,
106
110
[switch ] $ToBatch
107
111
)
108
112
@@ -528,21 +532,30 @@ function Build-CMakeProject {
528
532
# Add additional defines (unless already present)
529
533
$Defines = $Defines.Clone ()
530
534
531
- TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
535
+ TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE Release
532
536
TryAdd- KeyValue $Defines CMAKE_MT " mt"
533
537
534
- $GenerateDebugInfo = $Defines [" CMAKE_BUILD_TYPE" ] -ne " Release"
535
-
536
538
$CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
537
- if ($GenerateDebugInfo ) { $CFlags += " / Zi" }
539
+ if ($DebugInfo ) { $CFlags += if ( $EnableCaching ) { " /Z7 " } else { " / Zi" } }
538
540
$CXXFlags = $CFlags.Clone () + " /Zc:__cplusplus"
539
541
542
+ if ($EnableCaching ) {
543
+ $env: SCCACHE_DIRECT = " true"
544
+ $env: SCCACHE_DIR = " $BinaryCache \sccache"
545
+ }
546
+
540
547
if ($UseMSVCCompilers.Contains (" C" )) {
541
548
TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
549
+ if ($EnableCaching ) {
550
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER_LAUNCHER sccache
551
+ }
542
552
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
543
553
}
544
554
if ($UseMSVCCompilers.Contains (" CXX" )) {
545
555
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER cl
556
+ if ($EnableCaching ) {
557
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
558
+ }
546
559
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
547
560
}
548
561
if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
@@ -567,7 +580,7 @@ function Build-CMakeProject {
567
580
TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
568
581
}
569
582
570
- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
583
+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
571
584
Append- FlagsDefine $Defines CMAKE_C_FLAGS " -gdwarf"
572
585
}
573
586
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
@@ -585,7 +598,7 @@ function Build-CMakeProject {
585
598
TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
586
599
}
587
600
588
- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
601
+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
589
602
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS " -gdwarf"
590
603
}
591
604
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -615,7 +628,7 @@ function Build-CMakeProject {
615
628
}
616
629
617
630
# Debug Information
618
- if ($GenerateDebugInfo ) {
631
+ if ($DebugInfo ) {
619
632
if ($SwiftDebugFormat -eq " dwarf" ) {
620
633
$SwiftArgs += @ (" -g" , " -Xlinker" , " /DEBUG:DWARF" , " -use-ld=lld-link" )
621
634
} else {
@@ -730,14 +743,14 @@ function Build-SPMProject {
730
743
" -Xcc" , " -I$SDKInstallRoot \usr\lib\swift" ,
731
744
" -Xlinker" , " -L$SDKInstallRoot \usr\lib\swift\windows"
732
745
)
733
- if ($BuildType -eq " Release" ) {
734
- $Arguments += @ (" -debug-info-format" , " none" )
735
- } else {
746
+ if ($DebugInfo ) {
736
747
if ($SwiftDebugFormat -eq " dwarf" ) {
737
748
$Arguments += @ (" -debug-info-format" , " dwarf" )
738
749
} else {
739
750
$Arguments += @ (" -debug-info-format" , " codeview" )
740
751
}
752
+ } else {
753
+ $Arguments += @ (" -debug-info-format" , " none" )
741
754
}
742
755
743
756
Invoke-Program " $ToolchainInstallRoot \usr\bin\swift.exe" " build" @Arguments @AdditionalArguments
@@ -798,6 +811,7 @@ function Build-BuildTools($Arch) {
798
811
- Src $SourceCache \llvm- project\llvm `
799
812
- Bin $BinaryCache \0 `
800
813
- Arch $Arch `
814
+ - UseMSVCCompilers C, CXX `
801
815
- 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 `
802
816
- Defines @ {
803
817
LLDB_ENABLE_PYTHON = " NO" ;
@@ -845,11 +859,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
845
859
846
860
$env: Path = " $BinaryCache \toolchains\$PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin;${env: Path} "
847
861
848
- $LLVM_ENABLE_PDB = switch ($BuildType ) {
849
- " Release" { " NO" }
850
- default { " YES" }
851
- }
852
-
853
862
Build-CMakeProject `
854
863
- Src $SourceCache \llvm- project\llvm `
855
864
- Bin $BinaryCache \1 `
@@ -860,10 +869,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
860
869
- Defines ($TestingDefines + @ {
861
870
CLANG_TABLEGEN = " $BinaryCache \0\bin\clang-tblgen.exe" ;
862
871
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" ;
867
872
CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
868
873
CMAKE_Swift_COMPILER = " $BinaryCache \toolchains\$PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe" ;
869
874
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) {
872
877
LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
873
878
LLDB_TABLEGEN = " $BinaryCache \0\bin\lldb-tblgen.exe" ;
874
879
LLVM_CONFIG_PATH = " $BinaryCache \0\bin\llvm-config.exe" ;
875
- LLVM_ENABLE_PDB = $LLVM_ENABLE_PDB ;
876
880
LLVM_EXTERNAL_CMARK_SOURCE_DIR = " $SourceCache \cmark" ;
877
881
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
878
882
LLVM_NATIVE_TOOL_DIR = " $BinaryCache \0\bin" ;
0 commit comments