From 73bca80426953af46066733586ee563427f7c184 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 12 Dec 2015 19:41:54 +0000 Subject: [PATCH] setup AppVeyor CI --- appveyor.yml | 13 +++++++++--- scripts/ps/common.psm1 | 11 +++++++++++ scripts/ps/publish.ps1 | 45 +++++++++++++++++++++++++++--------------- scripts/ps/run.ps1 | 4 +++- setenv.ps1 | 26 ++++++++++++------------ 5 files changed, 66 insertions(+), 33 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 892dc2d27d..081ac5567d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,11 @@ -version: 0.0.3.{build} +version: 0.0.4.{build} build_script: -- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% -- .\build.bat +- ps: >- + .\setenv.ps1 + + install + + publish -Server AppVeyor -BuildNumber $env:APPVEYOR_BUILD_NUMBER -GitBranch $env:APPVEYOR_REPO_BRANCH +artifacts: +- path: .\artifacts\openrct2.zip + name: OpenRCT2 diff --git a/scripts/ps/common.psm1 b/scripts/ps/common.psm1 index 91fd987831..f643f6da8a 100644 --- a/scripts/ps/common.psm1 +++ b/scripts/ps/common.psm1 @@ -3,6 +3,17 @@ ######################################################### $scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path +function AppExists($app) +{ + $result = (Get-Command $app -CommandType Application -ErrorAction SilentlyContinue) + return ($result -ne $null -and $result.Count -gt 0) +} + +function AddPath($path) +{ + $env:path = "$path;$env:path" +} + function Get-RootPath() { return Split-Path (Split-Path $scriptsPath) diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index db3432f1fb..956e35287b 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -5,8 +5,9 @@ # - Creates a ZIP for distribution ######################################################### param ( - [string]$server = "", - [string]$buildNo = "" + [string]$Server = "", + [string]$BuildNumber = "", + [string]$GitBranch = "" ) # Setup @@ -18,21 +19,22 @@ Import-Module "$scriptsPath\common.psm1" -DisableNameChecking $rootPath = Get-RootPath # Set build attributes -function do-prepareSource($build_server = "", $build_number = "") +function do-prepareSource() { Write-Host "Setting build #defines..." -ForegroundColor Cyan - # $build_number = ""; - # $build_server = ""; - $build_branch = (git rev-parse --abbrev-ref HEAD) - $build_commit_sha1 = (git rev-parse HEAD) - $build_commit_sha1_short = (git rev-parse --short HEAD) + if ($GitBranch -eq "") + { + $GitBranch = (git rev-parse --abbrev-ref HEAD) + } + $GitCommitSha1 = (git rev-parse HEAD) + $GitCommitSha1Short = (git rev-parse --short HEAD) $defines = @{ } - $defines["OPENRCT2_BUILD_NUMBER"] = $build_number; - $defines["OPENRCT2_BUILD_SERVER"] = $build_server; - $defines["OPENRCT2_BRANCH"] = $build_branch; - $defines["OPENRCT2_COMMIT_SHA1"] = $build_commit_sha1; - $defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $build_commit_sha1_short; + $defines["OPENRCT2_BUILD_NUMBER"] = $BuildNumber; + $defines["OPENRCT2_BUILD_SERVER"] = $Server; + $defines["OPENRCT2_BRANCH"] = $GitBranch; + $defines["OPENRCT2_COMMIT_SHA1"] = $GitCommitSha1; + $defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $GitCommitSha1Short; $defineString = "" foreach ($key in $defines.Keys) { @@ -77,13 +79,24 @@ function do-package() Copy-Item -Force "$distDir\known_issues.txt" $tempDir -ErrorAction Stop Copy-Item -Force "$distDir\readme.txt" $tempDir -ErrorAction Stop - # Create archive - 7za a -tzip -mx9 $outZip "$tempDir\*" + # Create archive using 7z (renowned for speed and compression) + $7zcmd = "7za" + if (-not (AppExists($7zcmd))) + { + # AppVeyor in particular uses '7z' instead + $7zcmd = "7z" + if (-not (AppExists($7zcmd))) + { + Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red + exit 1 + } + } + & $7zcmd a -tzip -mx9 $outZip "$tempDir\*" # Remove temp directory Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue } -do-prepareSource $server $buildNo +do-prepareSource do-build do-package diff --git a/scripts/ps/run.ps1 b/scripts/ps/run.ps1 index 577c611e60..e1e1737b05 100644 --- a/scripts/ps/run.ps1 +++ b/scripts/ps/run.ps1 @@ -1 +1,3 @@ -&("..\bin\openrct2.exe") $args +$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path +$rootPath = Split-Path (Split-Path $scriptsPath) +&("$rootPath\bin\openrct2.exe") $args diff --git a/setenv.ps1 b/setenv.ps1 index d648edf23b..15aadc5ef4 100644 --- a/setenv.ps1 +++ b/setenv.ps1 @@ -2,19 +2,12 @@ # Setups a PowerShell environment for OpenRCT2 development ########################################################### -function AppExists($app) -{ - $result = (Get-Command $app -CommandType Application -ErrorAction SilentlyContinue) - return ($result -ne $null -and $result.Count -gt 0) -} - -function AddPath($path) -{ - $env:path = "$path;$env:path" -} - +# Setup +$ErrorActionPreference = "Stop" $rootPath = Split-Path $Script:MyInvocation.MyCommand.Path $scriptsPath = "$rootPath\scripts\ps" +Import-Module "$scriptsPath\common.psm1" -DisableNameChecking + Write-Host "Setting up OpenRCT2 development environment for Windows" -ForegroundColor Cyan $appExists = @{} @@ -24,10 +17,17 @@ $appExists["7z"] = AppExists("7z"); if (-not $appExists["msbuild"]) { - $lookPath = Join-Path ${env:ProgramFiles(x86)} "MSBuild\14.0\Bin\amd64\MSBuild.exe" + if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") + { + $lookPath = Join-Path ${env:ProgramFiles(x86)} "MSBuild\14.0\Bin\amd64\MSBuild.exe" + } + else + { + $lookPath = Join-Path $env:ProgramFiles "MSBuild\14.0\Bin\MSBuild.exe" + } if (Test-Path $lookPath) { - AddPath($lookPath) + AddPath(Split-Path $lookPath) } else {