2015-12-10 01:13:20 +01:00
|
|
|
#########################################################
|
|
|
|
# Script to build and package OpenRCT2
|
2015-12-02 22:01:38 +01:00
|
|
|
# - Sets the source code preprocessor defines
|
|
|
|
# - Builds a clean release of OpenRCT2
|
|
|
|
# - Creates a ZIP for distribution
|
2015-12-10 01:13:20 +01:00
|
|
|
#########################################################
|
2015-12-02 22:01:38 +01:00
|
|
|
param (
|
2015-12-12 20:41:54 +01:00
|
|
|
[string]$Server = "",
|
|
|
|
[string]$BuildNumber = "",
|
|
|
|
[string]$GitBranch = ""
|
2015-12-02 22:01:38 +01:00
|
|
|
)
|
|
|
|
|
2015-12-12 19:55:10 +01:00
|
|
|
# Setup
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
|
|
|
|
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
|
|
|
|
|
2015-12-11 00:02:05 +01:00
|
|
|
# Get paths
|
2015-12-12 19:55:10 +01:00
|
|
|
$rootPath = Get-RootPath
|
2015-12-11 00:02:05 +01:00
|
|
|
|
2015-12-02 22:01:38 +01:00
|
|
|
# Set build attributes
|
2015-12-12 20:41:54 +01:00
|
|
|
function do-prepareSource()
|
2015-12-02 22:01:38 +01:00
|
|
|
{
|
2015-12-11 00:02:05 +01:00
|
|
|
Write-Host "Setting build #defines..." -ForegroundColor Cyan
|
2015-12-12 20:41:54 +01:00
|
|
|
if ($GitBranch -eq "")
|
|
|
|
{
|
|
|
|
$GitBranch = (git rev-parse --abbrev-ref HEAD)
|
|
|
|
}
|
|
|
|
$GitCommitSha1 = (git rev-parse HEAD)
|
|
|
|
$GitCommitSha1Short = (git rev-parse --short HEAD)
|
2015-12-02 22:01:38 +01:00
|
|
|
|
|
|
|
$defines = @{ }
|
2015-12-12 20:41:54 +01:00
|
|
|
$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;
|
2015-12-02 22:01:38 +01:00
|
|
|
|
2015-12-02 23:28:00 +01:00
|
|
|
$defineString = ""
|
|
|
|
foreach ($key in $defines.Keys) {
|
|
|
|
$value = $defines[$key]
|
|
|
|
if ($value -is [System.String]) {
|
|
|
|
$value = $value.Replace('"', '\"')
|
2015-12-02 22:01:38 +01:00
|
|
|
}
|
2015-12-02 23:28:00 +01:00
|
|
|
$defineString += "$key=""$value"";";
|
2015-12-02 22:01:38 +01:00
|
|
|
}
|
2015-12-02 23:28:00 +01:00
|
|
|
|
|
|
|
# Set the environment variable which the msbuild project will use
|
|
|
|
$env:OPENRCT2_DEFINES = $defineString;
|
2015-12-02 22:01:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Building OpenRCT2
|
|
|
|
function do-build()
|
|
|
|
{
|
2015-12-11 00:02:05 +01:00
|
|
|
Write-Host "Building OpenRCT2..." -ForegroundColor Cyan
|
2015-12-11 01:20:09 +01:00
|
|
|
& "$scriptsPath\build.ps1" all -Rebuild
|
2015-12-02 22:01:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Package
|
|
|
|
function do-package()
|
|
|
|
{
|
2015-12-11 00:02:05 +01:00
|
|
|
Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan
|
|
|
|
$releaseDir = "$rootPath\bin"
|
|
|
|
$distDir = "$rootPath\distribution"
|
|
|
|
$tempDir = "$rootPath\artifacts\temp"
|
|
|
|
$outZip = "$rootPath\artifacts\openrct2.zip"
|
2015-12-02 22:01:38 +01:00
|
|
|
|
|
|
|
# Create new temp directory
|
|
|
|
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
|
|
|
New-Item -Force -ItemType Directory $tempDir > $null
|
|
|
|
|
|
|
|
# Copy files to be archived
|
2015-12-10 01:13:20 +01:00
|
|
|
Copy-Item -Force -Recurse "$releaseDir\data" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$releaseDir\openrct2.exe" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$releaseDir\openrct2.dll" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$releaseDir\curl-ca-bundle.crt" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$releaseDir\SDL2.dll" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$distDir\changelog.txt" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$distDir\known_issues.txt" $tempDir -ErrorAction Stop
|
|
|
|
Copy-Item -Force "$distDir\readme.txt" $tempDir -ErrorAction Stop
|
2015-12-02 22:01:38 +01:00
|
|
|
|
2015-12-12 20:41:54 +01:00
|
|
|
# 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\*"
|
2015-12-02 22:01:38 +01:00
|
|
|
|
|
|
|
# Remove temp directory
|
|
|
|
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
|
2015-12-12 20:41:54 +01:00
|
|
|
do-prepareSource
|
2015-12-11 00:02:05 +01:00
|
|
|
do-build
|
2015-12-02 22:01:38 +01:00
|
|
|
do-package
|