@@ -16,7 +16,8 @@ $PlatformInstallRoot = "$InstallRoot\Developer\Platforms\Windows.platform"
16
16
$SDKInstallRoot = " $PlatformInstallRoot \Developer\SDKs\Windows.sdk"
17
17
18
18
$vswhere = " ${Env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"
19
- $VSInstallRoot = .$vswhere - nologo - latest - products " *" - all - prerelease - property installationPath
19
+ $VSInstallRoot = & $vswhere - nologo - latest - products " *" - all - prerelease - property installationPath
20
+ $msbuild = " $VSInstallRoot \MSBuild\Current\Bin\$env: PROCESSOR_ARCHITECTURE \MSBuild.exe"
20
21
21
22
# Architecture definitions
22
23
$ArchX64 = @ {
@@ -81,6 +82,15 @@ function Get-ProjectBuildDir($Arch, $ID)
81
82
return " $BinaryCache \" + ($Arch.BuildID + $ID )
82
83
}
83
84
85
+ function Get-RuntimeInstallDir ($Arch , $SubDir = " " )
86
+ {
87
+ $Path = " $InstallRoot \swift-development\$ ( $Arch.ShortName ) "
88
+ if (" " -ne $SubDir ) {
89
+ $Path += " \$SubDir "
90
+ }
91
+ return $Path
92
+ }
93
+
84
94
function Check-LastExitCode
85
95
{
86
96
if ($LastExitCode -ne 0 )
@@ -102,11 +112,11 @@ function Invoke-VsDevShell($Arch)
102
112
Check- LastExitCode
103
113
}
104
114
105
- function TryAdd-Define ([hashtable ]$Defines , [string ]$Name , [string ]$Value )
115
+ function TryAdd-KeyValue ([hashtable ]$Hashtable , [string ]$Key , [string ]$Value )
106
116
{
107
- if (-not $Defines .Contains ($Name ))
117
+ if (-not $Hashtable .Contains ($Key ))
108
118
{
109
- $Defines .Add ($Name , $Value )
119
+ $Hashtable .Add ($Key , $Value )
110
120
}
111
121
}
112
122
@@ -152,39 +162,39 @@ function Build-CMakeProject
152
162
153
163
# Add additional defines (unless already present)
154
164
$Defines = $Defines.Clone ()
155
- TryAdd- Define $Defines CMAKE_BUILD_TYPE $BuildType
156
- TryAdd- Define $Defines CMAKE_MT " mt"
165
+ TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
166
+ TryAdd- KeyValue $Defines CMAKE_MT " mt"
157
167
158
168
$CFlags = " /GS- /Gw /Gy /Oi /Oy /Zi /Zc:inline"
159
169
$CXXFlags = " /GS- /Gw /Gy /Oi /Oy /Zi /Zc:inline /Zc:__cplusplus"
160
170
if ($UseMSVCCompilers.Contains (" C" ))
161
171
{
162
- TryAdd- Define $Defines CMAKE_C_COMPILER cl
172
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
163
173
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
164
174
}
165
175
if ($UseMSVCCompilers.Contains (" CXX" ))
166
176
{
167
- TryAdd- Define $Defines CMAKE_CXX_COMPILER cl
177
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER cl
168
178
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
169
179
}
170
180
if ($UseBuiltCompilers.Contains (" ASM" )) {
171
- TryAdd- Define $Defines CMAKE_ASM_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
181
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
172
182
Append- FlagsDefine $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
173
- TryAdd- Define $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL " /MD"
183
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL " /MD"
174
184
}
175
185
if ($UseBuiltCompilers.Contains (" C" )) {
176
- TryAdd- Define $Defines CMAKE_C_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
177
- TryAdd- Define $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
186
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
187
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
178
188
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
179
189
}
180
190
if ($UseBuiltCompilers.Contains (" CXX" )) {
181
- TryAdd- Define $Defines CMAKE_CXX_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
182
- TryAdd- Define $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
191
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
192
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
183
193
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
184
194
}
185
195
if ($UseBuiltCompilers.Contains (" Swift" )) {
186
- TryAdd- Define $Defines CMAKE_Swift_COMPILER S:/ b/ 1 / bin/ swiftc.exe
187
- TryAdd- Define $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
196
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER S:/ b/ 1 / bin/ swiftc.exe
197
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
188
198
189
199
$RuntimeBuildDir = Get-ProjectBuildDir $Arch 1
190
200
$SwiftResourceDir = " ${RuntimeBuildDir} \lib\swift"
@@ -202,7 +212,7 @@ function Build-CMakeProject
202
212
Append- FlagsDefine $Defines CMAKE_Swift_FLAGS $SwiftcFlags
203
213
}
204
214
if (" " -ne $InstallTo ) {
205
- TryAdd- Define $Defines CMAKE_INSTALL_PREFIX $InstallTo
215
+ TryAdd- KeyValue $Defines CMAKE_INSTALL_PREFIX $InstallTo
206
216
}
207
217
208
218
# Generate the project
@@ -240,6 +250,32 @@ function Build-CMakeProject
240
250
Write-Host " "
241
251
}
242
252
253
+ function Build-WiXProject ()
254
+ {
255
+ [CmdletBinding (PositionalBinding = $false )]
256
+ param (
257
+ [Parameter (Position = 0 )]
258
+ [string ]$FileName ,
259
+ [hashtable ]$Properties = @ {}
260
+ )
261
+
262
+ $Name = $FileName.Split (' .' )[0 ]
263
+
264
+ $Properties = $Properties.Clone ()
265
+ TryAdd- KeyValue $Properties RunWixToolsOutOfProc true
266
+ TryAdd- KeyValue $Properties OutputPath $BinaryCache \msi\
267
+ TryAdd- KeyValue $Properties IntermediateOutputPath BinaryCache\$Name \
268
+
269
+ $MSBuildArgs = @ (" $SourceCache \swift-installer-scripts\platforms\Windows\$FileName " )
270
+ $MSBuildArgs += " -noLogo"
271
+ foreach ($Property in $Properties.GetEnumerator ()) {
272
+ $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value ) "
273
+ }
274
+
275
+ & $msbuild @MSBuildArgs
276
+ Check- LastExitCode
277
+ }
278
+
243
279
function Build-Compilers ($Arch )
244
280
{
245
281
Build-CMakeProject `
@@ -415,6 +451,7 @@ function Build-Runtime($Arch)
415
451
- UseBuiltCompilers C, CXX `
416
452
- BuildDefaultTarget `
417
453
- Defines @ {
454
+ CMAKE_INSTALL_BINDIR = Get-RuntimeInstallDir $Arch " usr\bin" ;
418
455
LLVM_DIR = " $LLVMBuildDir \lib\cmake\llvm" ;
419
456
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
420
457
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = " YES" ;
@@ -426,13 +463,6 @@ function Build-Runtime($Arch)
426
463
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
427
464
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
428
465
}
429
-
430
- # Restructure runtime
431
- New-Item - ErrorAction Ignore - Type Directory `
432
- - Path $InstallRoot \swift- development\usr\bin\$ ($Arch.ShortName )
433
- Move-Item - Force `
434
- $SDKInstallRoot \usr\bin\* .dll `
435
- $InstallRoot \swift- development\usr\bin\$ ($Arch.ShortName )\
436
466
}
437
467
438
468
function Build-Dispatch ($Arch )
@@ -445,19 +475,13 @@ function Build-Dispatch($Arch)
445
475
- UseBuiltCompilers C, CXX, Swift `
446
476
- BuildDefaultTarget `
447
477
- Defines @ {
478
+ CMAKE_INSTALL_BINDIR = Get-RuntimeInstallDir $Arch " usr\bin" ;
448
479
CMAKE_SYSTEM_NAME = " Windows" ;
449
480
CMAKE_SYSTEM_PROCESSOR = $Arch.CMakeName ;
450
481
ENABLE_SWIFT = " YES" ;
451
482
BUILD_TESTING = " NO" ;
452
483
}
453
484
454
- # Restructure Runtime
455
- New-Item - ErrorAction Ignore - Type Directory `
456
- - Path $InstallRoot \swift- development\usr\bin\$ ($Arch.ShortName )
457
- Move-Item - Force `
458
- $SDKInstallRoot \usr\bin\* .dll `
459
- $InstallRoot \swift- development\usr\bin\$ ($Arch.ShortName )\
460
-
461
485
# Restructure BlocksRuntime, dispatch headers
462
486
foreach ($module in (" Block" , " dispatch" , " os" ))
463
487
{
@@ -500,6 +524,7 @@ function Build-Foundation($Arch)
500
524
- UseBuiltCompilers ASM, C, Swift `
501
525
- BuildDefaultTarget `
502
526
- Defines @ {
527
+ CMAKE_INSTALL_BINDIR = Get-RuntimeInstallDir $Arch " usr\bin" ;
503
528
CMAKE_SYSTEM_NAME = " Windows" ;
504
529
CMAKE_SYSTEM_PROCESSOR = $Arch.CMakeName ;
505
530
CURL_DIR = " $InstallRoot \curl-7.77.0\usr\lib\$ShortArch \cmake\CURL" ;
@@ -516,14 +541,6 @@ function Build-Foundation($Arch)
516
541
ENABLE_TESTING = " NO" ;
517
542
}
518
543
519
- # Restructure Runtime
520
- Move-Item - Force `
521
- $SDKInstallRoot \usr\bin\* .dll `
522
- $InstallRoot \swift- development\usr\bin\$ShortArch \
523
- Move-Item - Force `
524
- $SDKInstallRoot \usr\bin\* .exe `
525
- $InstallRoot \swift- development\usr\bin\$ShortArch \
526
-
527
544
# Remove CoreFoundation Headers
528
545
foreach ($module in (" CoreFoundation" , " CFXMLInterface" , " CFURLSessionInterface" ))
529
546
{
@@ -912,6 +929,36 @@ function Build-SourceKitLSP($Arch)
912
929
}
913
930
}
914
931
932
+ function Build-Installer ()
933
+ {
934
+ # Currently fails due to _InternalSwiftScan paths
935
+ # Build-WiXProject toolchain.wixproj -Properties @{
936
+ # DEVTOOLS_ROOT = "$ToolchainInstallRoot\";
937
+ # TOOLCHAIN_ROOT = "$ToolchainInstallRoot\";
938
+ # }
939
+
940
+ # TODO: The XCTest depends on the architecture
941
+ # Build-WiXProject sdk.wixproj -Properties @{
942
+ # PLATFORM_ROOT = "$PlatformInstallRoot\";
943
+ # SDK_ROOT = "$SDKInstallRoot\";
944
+ # SWIFT_SOURCE_DIR = "$SourceCache\swift\";
945
+ # }
946
+
947
+ Build-WiXProject runtime.wixproj - Properties @ {
948
+ SDK_ROOT = (Get-RuntimeInstallDir $ArchX64 ) + " \" ;
949
+ }
950
+
951
+ Build-WiXProject devtools.wixproj - Properties @ {
952
+ DEVTOOLS_ROOT = " $ToolchainInstallRoot \" ;
953
+ }
954
+
955
+ # TODO: The above wixprojs need to build
956
+ # Build-WiXProject installer.wixproj -Properties @{
957
+ # OutputPath = "$BinaryCache\";
958
+ # MSI_LOCATION = "$BinaryCache\msi\";
959
+ # }
960
+ }
961
+
915
962
# -------------------------------------------------------------------
916
963
917
964
Build-Compilers $HostArch
0 commit comments