@@ -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
91
94
[string ] $SourceCache = " S:\SourceCache" ,
92
95
[string ] $BinaryCache = " S:\b" ,
93
96
[string ] $ImageRoot = " S:" ,
94
- [string ] $BuildType = " Release" ,
95
97
[string ] $CDebugFormat = " dwarf" ,
96
98
[string ] $SwiftDebugFormat = " dwarf" ,
97
99
[string []] $SDKs = @ (" X64" , " X86" , " Arm64" ),
@@ -106,6 +108,8 @@ param(
106
108
[string []] $Test = @ (),
107
109
[string ] $Stage = " " ,
108
110
[string ] $BuildTo = " " ,
111
+ [switch ] $DebugInfo ,
112
+ [switch ] $EnableCaching ,
109
113
[switch ] $ToBatch ,
110
114
[string ] $PinnedLayout = " old"
111
115
)
@@ -577,21 +581,30 @@ function Build-CMakeProject {
577
581
# Add additional defines (unless already present)
578
582
$Defines = $Defines.Clone ()
579
583
580
- TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
584
+ TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE Release
581
585
TryAdd- KeyValue $Defines CMAKE_MT " mt"
582
586
583
- $GenerateDebugInfo = $Defines [" CMAKE_BUILD_TYPE" ] -ne " Release"
584
-
585
587
$CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
586
- if ($GenerateDebugInfo ) { $CFlags += " / Zi" }
588
+ if ($DebugInfo ) { $CFlags += if ( $EnableCaching ) { " /Z7 " } else { " / Zi" } }
587
589
$CXXFlags = $CFlags.Clone () + " /Zc:__cplusplus"
588
590
591
+ if ($EnableCaching ) {
592
+ $env: SCCACHE_DIRECT = " true"
593
+ $env: SCCACHE_DIR = " $BinaryCache \sccache"
594
+ }
595
+
589
596
if ($UseMSVCCompilers.Contains (" C" )) {
590
597
TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
598
+ if ($EnableCaching ) {
599
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER_LAUNCHER sccache
600
+ }
591
601
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
592
602
}
593
603
if ($UseMSVCCompilers.Contains (" CXX" )) {
594
604
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER cl
605
+ if ($EnableCaching ) {
606
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_LAUNCHER sccache
607
+ }
595
608
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
596
609
}
597
610
if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
@@ -616,7 +629,7 @@ function Build-CMakeProject {
616
629
TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
617
630
}
618
631
619
- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
632
+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
620
633
Append- FlagsDefine $Defines CMAKE_C_FLAGS " -gdwarf"
621
634
}
622
635
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
@@ -634,7 +647,7 @@ function Build-CMakeProject {
634
647
TryAdd- KeyValue $Defines CMAKE_CL_SHOWINCLUDES_PREFIX " Note: including file: "
635
648
}
636
649
637
- if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf" ) {
650
+ if ($DebugInfo -and $CDebugFormat -eq " dwarf" ) {
638
651
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS " -gdwarf"
639
652
}
640
653
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -664,7 +677,7 @@ function Build-CMakeProject {
664
677
}
665
678
666
679
# Debug Information
667
- if ($GenerateDebugInfo ) {
680
+ if ($DebugInfo ) {
668
681
if ($SwiftDebugFormat -eq " dwarf" ) {
669
682
$SwiftArgs += @ (" -g" , " -Xlinker" , " /DEBUG:DWARF" , " -use-ld=lld-link" )
670
683
} else {
@@ -779,14 +792,14 @@ function Build-SPMProject {
779
792
" -Xcc" , " -I$SDKInstallRoot \usr\lib\swift" ,
780
793
" -Xlinker" , " -L$SDKInstallRoot \usr\lib\swift\windows"
781
794
)
782
- if ($BuildType -eq " Release" ) {
783
- $Arguments += @ (" -debug-info-format" , " none" )
784
- } else {
795
+ if ($DebugInfo ) {
785
796
if ($SwiftDebugFormat -eq " dwarf" ) {
786
797
$Arguments += @ (" -debug-info-format" , " dwarf" )
787
798
} else {
788
799
$Arguments += @ (" -debug-info-format" , " codeview" )
789
800
}
801
+ } else {
802
+ $Arguments += @ (" -debug-info-format" , " none" )
790
803
}
791
804
792
805
Invoke-Program " $ToolchainInstallRoot \usr\bin\swift.exe" " build" @Arguments @AdditionalArguments
@@ -847,6 +860,7 @@ function Build-BuildTools($Arch) {
847
860
- Src $SourceCache \llvm- project\llvm `
848
861
- Bin $BinaryCache \0 `
849
862
- Arch $Arch `
863
+ - UseMSVCCompilers C, CXX `
850
864
- 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 `
851
865
- Defines @ {
852
866
LLDB_ENABLE_PYTHON = " NO" ;
@@ -898,11 +912,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
898
912
899
913
$env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
900
914
901
- $LLVM_ENABLE_PDB = switch ($BuildType ) {
902
- " Release" { " NO" }
903
- default { " YES" }
904
- }
905
-
906
915
Build-CMakeProject `
907
916
- Src $SourceCache \llvm- project\llvm `
908
917
- Bin $BinaryCache \1 `
@@ -913,10 +922,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
913
922
- Defines ($TestingDefines + @ {
914
923
CLANG_TABLEGEN = " $BinaryCache \0\bin\clang-tblgen.exe" ;
915
924
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" ;
920
925
CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
921
926
CMAKE_Swift_COMPILER = (Join-Path - Path (Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" );
922
927
CMAKE_Swift_FLAGS = @ (" -sdk" , (Get-PinnedToolchainSDK ));
@@ -925,7 +930,6 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
925
930
LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
926
931
LLDB_TABLEGEN = " $BinaryCache \0\bin\lldb-tblgen.exe" ;
927
932
LLVM_CONFIG_PATH = " $BinaryCache \0\bin\llvm-config.exe" ;
928
- LLVM_ENABLE_PDB = $LLVM_ENABLE_PDB ;
929
933
LLVM_EXTERNAL_CMARK_SOURCE_DIR = " $SourceCache \cmark" ;
930
934
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
931
935
LLVM_NATIVE_TOOL_DIR = " $BinaryCache \0\bin" ;
0 commit comments