diff options
Diffstat (limited to '')
-rw-r--r-- | .appveyor/build.ps1 | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1 index 173ba3c..3016b42 100644 --- a/.appveyor/build.ps1 +++ b/.appveyor/build.ps1 @@ -1,7 +1,8 @@ param( - [string] $BuildDir = 'C:\Projects\build', + [string] $BuildDir = $null, [string] $ProjectDir = $null, [string] $Platform = $null, + [string] $Generator = $null, [string] $Configuration = $null, [string] $BoostDir = $null, [string] $BoostLibraryDir = $null, @@ -9,6 +10,7 @@ param( ) $ErrorActionPreference = "Stop"; +Set-PSDebug -Strict function Invoke-Exe { param( @@ -55,6 +57,22 @@ function Get-AppVeyorBoostLibraryDir { } } +function Set-AppVeyorDefaults { + $script:ProjectDir = $env:APPVEYOR_BUILD_FOLDER + $script:BuildDir = 'C:\Projects\build' + $script:Generator = switch ($env:APPVEYOR_BUILD_WORKER_IMAGE) { + 'Visual Studio 2013' { 'Visual Studio 12 2013' } + 'Visual Studio 2015' { 'Visual Studio 14 2015' } + 'Visual Studio 2017' { 'Visual Studio 15 2017' } + default { throw "Unsupported AppVeyor image: $env:APPVEYOR_BUILD_WORKER_IMAGE" } + } + $script:Platform = $env:PLATFORM + $script:Configuration = $env:CONFIGURATION + $script:BoostDir = Get-AppVeyorBoostDir + $script:BoostLibraryDir = Get-AppVeyorBoostLibraryDir -Platform $script:Platform + $script:UseAsm = -not ($env:appveyor_asm -eq '0') +} + function Build-Project { param( [Parameter(Mandatory=$true)] @@ -62,6 +80,8 @@ function Build-Project { [Parameter(Mandatory=$true)] [string] $BuildDir, [Parameter(Mandatory=$true)] + [string] $Generator, + [Parameter(Mandatory=$true)] [string] $Platform, [Parameter(Mandatory=$true)] [string] $Configuration, @@ -84,8 +104,8 @@ function Build-Project { mkdir $BuildDir cd $BuildDir - Invoke-Exe { cmake -Wno-dev ` - -G "Visual Studio 15 2017" -A $Platform ` + Invoke-Exe { cmake.exe -Wno-dev ` + -G $Generator -A $Platform ` -D "AES_TOOLS_ASM=$cmake_asm" ` -D "BOOST_ROOT=$BoostDir" ` -D "BOOST_LIBRARYDIR=$BoostLibraryDir" ` @@ -94,29 +114,30 @@ function Build-Project { $ProjectDir } - Invoke-Exe { cmake --build . --config "$Configuration" -- /m } + Invoke-Exe { cmake.exe --build . --config $Configuration -- /m } } -if (Test-AppVeyor) { - $cwd = pwd - $ProjectDir = $env:APPVEYOR_BUILD_FOLDER - $BuildDir = 'C:\Projects\build' - $Platform = $env:PLATFORM - $Configuration = $env:CONFIGURATION - $BoostDir = Get-AppVeyorBoostDir - $BoostLibraryDir = Get-AppVeyorBoostLibraryDir -Platform $Platform - $UseAsm = -not ($env:appveyor_asm -eq '0') +function Build-ProjectAppVeyor { + if (Test-AppVeyor) { + Set-AppVeyorDefaults + $appveyor_cwd = pwd + } + + try { + Build-Project ` + -ProjectDir $script:ProjectDir ` + -BuildDir $script:BuildDir ` + -Generator $script:Generator ` + -Platform $script:Platform ` + -Configuration $script:Configuration ` + -BoostDir $script:BoostDir ` + -BoostLibraryDir $script:BoostLibraryDir ` + -UseAsm $UseAsm + } finally { + if (Test-AppVeyor) { + cd $appveyor_cwd + } + } } -Build-Project ` - -ProjectDir $ProjectDir ` - -BuildDir $BuildDir ` - -Platform $Platform ` - -Configuration $Configuration ` - -BoostDir $BoostDir ` - -BoostLibraryDir $BoostLibraryDir ` - -UseAsm $UseAsm - -if (Test-AppVeyor) { - cd $cwd -} +Build-ProjectAppVeyor |