Skip to content

Commit 6f92302

Browse files
authored
Merge pull request #79050 from andrurogerz/swift-inspect-android-on-windows
build swift-inspect for Android as part of toolchain build
2 parents c5f0200 + 63d29ff commit 6f92302

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

utils/build.ps1

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ enum TargetComponent {
425425
Testing
426426
ClangBuiltins
427427
ClangRuntime
428+
SwiftInspect
428429
}
429430

430431
function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
@@ -452,7 +453,6 @@ enum HostComponent {
452453
SourceKitLSP
453454
SymbolKit
454455
DocC
455-
SwiftInspect
456456
}
457457

458458
function Get-HostProjectBinaryCache([HostComponent]$Project) {
@@ -2879,19 +2879,34 @@ function Install-HostToolchain() {
28792879
Copy-Item -Force $SwiftDriver "$($HostArch.ToolchainInstallRoot)\usr\bin\swiftc.exe"
28802880
}
28812881

2882-
function Build-Inspect() {
2883-
$SDKRoot = Get-HostSwiftSDK
2882+
function Build-Inspect([Platform]$Platform, $Arch) {
2883+
if ($Arch -eq $HostArch) {
2884+
# When building for the host target, use the host version of the swift-argument-parser,
2885+
# and place the host swift-inspect executable with the other host toolchain binaries.
2886+
$ArgumentParserDir = Get-HostProjectCMakeModules ArgumentParser
2887+
$InstallPath = "$($HostArch.ToolchainInstallRoot)\usr"
2888+
} else {
2889+
# When building for non-host target, let CMake fetch the swift-argument-parser dependency
2890+
# since it is currently only built for the host and and cannot be built for Android until
2891+
# the pinned version is >= 1.5.0.
2892+
$ArgumentParserDir = ""
2893+
$InstallPath = "$($Arch.PlatformInstallRoot)\Developer\Library\$(Get-ModuleTriple $Arch)"
2894+
}
28842895

28852896
Build-CMakeProject `
28862897
-Src $SourceCache\swift\tools\swift-inspect `
2887-
-Bin (Get-HostProjectBinaryCache SwiftInspect) `
2888-
-InstallTo "$($HostArch.ToolchainInstallRoot)\usr" `
2889-
-Arch $HostArch `
2898+
-Bin (Get-TargetProjectBinaryCache $Arch SwiftInspect)`
2899+
-InstallTo $InstallPath `
2900+
-Arch $Arch `
2901+
-Platform $Platform `
28902902
-UseBuiltCompilers C,CXX,Swift `
2891-
-SwiftSDK $SDKRoot `
2903+
-SwiftSDK $Arch.SDKInstallRoot `
28922904
-Defines @{
2893-
CMAKE_Swift_FLAGS = @("-Xcc", "-I$SDKRoot\usr\include\swift\SwiftRemoteMirror");
2894-
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
2905+
CMAKE_Swift_FLAGS = @(
2906+
"-Xcc", "-I$($Arch.SDKInstallRoot)\usr\lib\swift",
2907+
"-Xcc", "-I$($Arch.SDKInstallRoot)\usr\include\swift\SwiftRemoteMirror",
2908+
"-L$($Arch.SDKInstallRoot)\usr\lib\swift\$Platform");
2909+
ArgumentParser_DIR = $ArgumentParserDir;
28952910
}
28962911
}
28972912

@@ -3053,6 +3068,12 @@ if (-not $SkipBuild) {
30533068
Invoke-BuildStep Build-Sanitizers Android $Arch
30543069
Invoke-BuildStep Build-XCTest Android $Arch
30553070
Invoke-BuildStep Build-Testing Android $Arch
3071+
3072+
# Android swift-inspect only supports 64-bit platforms.
3073+
if ($Arch.AndroidArchABI -eq "arm64-v8a" -or
3074+
$Arch.AndroidArchABI -eq "x86_64") {
3075+
Invoke-BuildStep Build-Inspect -Platform Android -Arch $Arch
3076+
}
30563077
Invoke-BuildStep Write-SDKSettingsPlist Android $Arch
30573078
Invoke-BuildStep Write-PlatformInfoPlist $Arch
30583079
}
@@ -3097,7 +3118,7 @@ if (-not $SkipBuild) {
30973118
Invoke-BuildStep Build-LMDB $HostArch
30983119
Invoke-BuildStep Build-IndexStoreDB $HostArch
30993120
Invoke-BuildStep Build-SourceKitLSP $HostArch
3100-
Invoke-BuildStep Build-Inspect $HostArch
3121+
Invoke-BuildStep Build-Inspect Windows $HostArch
31013122
}
31023123

31033124
Install-HostToolchain

0 commit comments

Comments
 (0)