aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.appveyor
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-08-22 02:40:01 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-08-22 14:36:32 +0300
commitb3b61167312c4919ab74c54c1257c4e7fecb9124 (patch)
tree12faa6ba5429133f84d16fc4e0022c883c2ed6c1 /.appveyor
parentREADME: add AppVeyor badge (diff)
downloadprivilege-check-b3b61167312c4919ab74c54c1257c4e7fecb9124.tar.gz
privilege-check-b3b61167312c4919ab74c54c1257c4e7fecb9124.zip
AppVeyor: better practices
Diffstat (limited to '.appveyor')
-rw-r--r--.appveyor/build.ps161
1 files changed, 39 insertions, 22 deletions
diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1
index 865bc10..8efd8e2 100644
--- a/.appveyor/build.ps1
+++ b/.appveyor/build.ps1
@@ -1,11 +1,13 @@
param(
- [string] $BuildDir = 'C:\Projects\build',
+ [string] $BuildDir = $null,
[string] $ProjectDir = $null,
+ [string] $Generator = $null,
[string] $Platform = $null,
[string] $Configuration = $null
)
$ErrorActionPreference = "Stop";
+Set-PSDebug -Strict
function Invoke-Exe {
param(
@@ -30,6 +32,19 @@ function Test-AppVeyor {
return Test-Path env:APPVEYOR
}
+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
+}
+
function Build-Project {
param(
[Parameter(Mandatory=$true)]
@@ -37,6 +52,8 @@ function Build-Project {
[Parameter(Mandatory=$true)]
[string] $BuildDir,
[Parameter(Mandatory=$true)]
+ [string] $Generator,
+ [Parameter(Mandatory=$true)]
[string] $Platform,
[Parameter(Mandatory=$true)]
[string] $Configuration
@@ -45,28 +62,28 @@ function Build-Project {
mkdir $BuildDir
cd $BuildDir
- Invoke-Exe { cmake -Wno-dev `
- -G "Visual Studio 14 2015" -A $Platform `
- $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
+ Invoke-Exe { cmake.exe -Wno-dev -G $Generator -A $Platform $ProjectDir }
+ Invoke-Exe { cmake.exe --build . --config $Configuration -- /m }
}
-Build-Project `
- -ProjectDir $ProjectDir `
- -BuildDir $BuildDir `
- -Platform $Platform `
- -Configuration $Configuration
+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
+ } finally {
+ if (Test-AppVeyor) {
+ cd $appveyor_cwd
+ }
+ }
}
+
+Build-ProjectAppVeyor