summaryrefslogtreecommitdiff
path: root/src/pal/tools/probe-win.ps1
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tools/probe-win.ps1
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tools/probe-win.ps1')
-rw-r--r--src/pal/tools/probe-win.ps160
1 files changed, 60 insertions, 0 deletions
diff --git a/src/pal/tools/probe-win.ps1 b/src/pal/tools/probe-win.ps1
new file mode 100644
index 0000000000..783cb6dfe0
--- /dev/null
+++ b/src/pal/tools/probe-win.ps1
@@ -0,0 +1,60 @@
+# This file probes for the prerequisites for the build system, and outputs commands for eval'ing
+# from the cmd scripts to set variables (and exit on error)
+
+function GetCMakeVersions
+{
+ $items = @()
+ $items += @(Get-ChildItem hklm:\SOFTWARE\Wow6432Node\Kitware -ErrorAction SilentlyContinue)
+ $items += @(Get-ChildItem hklm:\SOFTWARE\Kitware -ErrorAction SilentlyContinue)
+ return $items | where { $_.PSChildName.StartsWith("CMake ") }
+}
+
+function GetCMakeInfo($regKey)
+{
+ try {
+ $version = [System.Version] $regKey.PSChildName.Split(' ')[1]
+ }
+ catch {
+ return $null
+ }
+ $cmakeDir = (Get-ItemProperty $regKey.PSPath).'(default)'
+ $cmakePath = [System.IO.Path]::Combine($cmakeDir, "bin\cmake.exe")
+ if (![System.IO.File]::Exists($cmakePath)) {
+ return $null
+ }
+ return @{'version' = $version; 'path' = $cmakePath}
+}
+
+function LocateCMake
+{
+ $errorMsg = "CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from http://www.cmake.org/download/ and ensure it is on your path."
+ $inPathPath = (get-command cmake.exe -ErrorAction SilentlyContinue).Path
+ if ($inPathPath -ne $null) {
+ return $inPathPath
+ }
+ # Let us hope that CMake keep using their current version scheme
+ $validVersions = @()
+ foreach ($regKey in GetCMakeVersions) {
+ $info = GetCMakeInfo($regKey)
+ if ($info -ne $null) {
+ $validVersions += @($info)
+ }
+ }
+ $newestCMakePath = ($validVersions |
+ Sort-Object -property @{Expression={$_.version}; Ascending=$false} |
+ select -first 1).path
+ if ($newestCMakePath -eq $null) {
+ Throw $errorMsg
+ }
+ return $newestCMakePath
+}
+
+try {
+ $cmakePath = LocateCMake
+ [System.Console]::WriteLine("set CMakePath=" + $cmakePath)
+
+}
+catch {
+ [System.Console]::Error.WriteLine($_.Exception.Message)
+ [System.Console]::WriteLine("exit /b 1")
+}