@@ -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 " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" ) {
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 " ${VSInstallRoot} \Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja" ) {
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,9 @@ function Build-CMakeProject {
1428
1445
Add-KeyValueIfNew $Defines CMAKE_INSTALL_PREFIX $InstallTo
1429
1446
}
1430
1447
1448
+ $ninja_bin = Get-NinjaPath
1449
+ Add-KeyValueIfNew $Defines CMAKE_MAKE_PROGRAM " $ninja "
1450
+
1431
1451
# Generate the project
1432
1452
$cmakeGenerateArgs = @ (" -B" , $Bin , " -S" , $Src , " -G" , $Generator )
1433
1453
if ($CacheScript ) {
@@ -1467,26 +1487,25 @@ function Build-CMakeProject {
1467
1487
} elseif ($UsePinnedCompilers.Contains (" Swift" )) {
1468
1488
$env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
1469
1489
}
1470
-
1471
1490
if ($ToBatch ) {
1472
1491
Write-Output " "
1473
- Write-Output " echo cmake.exe $cmakeGenerateArgs "
1492
+ Write-Output " echo $ cmake $cmakeGenerateArgs "
1474
1493
} else {
1475
- Write-Host " cmake.exe $cmakeGenerateArgs "
1494
+ Write-Host " $ cmake $cmakeGenerateArgs "
1476
1495
}
1477
- Invoke-Program cmake.exe @cmakeGenerateArgs
1496
+ Invoke-Program $ cmake @cmakeGenerateArgs
1478
1497
1479
1498
# Build all requested targets
1480
1499
foreach ($Target in $BuildTargets ) {
1481
1500
if ($Target -eq " default" ) {
1482
- Invoke-Program cmake.exe -- build $Bin
1501
+ Invoke-Program $ cmake -- build $Bin
1483
1502
} else {
1484
- Invoke-Program cmake.exe -- build $Bin -- target $Target
1503
+ Invoke-Program $ cmake -- build $Bin -- target $Target
1485
1504
}
1486
1505
}
1487
1506
1488
1507
if ($BuildTargets.Length -eq 0 -and $InstallTo ) {
1489
- Invoke-Program cmake.exe -- build $Bin -- target install
1508
+ Invoke-Program $ cmake -- build $Bin -- target install
1490
1509
}
1491
1510
}
1492
1511
@@ -2270,7 +2289,7 @@ function Build-ExperimentalRuntime {
2270
2289
Invoke-VsDevShell $BuildPlatform
2271
2290
2272
2291
Push-Location " ${SourceCache} \swift\Runtimes"
2273
- Start-Process - Wait - WindowStyle Hidden - FilePath cmake.exe - ArgumentList @ (" -P" , " Resync.cmake" )
2292
+ Start-Process - Wait - WindowStyle Hidden - FilePath $ cmake - ArgumentList @ (" -P" , " Resync.cmake" )
2274
2293
Pop-Location
2275
2294
}
2276
2295
@@ -2681,7 +2700,7 @@ function Test-LLBuild {
2681
2700
# Build additional llvm executables needed by tests
2682
2701
Invoke-IsolatingEnvVars {
2683
2702
Invoke-VsDevShell $BuildPlatform
2684
- Invoke-Program ninja.exe - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2703
+ Invoke-Program $ ninja - C (Get-ProjectBinaryCache $BuildPlatform BuildTools) FileCheck not
2685
2704
}
2686
2705
2687
2706
Invoke-IsolatingEnvVars {
0 commit comments