@@ -570,12 +570,18 @@ function Test-CMakeAtLeast([int]$Major, [int]$Minor, [int]$Patch = 0) {
570
570
return [int ]$Matches.3 -ge $Patch
571
571
}
572
572
573
+ enum Platform {
574
+ Windows
575
+ Android
576
+ }
577
+
573
578
function Build-CMakeProject {
574
579
[CmdletBinding (PositionalBinding = $false )]
575
580
param (
576
581
[string ] $Src ,
577
582
[string ] $Bin ,
578
583
[string ] $InstallTo = " " ,
584
+ [Platform ] $Platform = " Windows" ,
579
585
[hashtable ] $Arch ,
580
586
[string ] $Generator = " Ninja" ,
581
587
[string ] $CacheScript = " " ,
@@ -600,7 +606,9 @@ function Build-CMakeProject {
600
606
# Enter the developer command shell early so we can resolve cmake.exe
601
607
# for version checks.
602
608
Isolate- EnvVars {
603
- Invoke-VsDevShell $Arch
609
+ if ($Platform -eq " Windows" ) {
610
+ Invoke-VsDevShell $Arch
611
+ }
604
612
605
613
$CompilersBinaryCache = Get-HostProjectBinaryCache Compilers
606
614
$DriverBinaryCache = Get-HostProjectBinaryCache Driver
@@ -624,7 +632,16 @@ function Build-CMakeProject {
624
632
TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE Release
625
633
TryAdd- KeyValue $Defines CMAKE_MT " mt"
626
634
627
- $CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
635
+ $CFlags = @ ()
636
+ if ($Platform -eq " Windows" ) {
637
+ $CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
638
+ }
639
+
640
+ $CXXFlags = @ ()
641
+ if ($Platform -eq " Windows" ) {
642
+ $CXXFlags += $CFlags.Clone () + @ (" /Zc:__cplusplus" )
643
+ }
644
+
628
645
if ($UseMSVCCompilers.Contains (" C" ) -Or $UseMSVCCompilers.Contains (" CXX" ) -Or
629
646
$UseBuiltCompilers.Contains (" C" ) -Or $UseBuiltCompilers.Contains (" CXX" ) -Or
630
647
$UsePinnedCompilers.Contains (" C" ) -Or $UsePinnedCompilers.Contains (" CXX" )) {
@@ -636,7 +653,6 @@ function Build-CMakeProject {
636
653
Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " /debug"
637
654
}
638
655
}
639
- $CXXFlags = $CFlags.Clone () + " /Zc:__cplusplus"
640
656
641
657
if ($UseMSVCCompilers.Contains (" C" )) {
642
658
TryAdd- KeyValue $Defines CMAKE_C_COMPILER cl
@@ -809,8 +825,8 @@ function Build-CMakeProject {
809
825
if ($Summary ) {
810
826
$TimingData.Add ([PSCustomObject ]@ {
811
827
Arch = $Arch.LLVMName
828
+ Platform = $Platform
812
829
Checkout = $Src.Replace ($SourceCache , ' ' )
813
- BuildID = Split-Path - Path $Bin - Leaf
814
830
" Elapsed Time" = $Stopwatch.Elapsed.ToString ()
815
831
})
816
832
}
@@ -875,7 +891,7 @@ function Build-SPMProject {
875
891
$TimingData.Add ([PSCustomObject ]@ {
876
892
Arch = $Arch.LLVMName
877
893
Checkout = $Src.Replace ($SourceCache , ' ' )
878
- BuildID = Split-Path - Path $Bin - Leaf
894
+ Platform = " Windows "
879
895
" Elapsed Time" = $Stopwatch.Elapsed.ToString ()
880
896
})
881
897
}
@@ -1060,16 +1076,14 @@ function Build-Compilers() {
1060
1076
}
1061
1077
}
1062
1078
1063
- enum Platform {
1064
- Windows
1065
- }
1066
-
1067
1079
function Build-LLVM ([Platform ]$Platform , $Arch ) {
1068
1080
Build-CMakeProject `
1069
1081
- Src $SourceCache \llvm- project\llvm `
1070
1082
- Bin (Get-TargetProjectBinaryCache $Arch LLVM) `
1071
1083
- Arch $Arch `
1084
+ - Platform $Platform `
1072
1085
- Defines @ {
1086
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1073
1087
LLVM_HOST_TRIPLE = $Arch.LLVMTarget ;
1074
1088
}
1075
1089
}
@@ -1079,14 +1093,16 @@ function Build-ZLib([Platform]$Platform, $Arch) {
1079
1093
1080
1094
Build-CMakeProject `
1081
1095
- Src $SourceCache \zlib `
1082
- - Bin " $ ( $Arch.BinaryCache ) \zlib-1.3" `
1096
+ - Bin " $ ( $Arch.BinaryCache ) \$Platform \ zlib-1.3" `
1083
1097
- InstallTo $LibraryRoot \zlib- 1.3 \usr `
1084
1098
- Arch $Arch `
1099
+ - Platform $Platform `
1085
1100
- BuildTargets default `
1086
1101
- Defines @ {
1087
1102
BUILD_SHARED_LIBS = " NO" ;
1088
- INSTALL_BIN_DIR = " $LibraryRoot \zlib-1.3\usr\bin\$ArchName " ;
1089
- INSTALL_LIB_DIR = " $LibraryRoot \zlib-1.3\usr\lib\$ArchName " ;
1103
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1104
+ INSTALL_BIN_DIR = " $LibraryRoot \zlib-1.3\usr\bin\$Platform \$ArchName " ;
1105
+ INSTALL_LIB_DIR = " $LibraryRoot \zlib-1.3\usr\lib\$Platform \$ArchName " ;
1090
1106
}
1091
1107
}
1092
1108
@@ -1095,14 +1111,16 @@ function Build-XML2([Platform]$Platform, $Arch) {
1095
1111
1096
1112
Build-CMakeProject `
1097
1113
- Src $SourceCache \libxml2 `
1098
- - Bin " $ ( $Arch.BinaryCache ) \libxml2-2.11.5" `
1114
+ - Bin " $ ( $Arch.BinaryCache ) \$Platform \ libxml2-2.11.5" `
1099
1115
- InstallTo " $LibraryRoot \libxml2-2.11.5\usr" `
1100
1116
- Arch $Arch `
1117
+ - Platform $Platform `
1101
1118
- BuildTargets default `
1102
1119
- Defines @ {
1103
1120
BUILD_SHARED_LIBS = " NO" ;
1104
- CMAKE_INSTALL_BINDIR = " bin/$ArchName " ;
1105
- CMAKE_INSTALL_LIBDIR = " lib/$ArchName " ;
1121
+ CMAKE_INSTALL_BINDIR = " bin/$Platform /$ArchName " ;
1122
+ CMAKE_INSTALL_LIBDIR = " lib/$Platform /$ArchName " ;
1123
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1106
1124
LIBXML2_WITH_ICONV = " NO" ;
1107
1125
LIBXML2_WITH_ICU = " NO" ;
1108
1126
LIBXML2_WITH_LZMA = " NO" ;
@@ -1116,16 +1134,25 @@ function Build-XML2([Platform]$Platform, $Arch) {
1116
1134
function Build-CURL ([Platform ]$Platform , $Arch ) {
1117
1135
$ArchName = $Arch.LLVMName
1118
1136
1137
+ $PlatformDefines = @ {}
1138
+ if ($Platform -eq " Android" ) {
1139
+ $PlatformDefines += @ {
1140
+ HAVE_FSEEKO = " 0" ;
1141
+ }
1142
+ }
1143
+
1119
1144
Build-CMakeProject `
1120
1145
- Src $SourceCache \curl `
1121
- - Bin " $ ( $Arch.BinaryCache ) \curl-8.4.0" `
1146
+ - Bin " $ ( $Arch.BinaryCache ) \$Platform \ curl-8.4.0" `
1122
1147
- InstallTo " $LibraryRoot \curl-8.4.0\usr" `
1123
1148
- Arch $Arch `
1149
+ - Platform $Platform `
1124
1150
- BuildTargets default `
1125
- - Defines @ {
1151
+ - Defines ( $PlatformDefines + @ {
1126
1152
BUILD_SHARED_LIBS = " NO" ;
1127
1153
BUILD_TESTING = " NO" ;
1128
- CMAKE_INSTALL_LIBDIR = " lib/$ArchName " ;
1154
+ CMAKE_INSTALL_LIBDIR = " lib/$Platform /$ArchName " ;
1155
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1129
1156
BUILD_CURL_EXE = " NO" ;
1130
1157
CURL_CA_BUNDLE = " none" ;
1131
1158
CURL_CA_FALLBACK = " NO" ;
@@ -1178,9 +1205,9 @@ function Build-CURL([Platform]$Platform, $Arch) {
1178
1205
CURL_USE_LIBSSH2 = " NO" ;
1179
1206
CURL_USE_MBEDTLS = " NO" ;
1180
1207
CURL_USE_OPENSSL = " NO" ;
1181
- CURL_USE_SCHANNEL = " YES" ;
1208
+ CURL_USE_SCHANNEL = if ( $Platform -eq " Windows " ) { " YES" } else { " NO " } ;
1182
1209
CURL_USE_WOLFSSL = " NO" ;
1183
- CURL_WINDOWS_SSPI = " YES" ;
1210
+ CURL_WINDOWS_SSPI = if ( $Platform -eq " Windows " ) { " YES" } else { " NO " } ;
1184
1211
CURL_ZLIB = " YES" ;
1185
1212
CURL_ZSTD = " NO" ;
1186
1213
ENABLE_ARES = " NO" ;
@@ -1198,12 +1225,12 @@ function Build-CURL([Platform]$Platform, $Arch) {
1198
1225
USE_NGHTTP2 = " NO" ;
1199
1226
USE_NGTCP2 = " NO" ;
1200
1227
USE_QUICHE = " NO" ;
1201
- USE_WIN32_IDN = " YES" ;
1202
- USE_WIN32_LARGE_FILES = " YES" ;
1228
+ USE_WIN32_IDN = if ( $Platform -eq " Windows " ) { " YES" } else { " NO " } ;
1229
+ USE_WIN32_LARGE_FILES = if ( $Platform -eq " Windows " ) { " YES" } else { " NO " } ;
1203
1230
USE_WIN32_LDAP = " NO" ;
1204
1231
ZLIB_ROOT = " $LibraryRoot \zlib-1.3\usr" ;
1205
- ZLIB_LIBRARY = " $LibraryRoot \zlib-1.3\usr\lib\$ArchName \zlibstatic.lib" ;
1206
- }
1232
+ ZLIB_LIBRARY = " $LibraryRoot \zlib-1.3\usr\lib\$Platform \ $ ArchName \zlibstatic.lib" ;
1233
+ })
1207
1234
}
1208
1235
1209
1236
function Build-ICU ([Platform ]$Platform , $Arch ) {
@@ -1216,26 +1243,28 @@ function Build-ICU([Platform]$Platform, $Arch) {
1216
1243
}
1217
1244
}
1218
1245
1219
- if ($Arch -eq $ArchARM64 -and $HostArch -ne $ArchARM64 ) {
1246
+ if ($Platform -ne " Windows " -or ( $ Arch -eq $ArchARM64 -and $HostArch -ne $ArchARM64 ) ) {
1220
1247
# Use previously built x64 tools
1221
1248
$BuildToolsDefines = @ {
1222
1249
BUILD_TOOLS = " NO" ;
1223
- ICU_TOOLS_DIR = " $ ( $ArchX64.BinaryCache ) \icu-69.1"
1250
+ ICU_TOOLS_DIR = " $ ( $ArchX64.BinaryCache ) \windows\ icu-69.1"
1224
1251
}
1225
1252
} else {
1226
1253
$BuildToolsDefines = @ {BUILD_TOOLS = " YES" }
1227
1254
}
1228
1255
1229
1256
Build-CMakeProject `
1230
1257
- Src $SourceCache \icu\icu4c `
1231
- - Bin " $ ( $Arch.BinaryCache ) \icu-69.1" `
1258
+ - Bin " $ ( $Arch.BinaryCache ) \$Platform \ icu-69.1" `
1232
1259
- InstallTo " $LibraryRoot \icu-69.1\usr" `
1233
1260
- Arch $Arch `
1261
+ - Platform $Platform `
1234
1262
- BuildTargets default `
1235
1263
- Defines ($BuildToolsDefines + @ {
1236
1264
BUILD_SHARED_LIBS = " NO" ;
1237
- CMAKE_INSTALL_BINDIR = " bin/$ArchName " ;
1238
- CMAKE_INSTALL_LIBDIR = " lib/$ArchName " ;
1265
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1266
+ CMAKE_INSTALL_BINDIR = " bin/$Platform /$ArchName " ;
1267
+ CMAKE_INSTALL_LIBDIR = " lib/$Platform /$ArchName " ;
1239
1268
})
1240
1269
}
1241
1270
@@ -1248,12 +1277,14 @@ function Build-Runtime([Platform]$Platform, $Arch) {
1248
1277
- Bin (Get-TargetProjectBinaryCache $Arch Runtime) `
1249
1278
- InstallTo " $ ( $Arch.SDKInstallRoot ) \usr" `
1250
1279
- Arch $Arch `
1280
+ - Platform $Platform `
1251
1281
- CacheScript $SourceCache \swift\cmake\caches\Runtime- Windows- $ ($Arch.LLVMName ).cmake `
1252
1282
- UseBuiltCompilers C, CXX, Swift `
1253
1283
- BuildTargets default `
1254
1284
- Defines @ {
1255
1285
CMAKE_Swift_COMPILER_TARGET = $Arch.LLVMTarget ;
1256
1286
CMAKE_Swift_COMPILER_WORKS = " YES" ;
1287
+ CMAKE_SYSTEM_NAME = if ($Platform -eq " Windows" ) { " Windows" } else { " Android" };
1257
1288
LLVM_DIR = " $ ( Get-TargetProjectBinaryCache $Arch LLVM) \lib\cmake\llvm" ;
1258
1289
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
1259
1290
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
@@ -1281,6 +1312,7 @@ function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
1281
1312
- Bin (Get-TargetProjectBinaryCache $Arch Dispatch) `
1282
1313
- InstallTo " $ ( $Arch.SDKInstallRoot ) \usr" `
1283
1314
- Arch $Arch `
1315
+ - Platform $Platform `
1284
1316
- UseBuiltCompilers C, CXX, Swift `
1285
1317
- BuildTargets $Targets `
1286
1318
- Defines @ {
@@ -1315,6 +1347,7 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
1315
1347
- Bin $FoundationBinaryCache `
1316
1348
- InstallTo " $ ( $Arch.SDKInstallRoot ) \usr" `
1317
1349
- Arch $Arch `
1350
+ - Platform $Platform `
1318
1351
- UseBuiltCompilers ASM, C, Swift `
1319
1352
- BuildTargets $Targets `
1320
1353
- Defines (@ {
@@ -1324,15 +1357,15 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
1324
1357
# and fails with an ICU data object file icudt69l_dat.obj. This
1325
1358
# matters to X86 only.
1326
1359
CMAKE_Swift_FLAGS = if ($Arch -eq $ArchX86 ) { @ (" -Xlinker" , " /SAFESEH:NO" ) } else { " " };
1327
- CURL_DIR = " $LibraryRoot \curl-8.4.0\usr\lib\$ShortArch \cmake\CURL" ;
1328
- ICU_DATA_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$ShortArch \sicudt69.lib" ;
1329
- ICU_I18N_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$ShortArch \sicuin69.lib" ;
1360
+ CURL_DIR = " $LibraryRoot \curl-8.4.0\usr\lib\$Platform \ $ ShortArch \cmake\CURL" ;
1361
+ ICU_DATA_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$Platform \ $ ShortArch \sicudt69.lib" ;
1362
+ ICU_I18N_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$Platform \ $ ShortArch \sicuin69.lib" ;
1330
1363
ICU_ROOT = " $LibraryRoot \icu-69.1\usr" ;
1331
- ICU_UC_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$ShortArch \sicuuc69.lib" ;
1332
- LIBXML2_LIBRARY = " $LibraryRoot \libxml2-2.11.5\usr\lib\$ShortArch \libxml2s.lib" ;
1364
+ ICU_UC_LIBRARY_RELEASE = " $LibraryRoot \icu-69.1\usr\lib\$Platform \ $ ShortArch \sicuuc69.lib" ;
1365
+ LIBXML2_LIBRARY = " $LibraryRoot \libxml2-2.11.5\usr\lib\$Platform \ $ ShortArch \libxml2s.lib" ;
1333
1366
LIBXML2_INCLUDE_DIR = " $LibraryRoot \libxml2-2.11.5\usr\include\libxml2" ;
1334
1367
LIBXML2_DEFINITIONS = " /DLIBXML_STATIC" ;
1335
- ZLIB_LIBRARY = " $LibraryRoot \zlib-1.3\usr\lib\$ShortArch \zlibstatic.lib" ;
1368
+ ZLIB_LIBRARY = " $LibraryRoot \zlib-1.3\usr\lib\$Platform \ $ ShortArch \zlibstatic.lib" ;
1336
1369
ZLIB_INCLUDE_DIR = " $LibraryRoot \zlib-1.3\usr\include" ;
1337
1370
dispatch_DIR = " $DispatchBinaryCache \cmake\modules" ;
1338
1371
} + $TestingDefines )
@@ -1365,6 +1398,7 @@ function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
1365
1398
- Bin $XCTestBinaryCache `
1366
1399
- InstallTo " $ ( $Arch.XCTestInstallRoot ) \usr" `
1367
1400
- Arch $Arch `
1401
+ - Platform $Platform `
1368
1402
- UseBuiltCompilers Swift `
1369
1403
- BuildTargets $Targets `
1370
1404
- Defines (@ {
@@ -1902,7 +1936,7 @@ if (-not $SkipBuild) {
1902
1936
if ($Clean ) {
1903
1937
2 .. 16 | % { Remove-Item - Force - Recurse " $BinaryCache \$_ " - ErrorAction Ignore }
1904
1938
foreach ($Arch in $WindowsSDKArchs ) {
1905
- 0 .. 3 | % { Remove-Item - Force - Recurse " $BinaryCache \$ ( $Arch.BuildiD + $_ ) " - ErrorAction Ignore }
1939
+ 0 .. 3 | % { Remove-Item - Force - Recurse " $BinaryCache \$ ( $Arch.BuildID + $_ ) " - ErrorAction Ignore }
1906
1940
}
1907
1941
}
1908
1942
@@ -2021,6 +2055,6 @@ if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
2021
2055
exit 1
2022
2056
} finally {
2023
2057
if ($Summary ) {
2024
- $TimingData | Select Arch, Checkout, BuildID , " Elapsed Time" | Sort - Descending - Property " Elapsed Time" | Format-Table - AutoSize
2058
+ $TimingData | Select Platform , Arch, Checkout, " Elapsed Time" | Sort - Descending - Property " Elapsed Time" | Format-Table - AutoSize
2025
2059
}
2026
2060
}
0 commit comments