Skip to content

Commit d93d742

Browse files
authored
Merge pull request #71410 from compnerd/driver-driver
utils: add support to use the swift-driver as the driver
2 parents 78cf572 + 5953d87 commit d93d742

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

utils/build.ps1

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ function Build-CMakeProject {
554554
[string[]] $UseMSVCCompilers = @(), # C,CXX
555555
[string[]] $UseBuiltCompilers = @(), # ASM,C,CXX,Swift
556556
[string[]] $UsePinnedCompilers = @(), # ASM,C,CXX,Swift
557+
[switch] $UseSwiftSwiftDriver = $false,
557558
[string] $SwiftSDK = "",
558559
[hashtable] $Defines = @{}, # Values are either single strings or arrays of flags
559560
[string[]] $BuildTargets = @()
@@ -573,6 +574,19 @@ function Build-CMakeProject {
573574
Isolate-EnvVars {
574575
Invoke-VsDevShell $Arch
575576

577+
if ($EnableCaching) {
578+
$env:SCCACHE_DIRECT = "true"
579+
$env:SCCACHE_DIR = "$BinaryCache\sccache"
580+
}
581+
if ($UseSwiftSwiftDriver) {
582+
$env:SWIFT_DRIVER_SWIFT_FRONTEND_EXEC = "$BinaryCache\1\bin\swift-frontend.exe"
583+
}
584+
585+
# TODO(compnerd) workaround swiftc.exe symlink not existing.
586+
if ($UseSwiftSwiftDriver) {
587+
Copy-Item -Force "$BinaryCache\7\bin\swift-driver.exe" "$BinaryCache\7\bin\swiftc.exe" | Out-Null
588+
}
589+
576590
# Add additional defines (unless already present)
577591
$Defines = $Defines.Clone()
578592

@@ -593,11 +607,6 @@ function Build-CMakeProject {
593607
}
594608
$CXXFlags = $CFlags.Clone() + "/Zc:__cplusplus"
595609

596-
if ($EnableCaching) {
597-
$env:SCCACHE_DIRECT = "true"
598-
$env:SCCACHE_DIR = "$BinaryCache\sccache"
599-
}
600-
601610
if ($UseMSVCCompilers.Contains("C")) {
602611
TryAdd-KeyValue $Defines CMAKE_C_COMPILER cl
603612
if ($EnableCaching) {
@@ -660,7 +669,9 @@ function Build-CMakeProject {
660669
if ($UsePinnedCompilers.Contains("Swift") -Or $UseBuiltCompilers.Contains("Swift")) {
661670
$SwiftArgs = @()
662671

663-
if ($UseBuiltCompilers.Contains("Swift")) {
672+
if ($UseSwiftSwiftDriver) {
673+
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER "$BinaryCache\7\bin\swiftc.exe"
674+
} elseif ($UseBuiltCompilers.Contains("Swift")) {
664675
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER "$BinaryCache\1\bin\swiftc.exe"
665676
} else {
666677
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path -Path (Get-PinnedToolchainTool) -ChildPath "swiftc.exe")

0 commit comments

Comments
 (0)