@@ -383,6 +383,31 @@ $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.e
383
383
$VSInstallRoot = & $vswhere - nologo - latest - products " *" - all - prerelease - property installationPath
384
384
$msbuild = " $VSInstallRoot \MSBuild\Current\Bin\$BuildArchName \MSBuild.exe"
385
385
386
+ function Get-CMake {
387
+ try {
388
+ return (Get-Command " cmake.exe" - ErrorAction Stop).Source
389
+ } catch {
390
+ if (Test-Path - Path " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" - PathType Container) {
391
+ return " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
392
+ }
393
+ }
394
+ throw " CMake not found on Path nor in the Visual Studio Installation. Please Install CMake to continue."
395
+ }
396
+
397
+ function Get-Ninja {
398
+ try {
399
+ return (Get-Command " Ninja.exe" - ErrorAction Stop).Source
400
+ } catch {
401
+ if (Test-Path - Path " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja" - PathType Container) {
402
+ return " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
403
+ }
404
+ }
405
+ throw " Ninja not found on Path nor in the Visual Studio Installation. Please Install Ninja to continue."
406
+ }
407
+
408
+ $cmake = Get-CMake
409
+ $ninja = Get-Ninja
410
+
386
411
$NugetRoot = " $BinaryCache \nuget"
387
412
$LibraryRoot = " $ImageRoot \Library"
388
413
@@ -1206,14 +1231,6 @@ function Build-CMakeProject {
1206
1231
}
1207
1232
1208
1233
if ($Platform.OS -eq [OS ]::Android) {
1209
- $vswhere = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"
1210
- $VSInstallPath = & $vswhere - nologo - latest - products * - property installationPath
1211
- if (Test-Path " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" ) {
1212
- $env: Path = " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;${env: Path} "
1213
- Add-KeyValueIfNew $Defines CMAKE_MAKE_PROGRAM " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
1214
- } else {
1215
- throw " Missing CMake and Ninja in the visual studio installation that are needed to build Android"
1216
- }
1217
1234
$androidNDKPath = Get-AndroidNDKPath
1218
1235
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER (Join-Path - Path $androidNDKPath - ChildPath " toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" )
1219
1236
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER (Join-Path - Path $androidNDKPath - ChildPath " toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe" )
@@ -1412,6 +1429,8 @@ function Build-CMakeProject {
1412
1429
Add-KeyValueIfNew $Defines CMAKE_INSTALL_PREFIX $InstallTo
1413
1430
}
1414
1431
1432
+ Add-KeyValueIfNew $Defines CMAKE_MAKE_PROGRAM " $ninja "
1433
+
1415
1434
# Generate the project
1416
1435
$cmakeGenerateArgs = @ (" -B" , $Bin , " -S" , $Src , " -G" , $Generator )
1417
1436
if ($CacheScript ) {
@@ -1451,26 +1470,25 @@ function Build-CMakeProject {
1451
1470
} elseif ($UsePinnedCompilers.Contains (" Swift" )) {
1452
1471
$env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
1453
1472
}
1454
-
1455
1473
if ($ToBatch ) {
1456
1474
Write-Output " "
1457
- Write-Output " echo cmake.exe $cmakeGenerateArgs "
1475
+ Write-Output " echo $ cmake $cmakeGenerateArgs "
1458
1476
} else {
1459
- Write-Host " cmake.exe $cmakeGenerateArgs "
1477
+ Write-Host " $ cmake $cmakeGenerateArgs "
1460
1478
}
1461
- Invoke-Program cmake.exe @cmakeGenerateArgs
1479
+ Invoke-Program $ cmake @cmakeGenerateArgs
1462
1480
1463
1481
# Build all requested targets
1464
1482
foreach ($Target in $BuildTargets ) {
1465
1483
if ($Target -eq " default" ) {
1466
- Invoke-Program cmake.exe -- build $Bin
1484
+ Invoke-Program $ cmake -- build $Bin
1467
1485
} else {
1468
- Invoke-Program cmake.exe -- build $Bin -- target $Target
1486
+ Invoke-Program $ cmake -- build $Bin -- target $Target
1469
1487
}
1470
1488
}
1471
1489
1472
1490
if ($BuildTargets.Length -eq 0 -and $InstallTo ) {
1473
- Invoke-Program cmake.exe -- build $Bin -- target install
1491
+ Invoke-Program $ cmake -- build $Bin -- target install
1474
1492
}
1475
1493
}
1476
1494
@@ -2254,7 +2272,7 @@ function Build-ExperimentalRuntime {
2254
2272
Invoke-VsDevShell $BuildPlatform
2255
2273
2256
2274
Push-Location " ${SourceCache} \swift\Runtimes"
2257
- Start-Process - Wait - WindowStyle Hidden - FilePath cmake.exe - ArgumentList @ (" -P" , " Resync.cmake" )
2275
+ Start-Process - Wait - WindowStyle Hidden - FilePath $ cmake - ArgumentList @ (" -P" , " Resync.cmake" )
2258
2276
Pop-Location
2259
2277
}
2260
2278
@@ -2665,7 +2683,7 @@ function Test-LLBuild {
2665
2683
# Build additional llvm executables needed by tests
2666
2684
Invoke-IsolatingEnvVars {
2667
2685
Invoke-VsDevShell $BuildPlatform
2668
- Invoke-Program ninja.exe - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2686
+ Invoke-Program $ ninja - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2669
2687
}
2670
2688
2671
2689
Invoke-IsolatingEnvVars {
0 commit comments