From 0bf97dabb440293e8f776284a3a5145d6a89a916 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 6 Feb 2024 09:19:59 -0800 Subject: [PATCH] build: setup a CMake based build for DocC In local testing, this helps reduce the overall build times 7-8%. Stage the build conversion to allow us to measure the time savings on CI hosts. --- utils/build.ps1 | 56 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 0e2cd50243642..c2ecf609e68a1 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1717,6 +1717,45 @@ function Build-SourceKitLSP($Arch) { } } +function Build-LMDB($Arch) { + Build-CMakeProject ` + -Src $SourceCache\swift-lmdb ` + -Bin $BinaryCache\17 ` + -Arch $Arch ` + -UseMSVCCompilers C ` + -BuildTargets default +} + +function Build-SymbolKit($Arch) { + Build-CMakeProject ` + -Src $SourceCache\swift-docc-symbolkit ` + -Bin $BinaryCache\18 ` + -Arch $Arch ` + -UseBuiltCompilers Swift ` + -SwiftSDK $SDKInstallRoot ` + -BuildTargets default +} + +function Build-DocC($Arch) { + Build-CMakeProject ` + -Src $SourceCache\swift-docc ` + -Bin $BinaryCache\19 ` + -InstallTo "$($Arch.ToolchainInstallRoot)\usr" ` + -Arch $Arch ` + -UseBuiltCompilers Swift ` + -UseSwiftSwiftDriver ` + -SwiftSDK $SDKInstallRoot ` + -BuildTargets default ` + -Defines @{ + ArgumentParser_DIR = "$BinaryCache\6\cmake\modules"; + SwiftCrypto_DIR = "$BinaryCache\8\cmake\modules"; + SwiftMarkdown_DIR = "$BinaryCache\13\cmake\modules"; + LMDB_DIR = "$BinaryCache\17\cmake\modules"; + SymbolKit_DIR = "$BinaryCache\18\cmake\modules"; + "cmark-gfm_DIR" = "$($Arch.ToolchainInstallRoot)\usr\lib\cmake"; + } +} + function Install-HostToolchain() { if ($ToBatch) { return } @@ -1749,19 +1788,6 @@ function Build-Inspect() { } } -function Build-DocC() { - $OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-docc - - Isolate-EnvVars { - $env:SWIFTCI_USE_LOCAL_DEPS=1 - Build-SPMProject ` - -Src $SourceCache\swift-docc ` - -Bin $OutDir ` - -Arch $HostArch ` - --product docc - } -} - function Test-PackageManager() { $OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-package-manager $SrcDir = if (Test-Path -Path "$SourceCache\swift-package-manager" -PathType Container) { @@ -1896,13 +1922,15 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-Format $HostArch Invoke-BuildStep Build-IndexStoreDB $HostArch Invoke-BuildStep Build-SourceKitLSP $HostArch + Invoke-BuildStep Build-LMDB $HostArch + Invoke-BuildStep Build-SymbolKit $HostArch + Invoke-BuildStep Build-DocC $HostArch } Install-HostToolchain if (-not $SkipBuild) { Invoke-BuildStep Build-Inspect $HostArch - Invoke-BuildStep Build-DocC $HostArch } if (-not $SkipPackaging) {