Refactor native build steps

Move dependency checks to precheck section and make conditional more
sensible.
This commit is contained in:
Andrew Schwartzmeyer 2016-04-01 14:42:40 -07:00
parent aa5c30d42e
commit 6cf8e39d1a

View File

@ -78,6 +78,17 @@ function Start-PSBuild {
}
$precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')
} elseif ($IsLinux -Or $IsOSX) {
$InstallCommand = if ($IsLinux) {
'apt-get'
} elseif ($IsOSX) {
'brew'
}
foreach ($Dependency in 'cmake', 'make', 'g++') {
$precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run '$InstallCommand install $Dependency'")
}
}
}
# Abort if any precheck failed
@ -111,21 +122,16 @@ function Start-PSBuild {
}
# Build native components
if (-not $FullCLR)
{
if ($IsLinux -Or $IsOSX) {
log "Start building native components"
$InstallCommand = if ($IsLinux) { "apt-get" } elseif ($IsOSX) { "brew" }
foreach ($Dependency in "cmake", "g++") {
if (-Not (Get-Command $Dependency -ErrorAction SilentlyContinue)) {
throw "Build dependency '$Dependency' not found in PATH! Run '$InstallCommand install $Dependency'"
}
$Ext = if ($IsLinux) {
"so"
} elseif ($IsOSX) {
"dylib"
}
$Ext = if ($IsLinux) { "so" } elseif ($IsOSX) { "dylib" }
$Native = "$PSScriptRoot/src/libpsl-native"
$Lib = "$Top/libpsl-native.$Ext"
Write-Verbose "Building $Lib"
log "Start building $Lib"
try {
Push-Location $Native
@ -136,11 +142,10 @@ function Start-PSBuild {
Pop-Location
}
if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" }
if (-Not (Test-Path $Lib)) {
throw "Compilation of $Lib failed"
}
}
else
{
} elseif ($FullCLR) {
log "Start building native powershell.exe"
$build = "$PSScriptRoot/build"
if ($Clean) {