@@ -396,6 +396,31 @@ $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.e
396
396
$VSInstallRoot = & $vswhere - nologo - latest - products " *" - all - prerelease - property installationPath
397
397
$msbuild = " $VSInstallRoot \MSBuild\Current\Bin\$BuildArchName \MSBuild.exe"
398
398
399
+ function Get-CMake {
400
+ try {
401
+ return (Get-Command " cmake.exe" - ErrorAction Stop).Source
402
+ } catch {
403
+ if (Test-Path - Path " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" - PathType Container) {
404
+ return " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
405
+ }
406
+ }
407
+ throw " CMake not found on Path nor in the Visual Studio Installation. Please Install CMake to continue."
408
+ }
409
+
410
+ function Get-Ninja {
411
+ try {
412
+ return (Get-Command " Ninja.exe" - ErrorAction Stop).Source
413
+ } catch {
414
+ if (Test-Path - Path " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja" - PathType Container) {
415
+ return " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
416
+ }
417
+ }
418
+ throw " Ninja not found on Path nor in the Visual Studio Installation. Please Install Ninja to continue."
419
+ }
420
+
421
+ $cmake = Get-CMake
422
+ $ninja = Get-Ninja
423
+
399
424
$NugetRoot = " $BinaryCache \nuget"
400
425
$LibraryRoot = " $ImageRoot \Library"
401
426
@@ -1222,14 +1247,6 @@ function Build-CMakeProject {
1222
1247
}
1223
1248
1224
1249
if ($Platform.OS -eq [OS ]::Android) {
1225
- $vswhere = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"
1226
- $VSInstallPath = & $vswhere - nologo - latest - products * - property installationPath
1227
- if (Test-Path " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" ) {
1228
- $env: Path = " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;${env: Path} "
1229
- Add-KeyValueIfNew $Defines CMAKE_MAKE_PROGRAM " ${VSInstallPath} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
1230
- } else {
1231
- throw " Missing CMake and Ninja in the visual studio installation that are needed to build Android"
1232
- }
1233
1250
$androidNDKPath = Get-AndroidNDKPath
1234
1251
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER (Join-Path - Path $androidNDKPath - ChildPath " toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" )
1235
1252
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER (Join-Path - Path $androidNDKPath - ChildPath " toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe" )
@@ -1428,6 +1445,8 @@ function Build-CMakeProject {
1428
1445
Add-KeyValueIfNew $Defines CMAKE_INSTALL_PREFIX $InstallTo
1429
1446
}
1430
1447
1448
+ Add-KeyValueIfNew $Defines CMAKE_MAKE_PROGRAM " $ninja "
1449
+
1431
1450
# Generate the project
1432
1451
$cmakeGenerateArgs = @ (" -B" , $Bin , " -S" , $Src , " -G" , $Generator )
1433
1452
if ($CacheScript ) {
@@ -1467,26 +1486,25 @@ function Build-CMakeProject {
1467
1486
} elseif ($UsePinnedCompilers.Contains (" Swift" )) {
1468
1487
$env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
1469
1488
}
1470
-
1471
1489
if ($ToBatch ) {
1472
1490
Write-Output " "
1473
- Write-Output " echo cmake.exe $cmakeGenerateArgs "
1491
+ Write-Output " echo $ cmake $cmakeGenerateArgs "
1474
1492
} else {
1475
- Write-Host " cmake.exe $cmakeGenerateArgs "
1493
+ Write-Host " $ cmake $cmakeGenerateArgs "
1476
1494
}
1477
- Invoke-Program cmake.exe @cmakeGenerateArgs
1495
+ Invoke-Program $ cmake @cmakeGenerateArgs
1478
1496
1479
1497
# Build all requested targets
1480
1498
foreach ($Target in $BuildTargets ) {
1481
1499
if ($Target -eq " default" ) {
1482
- Invoke-Program cmake.exe -- build $Bin
1500
+ Invoke-Program $ cmake -- build $Bin
1483
1501
} else {
1484
- Invoke-Program cmake.exe -- build $Bin -- target $Target
1502
+ Invoke-Program $ cmake -- build $Bin -- target $Target
1485
1503
}
1486
1504
}
1487
1505
1488
1506
if ($BuildTargets.Length -eq 0 -and $InstallTo ) {
1489
- Invoke-Program cmake.exe -- build $Bin -- target install
1507
+ Invoke-Program $ cmake -- build $Bin -- target install
1490
1508
}
1491
1509
}
1492
1510
@@ -2270,7 +2288,7 @@ function Build-ExperimentalRuntime {
2270
2288
Invoke-VsDevShell $BuildPlatform
2271
2289
2272
2290
Push-Location " ${SourceCache} \swift\Runtimes"
2273
- Start-Process - Wait - WindowStyle Hidden - FilePath cmake.exe - ArgumentList @ (" -P" , " Resync.cmake" )
2291
+ Start-Process - Wait - WindowStyle Hidden - FilePath $ cmake - ArgumentList @ (" -P" , " Resync.cmake" )
2274
2292
Pop-Location
2275
2293
}
2276
2294
@@ -2681,7 +2699,7 @@ function Test-LLBuild {
2681
2699
# Build additional llvm executables needed by tests
2682
2700
Invoke-IsolatingEnvVars {
2683
2701
Invoke-VsDevShell $BuildPlatform
2684
- Invoke-Program ninja.exe - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2702
+ Invoke-Program $ ninja - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2685
2703
}
2686
2704
2687
2705
Invoke-IsolatingEnvVars {
0 commit comments