Skip to content

Commit c44c098

Browse files
committed
utils: enable early swift driver on Windows
This wires up the build of the swift-driver via SPM from the pinned toolchain to allow us the use of the early swift driver in the Swift build.
1 parent 358fdac commit c44c098

File tree

1 file changed

+48
-23
lines changed

1 file changed

+48
-23
lines changed

utils/build.ps1

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
433433
}
434434

435435
enum HostComponent {
436-
Compilers = 5
436+
Compilers = 9
437437
FoundationMacros = 10
438438
TestingMacros
439439
System
@@ -466,6 +466,7 @@ function Get-HostProjectCMakeModules([HostComponent]$Project) {
466466

467467
enum BuildComponent {
468468
BuildTools
469+
Driver
469470
Compilers
470471
FoundationMacros
471472
TestingMacros
@@ -1454,6 +1455,7 @@ function Build-Compilers() {
14541455
Python3_ROOT_DIR = "$BinaryCache\Python$($Arch.CMakeName)-$PythonVersion\tools";
14551456
SWIFT_BUILD_SWIFT_SYNTAX = "YES";
14561457
SWIFT_CLANG_LOCATION = (Get-PinnedToolchainTool);
1458+
SWIFT_EARLY_SWIFT_DRIVER_BUILD = "$(Get-BuildProjectBinaryCache Driver)\$($BuildArch.LLVMTarget)\release";
14571459
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES";
14581460
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES";
14591461
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = "YES";
@@ -2217,29 +2219,51 @@ function Build-ArgumentParser($Arch) {
22172219
}
22182220
}
22192221

2220-
function Build-Driver($Arch) {
2221-
Build-CMakeProject `
2222-
-Src $SourceCache\swift-driver `
2223-
-Bin (Get-HostProjectBinaryCache Driver) `
2224-
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
2225-
-Arch $Arch `
2226-
-Platform Windows `
2227-
-UseBuiltCompilers C,CXX,Swift `
2228-
-SwiftSDK (Get-HostSwiftSDK) `
2229-
-Defines @{
2230-
BUILD_SHARED_LIBS = "YES";
2231-
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
2232-
TSC_DIR = (Get-HostProjectCMakeModules ToolsSupportCore);
2233-
LLBuild_DIR = (Get-HostProjectCMakeModules LLBuild);
2234-
Yams_DIR = (Get-HostProjectCMakeModules Yams);
2235-
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
2236-
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
2237-
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
2238-
SWIFT_DRIVER_BUILD_TOOLS = "YES";
2239-
LLVM_DIR = "$(Get-HostProjectBinaryCache Compilers)\lib\cmake\llvm";
2240-
Clang_DIR = "$(Get-HostProjectBinaryCache Compilers)\lib\cmake\clang";
2241-
Swift_DIR = "$(Get-HostProjectBinaryCache Compilers)\tools\swift\lib\cmake\swift";
2222+
function Build-Driver() {
2223+
[CmdletBinding(PositionalBinding = $false)]
2224+
param
2225+
(
2226+
[Parameter(Position = 0, Mandatory = $true)]
2227+
[hashtable]$Arch,
2228+
[switch] $Build = $false
2229+
)
2230+
2231+
if ($Build) {
2232+
Isolate-EnvVars {
2233+
$env:SWIFTCI_USE_LOCAL_DEPS=1
2234+
$env:SDKROOT = (Get-PinnedToolchainSDK)
2235+
$env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainTool);${env:Path}"
2236+
Invoke-Program `
2237+
"$(Get-PinnedToolchainTool)\swift.exe" build `
2238+
-c release `
2239+
--scratch-path (Get-BuildProjectBinaryCache Driver) `
2240+
--package-path $SourceCache\swift-driver `
2241+
-Xlinker "$(Get-PinnedToolchainSDK)\usr\lib\swift\windows\$($BuildArch.LLVMName)\swiftCore.lib"
22422242
}
2243+
} else {
2244+
Build-CMakeProject `
2245+
-Src $SourceCache\swift-driver `
2246+
-Bin (Get-HostProjectBinaryCache Driver) `
2247+
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
2248+
-Arch $Arch `
2249+
-Platform Windows `
2250+
-UseBuiltCompilers C,CXX,Swift `
2251+
-SwiftSDK (Get-HostSwiftSDK) `
2252+
-Defines @{
2253+
BUILD_SHARED_LIBS = "YES";
2254+
SwiftSystem_DIR = (Get-HostProjectCMakeModules System);
2255+
TSC_DIR = (Get-HostProjectCMakeModules ToolsSupportCore);
2256+
LLBuild_DIR = (Get-HostProjectCMakeModules LLBuild);
2257+
Yams_DIR = (Get-HostProjectCMakeModules Yams);
2258+
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
2259+
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
2260+
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
2261+
SWIFT_DRIVER_BUILD_TOOLS = "YES";
2262+
LLVM_DIR = "$(Get-HostProjectBinaryCache Compilers)\lib\cmake\llvm";
2263+
Clang_DIR = "$(Get-HostProjectBinaryCache Compilers)\lib\cmake\clang";
2264+
Swift_DIR = "$(Get-HostProjectBinaryCache Compilers)\tools\swift\lib\cmake\swift";
2265+
}
2266+
}
22432267
}
22442268

22452269
function Build-Crypto($Arch) {
@@ -2593,6 +2617,7 @@ Fetch-Dependencies
25932617
if (-not $SkipBuild) {
25942618
Invoke-BuildStep Build-CMark $BuildArch
25952619
Invoke-BuildStep Build-BuildTools $BuildArch
2620+
Invoke-BuildStep Build-Driver -Build $BuildArch
25962621
if ($IsCrossCompiling) {
25972622
Invoke-BuildStep Build-Compilers -Build $BuildArch
25982623
}

0 commit comments

Comments
 (0)