@@ -218,7 +218,7 @@ if ($AndroidSDKs.Length -gt 0) {
218
218
219
219
if ($Test -contains " *" ) {
220
220
# Explicitly don't include llbuild yet since tests are known to fail on Windows
221
- $Test = @ (" swift" , " dispatch" , " foundation" , " xctest" )
221
+ $Test = @ (" swift" , " dispatch" , " foundation" , " xctest" , " swift-format " )
222
222
}
223
223
224
224
# Architecture definitions
@@ -1216,6 +1216,8 @@ function Build-SPMProject {
1216
1216
[string ] $Src ,
1217
1217
[string ] $Bin ,
1218
1218
[hashtable ] $Arch ,
1219
+ [hashtable ] $AdditionalEnv = @ {},
1220
+ [string ] $InstallExe = " " ,
1219
1221
[switch ] $Test = $false ,
1220
1222
[Parameter (ValueFromRemainingArguments )]
1221
1223
[string []] $AdditionalArguments
@@ -1237,6 +1239,10 @@ function Build-SPMProject {
1237
1239
$env: Path = " $RuntimeInstallRoot \usr\bin;$ ( $HostArch.ToolchainInstallRoot ) \usr\bin;${env: Path} "
1238
1240
$env: SDKROOT = $SDKInstallRoot
1239
1241
1242
+ foreach ($Var in $AdditionalEnv.GetEnumerator ()) {
1243
+ New-Item - Path " env:\$ ( $Var.Key ) " - Value $Var.Value - ErrorAction Ignore | Out-Null
1244
+ }
1245
+
1240
1246
$Arguments = @ (
1241
1247
" --scratch-path" , $Bin ,
1242
1248
" --package-path" , $Src ,
@@ -1258,6 +1264,14 @@ function Build-SPMProject {
1258
1264
1259
1265
$Action = if ($Test ) { " test" } else { " build" }
1260
1266
Invoke-Program " $ ( $HostArch.ToolchainInstallRoot ) \usr\bin\swift.exe" $Action @Arguments @AdditionalArguments
1267
+
1268
+ if ($InstallExe -ne " " ) {
1269
+ $BinPath = (Invoke-Program " $ ( $HostArch.ToolchainInstallRoot ) \usr\bin\swift.exe" build @Arguments -- show-bin - path)
1270
+ $ExecPath = Join-Path - Path $BinPath - ChildPath $InstallExe
1271
+ $InstallDestination = " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1272
+ Write-Host " Installing $ ( $ExecPath ) to $ ( $InstallDestination ) "
1273
+ Copy-Item - Path $ExecPath - Destination $InstallDestination
1274
+ }
1261
1275
}
1262
1276
1263
1277
if (-not $ToBatch ) {
@@ -2348,23 +2362,45 @@ function Build-Markdown($Arch) {
2348
2362
}
2349
2363
}
2350
2364
2351
- function Build-Format ($Arch ) {
2352
- Build-CMakeProject `
2353
- - Src $SourceCache \swift- format `
2354
- - Bin (Get-HostProjectBinaryCache Format) `
2355
- - InstallTo " $ ( $Arch.ToolchainInstallRoot ) \usr" `
2356
- - Arch $Arch `
2357
- - Platform Windows `
2358
- - UseMSVCCompilers C `
2359
- - UseBuiltCompilers Swift `
2360
- - SwiftSDK (Get-HostSwiftSDK ) `
2361
- - Defines @ {
2362
- BUILD_SHARED_LIBS = " YES" ;
2363
- ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
2364
- SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
2365
- SwiftMarkdown_DIR = (Get-HostProjectCMakeModules Markdown);
2366
- " cmark-gfm_DIR" = " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmake" ;
2367
- }
2365
+ function Build-Format () {
2366
+ [CmdletBinding (PositionalBinding = $false )]
2367
+ param
2368
+ (
2369
+ [hashtable ]$Arch ,
2370
+ [switch ] $Test
2371
+ )
2372
+
2373
+ $SwiftPMArguments = @ (
2374
+ # swift-syntax
2375
+ " -Xswiftc" , " -I$ ( Get-HostProjectBinaryCache Compilers) \lib\swift\host" ,
2376
+ " -Xlinker" , " -I$ ( Get-HostProjectBinaryCache Compilers) \lib\swift\host" ,
2377
+ # swift-argument-parser
2378
+ " -Xswiftc" , " -I$ ( Get-HostProjectBinaryCache ArgumentParser) \swift" ,
2379
+ " -Xlinker" , " -L$ ( Get-HostProjectBinaryCache ArgumentParser) \lib" ,
2380
+ # swift-cmark
2381
+ " -Xswiftc" , " -I$ ( $Arch.ToolchainInstallRoot ) \usr\include\cmark_gfm" ,
2382
+ " -Xswiftc" , " -I$ ( $Arch.ToolchainInstallRoot ) \usr\include\cmark_gfm_extensions" ,
2383
+ " -Xlinker" , " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmark-gfm.lib" ,
2384
+ " -Xlinker" , " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmark-gfm-extensions.lib" ,
2385
+ # swift-markdown
2386
+ " -Xlinker" , " $ ( Get-HostProjectBinaryCache Markdown) \lib\CAtomic.lib" ,
2387
+ " -Xswiftc" , " -I$ ( $SourceCache ) \swift-markdown\Sources\CAtomic\include" ,
2388
+ " -Xswiftc" , " -I$ ( Get-HostProjectBinaryCache Markdown) \swift" ,
2389
+ " -Xlinker" , " -L$ ( Get-HostProjectBinaryCache Markdown) \lib"
2390
+ )
2391
+
2392
+ $Options = @ {
2393
+ Src = " $SourceCache \swift-format"
2394
+ Bin = (Get-HostProjectBinaryCache Format)
2395
+ Arch = $Arch
2396
+ Test = $Test
2397
+ InstallExe = If ($Test ) { " " } Else { " swift-format.exe" }
2398
+ }
2399
+
2400
+ Isolate- EnvVars {
2401
+ $env: SWIFTFORMAT_OMIT_EXTERNAL_DEPENDENCIES = 1
2402
+ Build-SPMProject @Options @SwiftPMArguments
2403
+ }
2368
2404
}
2369
2405
2370
2406
function Build-IndexStoreDB ($Arch ) {
@@ -2687,7 +2723,7 @@ if (-not $SkipBuild) {
2687
2723
Invoke-BuildStep Build-Certificates $HostArch
2688
2724
Invoke-BuildStep Build-PackageManager $HostArch
2689
2725
Invoke-BuildStep Build-Markdown $HostArch
2690
- Invoke-BuildStep Build-Format $HostArch
2726
+ Invoke-BuildStep Build-Format - Arch $HostArch
2691
2727
Invoke-BuildStep Build-IndexStoreDB $HostArch
2692
2728
Invoke-BuildStep Build-SourceKitLSP $HostArch
2693
2729
}
@@ -2737,6 +2773,7 @@ if (-not $IsCrossCompiling) {
2737
2773
}
2738
2774
if ($Test -contains " llbuild" ) { Build-LLBuild $HostArch - Test }
2739
2775
if ($Test -contains " swiftpm" ) { Test-PackageManager $HostArch }
2776
+ if ($Test -contains " swift-format" ) { Build-Format - Arch $HostArch - Test }
2740
2777
}
2741
2778
2742
2779
# Custom exception printing for more detailed exception information
0 commit comments