From 6cf8e39d1a010583ff7447bcb3d72277025e0f83 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 1 Apr 2016 14:42:40 -0700 Subject: [PATCH] Refactor native build steps Move dependency checks to precheck section and make conditional more sensible. --- PowerShellGitHubDev.psm1 | 63 ++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 5e2d0519d5..a25a9510d1 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -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,36 +122,30 @@ 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" } - $Native = "$PSScriptRoot/src/libpsl-native" - $Lib = "$Top/libpsl-native.$Ext" - Write-Verbose "Building $Lib" - - try { - Push-Location $Native - cmake -DCMAKE_BUILD_TYPE=Debug . - make -j - make test - } finally { - Pop-Location - } - - if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" } + if ($IsLinux -Or $IsOSX) { + $Ext = if ($IsLinux) { + "so" + } elseif ($IsOSX) { + "dylib" } - } - else - { + + $Native = "$PSScriptRoot/src/libpsl-native" + $Lib = "$Top/libpsl-native.$Ext" + log "Start building $Lib" + + try { + Push-Location $Native + cmake -DCMAKE_BUILD_TYPE=Debug . + make -j + make test + } finally { + Pop-Location + } + + if (-Not (Test-Path $Lib)) { + throw "Compilation of $Lib failed" + } + } elseif ($FullCLR) { log "Start building native powershell.exe" $build = "$PSScriptRoot/build" if ($Clean) {