@@ -829,11 +829,16 @@ function Fetch-Dependencies {
829
829
}
830
830
}
831
831
832
- function Get-PinnedToolchainTool () {
832
+ function Get-PinnedToolchainTool ([ string ] $Name ) {
833
833
if (Test-Path " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin" ) {
834
- return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
834
+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
835
+ } else {
836
+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
837
+ }
838
+ if ($Name ) {
839
+ $Path = " $Path \$Name "
835
840
}
836
- return " $BinaryCache \toolchains\ ${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin "
841
+ return $Path
837
842
}
838
843
839
844
function Get-PinnedToolchainSDK () {
@@ -864,6 +869,10 @@ $CompilersBinaryCache = if ($IsCrossCompiling) {
864
869
Get-HostProjectBinaryCache Compilers
865
870
}
866
871
872
+ function Get-BuiltToolchainTool ([string ] $Name ) {
873
+ return if ($Name ) { " $CompilersBinaryCache \bin\$Name " } else { " $CompilersBinaryCache \bin" }
874
+ }
875
+
867
876
function Get-ClangDriverName ([Platform ] $Platform , [string ] $Lang ) {
868
877
switch ($Platform ) {
869
878
Windows {
@@ -1032,7 +1041,7 @@ function Build-CMakeProject {
1032
1041
# Use a built lld linker as the Android's NDK linker might be too
1033
1042
# old and not support all required relocations needed by the Swift
1034
1043
# runtime.
1035
- $ldPath = ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " ld.lld" ) )
1044
+ $ldPath = (Get-BuiltToolchainTool " ld.lld" )
1036
1045
Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " --ld-path=$ldPath "
1037
1046
Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " --ld-path=$ldPath "
1038
1047
}
@@ -1055,9 +1064,9 @@ function Build-CMakeProject {
1055
1064
if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
1056
1065
$Driver = (Get-ClangDriverName $Platform - Lang " ASM" )
1057
1066
if ($UseBuiltCompilers.Contains (" ASM" )) {
1058
- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1067
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-BuiltToolchainTool $Driver )
1059
1068
} else {
1060
- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1069
+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-PinnedToolchainTool $Driver )
1061
1070
}
1062
1071
Append- FlagsDefine $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
1063
1072
if ($Platform -eq " Windows" ) {
@@ -1067,9 +1076,9 @@ function Build-CMakeProject {
1067
1076
if ($UsePinnedCompilers.Contains (" C" ) -Or $UseBuiltCompilers.Contains (" C" )) {
1068
1077
$Driver = (Get-ClangDriverName $Platform - Lang " C" )
1069
1078
if ($UseBuiltCompilers.Contains (" C" )) {
1070
- TryAdd- KeyValue $Defines CMAKE_C_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1079
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-BuiltToolchainTool $Driver )
1071
1080
} else {
1072
- TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1081
+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-PinnedToolchainTool $Driver )
1073
1082
}
1074
1083
TryAdd- KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
1075
1084
@@ -1086,9 +1095,9 @@ function Build-CMakeProject {
1086
1095
if ($UsePinnedCompilers.Contains (" CXX" ) -Or $UseBuiltCompilers.Contains (" CXX" )) {
1087
1096
$Driver = (Get-ClangDriverName $Platform - Lang " CXX" )
1088
1097
if ($UseBuiltCompilers.Contains (" CXX" )) {
1089
- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1098
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-BuiltToolchainTool $Driver )
1090
1099
} else {
1091
- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1100
+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-PinnedToolchainTool $Driver )
1092
1101
}
1093
1102
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
1094
1103
@@ -1108,9 +1117,9 @@ function Build-CMakeProject {
1108
1117
if ($UseSwiftSwiftDriver ) {
1109
1118
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([IO.Path ]::Combine($DriverBinaryCache , " bin" , " swiftc.exe" ))
1110
1119
} elseif ($UseBuiltCompilers.Contains (" Swift" )) {
1111
- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " swiftc.exe" ) )
1120
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-BuiltToolchainTool " swiftc.exe" )
1112
1121
} else {
1113
- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" )
1122
+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-PinnedToolchainTool " swiftc.exe" )
1114
1123
}
1115
1124
if (-not ($Platform -eq " Windows" )) {
1116
1125
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_WORKS = " YES"
0 commit comments