Skip to content

Commit

Permalink
Installing cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolKaczmarek committed Jul 25, 2016
1 parent 6a989e8 commit 38fc724
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ function Start-PSBuild {
$precheck = precheck 'dotnet' "Build dependency 'dotnet' not found in PATH. Run Start-PSBootstrap. Also see: https://dotnet.github.io/getting-started/"
if ($FullCLR) {
# cmake is needed to build powershell.exe
$precheck = $precheck -and (precheck 'cmake' 'cmake not found. You can install it from https://chocolatey.org/packages/cmake.portable')
$precheck = $precheck -and (precheck 'cmake' 'cmake not found. Run Start-PSBootstrap. You can also install it from https://chocolatey.org/packages/cmake.portable')

Use-MSBuild

#mc.exe is Message Compiler for native resources
$mcexe = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\" -Recurse -Filter 'mc.exe' | ? {$_.FullName -match 'x64'} | select -First 1 | % {$_.FullName}
if (-not $mcexe) {
throw 'mc.exe not found. Install Microsoft Windows 10 SDK from https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk'
throw 'mc.exe not found. Run Start-PSBootstrap or install Microsoft Windows 10 SDK from https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk'
}

$vcVarsPath = (Get-Item(Join-Path -Path "$env:VS140COMNTOOLS" -ChildPath '../../vc')).FullName
Expand Down Expand Up @@ -590,14 +590,16 @@ function Start-PSBootstrap {
Invoke-WebRequest -Uri $obtainUrl/$installScript -OutFile $installScript
& ./$installScript -c $Channel -v $Version

# Install chocolatey
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
$newMachineEnvironmentPath = $machinePath

# Install chocolatey
$chocolateyPath = "$env:AllUsersProfile\chocolatey\bin"
if(Get-Command "choco" -ErrorAction SilentlyContinue)
{
log "Chocolatey is already installed. Skipping installation."
}
else
else
{
log "Chocolatey not present. Installing chocolatey."
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Expand All @@ -606,14 +608,43 @@ function Start-PSBootstrap {
{
log "Adding $chocolateyPath to Path environment variable"
$env:Path += ";$chocolateyPath"
$machinePath += ";$chocolateyPath"
[Environment]::SetEnvironmentVariable('Path', $machinePath, 'MACHINE')
$newMachineEnvironmentPath += ";$chocolateyPath"
}
else
{
log "$chocolateyPath already present in Path environment variable"
}
}

# Install cmake
$cmakePath = "${env:ProgramFiles(x86)}\CMake\bin"
if(Get-Command "cmake" -ErrorAction SilentlyContinue)
{
log "Cmake is already installed. Skipping installation."
}
else
{
log "Cmake not present. Installing cmake."
choco install cmake.portable -y --version 3.6.0

if (-not ($machinePath.ToLower().Contains($cmakePath.ToLower())))
{
log "Adding $cmakePath to Path environment variable"
$env:Path += ";$cmakePath"
$newMachineEnvironmentPath = "$cmakePath;$newMachineEnvironmentPath"
}
else
{
log "$cmakePath already present in Path environment variable"
}
}

# Update machine environment path
if ($newMachineEnvironmentPath -ne $machinePath)
{
[Environment]::SetEnvironmentVariable('Path', $newMachineEnvironmentPath, 'MACHINE')
}

} elseif ($IsWindows) {
Write-Warning "Start-PSBootstrap cannot be run in Core PowerShell on Windows (need Invoke-WebRequest!)"
}
Expand Down

0 comments on commit 38fc724

Please sign in to comment.