Skip to content

Commit dde5842

Browse files
committed
build: migrate to CMake based build of swift-format
This allows us to build swift-format with dynamic linking against the toolchain build of the swift-syntax and swift-argument-parser packages. Wire up the swift-markdown build and hoist the swift-format build prior to sourcekit-lsp. This sets us up for supporting swift-format based formatting in the LSP.
1 parent d5c134f commit dde5842

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

utils/build.ps1

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,11 @@ function Build-CMark($Arch) {
849849
Build-CMakeProject `
850850
-Src $SourceCache\cmark `
851851
-Bin "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13" `
852-
-InstallTo "$LibraryRoot\cmark-0.29.0.gfm.13\usr" `
852+
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
853853
-Arch $Arch `
854854
-BuildTargets default `
855855
-Defines @{
856-
BUILD_SHARED_LIBS = "NO";
856+
BUILD_SHARED_LIBS = "YES";
857857
BUILD_TESTING = "NO";
858858
CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP = "YES";
859859
}
@@ -1602,10 +1602,45 @@ function Build-PackageManager($Arch) {
16021602
}
16031603
}
16041604

1605+
function Build-Markdown($Arch) {
1606+
Build-CMakeProject `
1607+
-Src $SourceCache\swift-markdown `
1608+
-Bin $BinaryCache\13 `
1609+
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
1610+
-Arch $Arch `
1611+
-UseBuiltCompilers Swift `
1612+
-SwiftSDK $SDKInstallRoot `
1613+
-BuildTargets default `
1614+
-Defines @{
1615+
BUILD_SHARED_LIBS = "NO";
1616+
ArgumentParser_DIR = "$BinaryCache\6\cmake\modules";
1617+
"cmark-gfm_DIR" = "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13";
1618+
}
1619+
}
1620+
1621+
function Build-Format($Arch) {
1622+
Build-CMakeProject `
1623+
-Src $SourceCache\swift-format `
1624+
-Bin $BinaryCache\14 `
1625+
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
1626+
-Arch $Arch `
1627+
-UseMSVCCompilers C `
1628+
-UseBuiltCompilers Swift `
1629+
-SwiftSDK $SDKInstallRoot `
1630+
-BuildTargets default `
1631+
-Defines @{
1632+
BUILD_SHARED_LIBS = "YES";
1633+
ArgumentParser_DIR = "$BinaryCache\6\cmake\modules";
1634+
SwiftSyntax_DIR = "$BinaryCache\1\cmake\modules";
1635+
"cmark-gfm_DIR" = "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13";
1636+
SwiftMarkdown_DIR = "$BinaryCache\13\cmake\modules";
1637+
}
1638+
}
1639+
16051640
function Build-IndexStoreDB($Arch) {
16061641
Build-CMakeProject `
16071642
-Src $SourceCache\indexstore-db `
1608-
-Bin $BinaryCache\13 `
1643+
-Bin $BinaryCache\15 `
16091644
-Arch $Arch `
16101645
-UseBuiltCompilers C,CXX,Swift `
16111646
-SwiftSDK $SDKInstallRoot `
@@ -1620,7 +1655,7 @@ function Build-IndexStoreDB($Arch) {
16201655
function Build-SourceKitLSP($Arch) {
16211656
Build-CMakeProject `
16221657
-Src $SourceCache\sourcekit-lsp `
1623-
-Bin $BinaryCache\14 `
1658+
-Bin $BinaryCache\16 `
16241659
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
16251660
-Arch $Arch `
16261661
-UseBuiltCompilers C,Swift `
@@ -1635,7 +1670,7 @@ function Build-SourceKitLSP($Arch) {
16351670
SwiftCrypto_DIR = "$BinaryCache\8\cmake\modules";
16361671
SwiftCollections_DIR = "$BinaryCache\9\cmake\modules";
16371672
SwiftPM_DIR = "$BinaryCache\12\cmake\modules";
1638-
IndexStoreDB_DIR = "$BinaryCache\13\cmake\modules";
1673+
IndexStoreDB_DIR = "$BinaryCache\15\cmake\modules";
16391674
}
16401675
}
16411676

@@ -1671,18 +1706,6 @@ function Build-Inspect() {
16711706
}
16721707
}
16731708

1674-
function Build-Format() {
1675-
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-format
1676-
1677-
Isolate-EnvVars {
1678-
$env:SWIFTCI_USE_LOCAL_DEPS=1
1679-
Build-SPMProject `
1680-
-Src $SourceCache\swift-format `
1681-
-Bin $OutDir `
1682-
-Arch $HostArch
1683-
}
1684-
}
1685-
16861709
function Build-DocC() {
16871710
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-docc
16881711

@@ -1801,6 +1824,8 @@ if (-not $SkipBuild) {
18011824
Invoke-BuildStep Build-ASN1 $HostArch
18021825
Invoke-BuildStep Build-Certificates $HostArch
18031826
Invoke-BuildStep Build-PackageManager $HostArch
1827+
Invoke-BuildStep Build-Markdown $HostArch
1828+
Invoke-BuildStep Build-Format $HostArch
18041829
Invoke-BuildStep Build-IndexStoreDB $HostArch
18051830
Invoke-BuildStep Build-SourceKitLSP $HostArch
18061831
}
@@ -1809,7 +1834,6 @@ Install-HostToolchain
18091834

18101835
if (-not $SkipBuild) {
18111836
Invoke-BuildStep Build-Inspect $HostArch
1812-
Invoke-BuildStep Build-Format $HostArch
18131837
Invoke-BuildStep Build-DocC $HostArch
18141838
}
18151839

0 commit comments

Comments
 (0)