Skip to content

Commit 54fd5c2

Browse files
compnerdbnbarham
authored andcommitted
utils: use CMake to build swift-inspect for Windows
This switches us to use CMake to build swift-inspect. In doing so, we can now cross-compile this tool. Due to the use of CMake, we now have install rules for the products, which allows the toolchain deployment and simpler rules in the installer. (cherry picked from commit c72246c)
1 parent 8cc20a5 commit 54fd5c2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

utils/build.ps1

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ enum HostComponent {
454454
LMDB
455455
SymbolKit
456456
DocC
457+
SwiftInspect
457458
}
458459

459460
function Get-HostProjectBinaryCache([HostComponent]$Project) {
@@ -2636,18 +2637,20 @@ function Install-HostToolchain() {
26362637
}
26372638

26382639
function Build-Inspect() {
2639-
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-inspect
2640-
$SDKInstallRoot = (Get-HostSwiftSDK) `
2640+
$SDKRoot = Get-HostSwiftSDK
26412641

2642-
Isolate-EnvVars {
2643-
$env:SWIFTCI_USE_LOCAL_DEPS=1
2644-
Build-SPMProject `
2645-
-Action Build `
2646-
-Src $SourceCache\swift\tools\swift-inspect `
2647-
-Bin $OutDir `
2648-
-Arch $HostArch `
2649-
-Xcc "-I$SDKInstallRoot\usr\include\swift\SwiftRemoteMirror" -Xlinker "$SDKInstallRoot\usr\lib\swift\windows\$($HostArch.LLVMName)\swiftRemoteMirror.lib"
2650-
}
2642+
Build-CMakeProject `
2643+
-Src $SourceCache\swift\tools\swift-inspect `
2644+
-Bin (Get-HostProjectBinaryCache SwiftInspect) `
2645+
-InstallTo "$($HostArch.ToolchainInstallRoot)\usr" `
2646+
-Arch $HostArch `
2647+
-UseBuiltCompilers Swift `
2648+
-UseSwiftSwiftDriver `
2649+
-SwiftSDK $SDKRoot `
2650+
-Defines @{
2651+
CMAKE_Swift_FLAGS = @("-Xcc", "-I$SDKRoot\usr\include\swift\SwiftRemoteMirror");
2652+
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
2653+
}
26512654
}
26522655

26532656
function Build-DocC() {
@@ -2686,18 +2689,15 @@ function Test-PackageManager() {
26862689
function Build-Installer($Arch) {
26872690
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
26882691
# when cross-compiling https://github.com/apple/swift/issues/71655
2689-
$INCLUDE_SWIFT_INSPECT = if ($IsCrossCompiling) { "false" } else { "true" }
26902692
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling) { "false" } else { "true" }
26912693
$ENABLE_MIMALLOC = if ($Allocator -eq "mimalloc" -and $Arch -eq $ArchX64) { "true" } else { "false" }
26922694

26932695
$Properties = @{
26942696
BundleFlavor = "offline";
26952697
DEVTOOLS_ROOT = "$($Arch.ToolchainInstallRoot)\";
26962698
TOOLCHAIN_ROOT = "$($Arch.ToolchainInstallRoot)\";
2697-
INCLUDE_SWIFT_INSPECT = $INCLUDE_SWIFT_INSPECT;
2698-
SWIFT_INSPECT_BUILD = "$($Arch.BinaryCache)\swift-inspect\release";
2699-
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC;
27002699
ENABLE_MIMALLOC = $ENABLE_MIMALLOC;
2700+
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC;
27012701
SWIFT_DOCC_BUILD = "$($Arch.BinaryCache)\swift-docc\release";
27022702
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact";
27032703
}

0 commit comments

Comments
 (0)