@@ -800,11 +800,16 @@ function Fetch-Dependencies {
800
800
}
801
801
}
802
802
803
- function Get-PinnedToolchainTool () {
803
+ function Get-PinnedToolchainTool ([ string ] $Name ) {
804
804
if (Test-Path " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin" ) {
805
- return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
805
+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
806
+ } else {
807
+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
808
+ }
809
+ if ($Name ) {
810
+ $Path = " $Path \$Name "
806
811
}
807
- return " $BinaryCache \toolchains\ ${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin "
812
+ return $Path
808
813
}
809
814
810
815
function Get-PinnedToolchainSDK () {
@@ -835,6 +840,10 @@ $CompilersBinaryCache = if ($IsCrossCompiling) {
835
840
Get-HostProjectBinaryCache Compilers
836
841
}
837
842
843
+ function Get-BuiltToolchainTool ([string ] $Name ) {
844
+ return if ($Name ) { " $CompilersBinaryCache \bin\$Name " } else { " $CompilersBinaryCache \bin" }
845
+ }
846
+
838
847
function Get-ClangDriverName ([Platform ] $Platform , [string ] $Lang ) {
839
848
switch ($Platform ) {
840
849
Windows {
@@ -1004,7 +1013,7 @@ function Build-CMakeProject {
1004
1013
# Use a built lld linker as the Android's NDK linker might be too
1005
1014
# old and not support all required relocations needed by the Swift
1006
1015
# runtime.
1007
- $ldPath = ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " ld.lld" ) )
1016
+ $ldPath = (Get-BuiltToolchainTool " ld.lld" )
1008
1017
Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " --ld-path=$ldPath "
1009
1018
Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " --ld-path=$ldPath "
1010
1019
}
@@ -1027,9 +1036,9 @@ function Build-CMakeProject {
1027
1036
if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
1028
1037
$Driver = (Get-ClangDriverName $Platform - Lang " ASM" )
1029
1038
if ($UseBuiltCompilers.Contains (" ASM" )) {
1030
- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1039
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-BuiltToolchainTool $Driver )
1031
1040
} else {
1032
- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1041
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-PinnedToolchainTool $Driver )
1033
1042
}
1034
1043
Append- FlagsDefine $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
1035
1044
if ($Platform -eq " Windows" ) {
@@ -1039,9 +1048,9 @@ function Build-CMakeProject {
1039
1048
if ($UsePinnedCompilers.Contains (" C" ) -Or $UseBuiltCompilers.Contains (" C" )) {
1040
1049
$Driver = (Get-ClangDriverName $Platform - Lang " C" )
1041
1050
if ($UseBuiltCompilers.Contains (" C" )) {
1042
- TryAdd- KeyValue $Defines CMAKE_C_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1051
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-BuiltToolchainTool $Driver )
1043
1052
} else {
1044
- TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1053
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-PinnedToolchainTool $Driver )
1045
1054
}
1046
1055
TryAdd- KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
1047
1056
@@ -1058,9 +1067,9 @@ function Build-CMakeProject {
1058
1067
if ($UsePinnedCompilers.Contains (" CXX" ) -Or $UseBuiltCompilers.Contains (" CXX" )) {
1059
1068
$Driver = (Get-ClangDriverName $Platform - Lang " CXX" )
1060
1069
if ($UseBuiltCompilers.Contains (" CXX" )) {
1061
- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1070
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-BuiltToolchainTool $Driver )
1062
1071
} else {
1063
- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1072
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-PinnedToolchainTool $Driver )
1064
1073
}
1065
1074
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
1066
1075
@@ -1080,9 +1089,9 @@ function Build-CMakeProject {
1080
1089
if ($UseSwiftSwiftDriver ) {
1081
1090
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([IO.Path ]::Combine($DriverBinaryCache , " bin" , " swiftc.exe" ))
1082
1091
} elseif ($UseBuiltCompilers.Contains (" Swift" )) {
1083
- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " swiftc.exe" ) )
1092
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-BuiltToolchainTool " swiftc.exe" )
1084
1093
} else {
1085
- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" )
1094
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-PinnedToolchainTool " swiftc.exe" )
1086
1095
}
1087
1096
if (-not ($Platform -eq " Windows" )) {
1088
1097
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_WORKS = " YES"
0 commit comments