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-10 01:13:20 +01:00
|
|
|
[string]$server = "",
|
2015-12-02 22:01:38 +01:00
|
|
|
[string]$buildNo = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
# Set build attributes
|
|
|
|
function do-prepareSource($build_server = "", $build_number = "")
|
|
|
|
{
|
|
|
|
Write-Output "Setting build #defines..."
|
|
|
|
# $build_number = "";
|
|
|
|
# $build_server = "";
|
2015-12-02 23:28:00 +01:00
|
|
|
$build_branch = (git rev-parse --abbrev-ref HEAD)
|
|
|
|
$build_commit_sha1 = (git rev-parse HEAD)
|
|
|
|
$build_commit_sha1_short = (git rev-parse --short HEAD)
|
2015-12-02 22:01:38 +01:00
|
|
|
|
|
|
|
$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;
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
Write-Output "Building OpenRCT2..."
|
2015-12-10 01:13:20 +01:00
|
|
|
msbuild ..\projects\openrct2.sln /p:Configuration=Release /p:Platform=Win32 /t:rebuild /v:minimal
|
2015-12-02 22:01:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Package
|
|
|
|
function do-package()
|
|
|
|
{
|
|
|
|
Write-Output "Publishing OpenRCT2..."
|
2015-12-10 01:13:20 +01:00
|
|
|
$releaseDir = "..\build\Release"
|
|
|
|
$distDir = "..\distribution"
|
|
|
|
$tempDir = "..\artifacts\temp"
|
|
|
|
$outZip = "..\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
|
|
|
|
|
|
|
# Create archive
|
|
|
|
7za a -tzip -mx9 $outZip "$tempDir\*"
|
|
|
|
|
|
|
|
# Remove temp directory
|
|
|
|
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
|
2015-12-10 01:13:20 +01:00
|
|
|
# do-prepareSource $server $buildNo
|
|
|
|
# do-build
|
2015-12-02 22:01:38 +01:00
|
|
|
do-package
|