diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-08-22 10:52:31 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-08-22 14:33:12 +0300 |
commit | 111ef6605310fbd113a6c8d38dda9ecee0e008f0 (patch) | |
tree | ca1a8bd1fff70bc0e790021faa34e85486700477 | |
parent | fix eol (diff) | |
download | winapi-debug-111ef6605310fbd113a6c8d38dda9ecee0e008f0.tar.gz winapi-debug-111ef6605310fbd113a6c8d38dda9ecee0e008f0.zip |
AppVeyor: better practices
-rw-r--r-- | .appveyor/build.ps1 | 75 | ||||
-rw-r--r-- | appveyor.yml | 1 |
2 files changed, 49 insertions, 27 deletions
diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1 index e79038d..a193909 100644 --- a/.appveyor/build.ps1 +++ b/.appveyor/build.ps1 @@ -1,6 +1,7 @@ param( - [string] $BuildDir = 'C:\Projects\build', + [string] $BuildDir = $null, [string] $ProjectDir = $null, + [string] $Generator = $null, [string] $Platform = $null, [string] $Configuration = $null, [string] $BoostDir = $null, @@ -8,6 +9,7 @@ param( ) $ErrorActionPreference = "Stop"; +Set-PSDebug -Strict function Invoke-Exe { param( @@ -54,6 +56,21 @@ 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 +} + function Build-Project { param( [Parameter(Mandatory=$true)] @@ -61,6 +78,8 @@ function Build-Project { [Parameter(Mandatory=$true)] [string] $BuildDir, [Parameter(Mandatory=$true)] + [string] $Generator, + [Parameter(Mandatory=$true)] [string] $Platform, [Parameter(Mandatory=$true)] [string] $Configuration, @@ -76,36 +95,38 @@ function Build-Project { mkdir $BuildDir cd $BuildDir - Invoke-Exe { cmake -Wno-dev ` - -G "Visual Studio 14 2015" -A $Platform ` - -D "BOOST_ROOT=$BoostDir" ` - -D "BOOST_LIBRARYDIR=$BoostLibraryDir" ` - -D Boost_USE_STATIC_LIBS=ON ` - -D Boost_USE_STATIC_RUNTIME=ON ` + Invoke-Exe { cmake.exe -Wno-dev ` + -G $Generator -A $Platform ` + -D "BOOST_ROOT=$BoostDir" ` + -D "BOOST_LIBRARYDIR=$BoostLibraryDir" ` + -D Boost_USE_STATIC_LIBS=ON ` + -D Boost_USE_STATIC_RUNTIME=ON ` $ProjectDir } - Invoke-Exe { cmake --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 + Invoke-Exe { cmake.exe --build . --config $Configuration -- /m } } -Build-Project ` - -ProjectDir $ProjectDir ` - -BuildDir $BuildDir ` - -Platform $Platform ` - -Configuration $Configuration ` - -BoostDir $BoostDir ` - -BoostLibraryDir $BoostLibraryDir +function Build-ProjectAppVeyor { + if (Test-AppVeyor) { + Set-AppVeyorDefaults + $appveyor_cwd = pwd + } -if (Test-AppVeyor) { - cd $cwd + try { + Build-Project ` + -ProjectDir $script:ProjectDir ` + -BuildDir $script:BuildDir ` + -Generator $script:Generator ` + -Platform $script:Platform ` + -Configuration $script:Configuration ` + -BoostDir $script:BoostDir ` + -BoostLibraryDir $script:BoostLibraryDir + } finally { + if (Test-AppVeyor) { + cd $appveyor_cwd + } + } } + +Build-ProjectAppVeyor diff --git a/appveyor.yml b/appveyor.yml index e1ae362..4912fa8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,5 @@ version: '{build}' +image: 'Visual Studio 2017' branches: only: |