2015-12-11 00:02:05 +01:00
|
|
|
#########################################################
|
|
|
|
# Script to build different parts of OpenRCT2
|
|
|
|
#########################################################
|
|
|
|
[CmdletBinding()]
|
|
|
|
param (
|
|
|
|
[Parameter(Mandatory = $false, Position = 1)]
|
|
|
|
[string]$Task = "openrct2",
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $false)]
|
2015-12-11 01:20:09 +01:00
|
|
|
[string]$Configuration = "Release",
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $false)]
|
2016-04-09 19:59:45 +02:00
|
|
|
[switch]$Rebuild = $false,
|
|
|
|
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
|
|
[switch]$Breakpad = $false
|
2015-12-11 00:02:05 +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
|
|
|
$binPath = Join-Path $rootPath "bin"
|
|
|
|
$openrct2Path = Join-Path $binPath "openrct2.exe"
|
|
|
|
|
|
|
|
function Build-Data()
|
|
|
|
{
|
2016-05-03 18:51:32 +02:00
|
|
|
$dataPath = "$rootPath\data"
|
|
|
|
$binDataPath = "$binPath\data"
|
|
|
|
|
|
|
|
# Create data directory in bin
|
|
|
|
Write-Host "Create data directory..." -ForegroundColor Cyan
|
|
|
|
New-Item -Force -ItemType Directory $binDataPath > $null
|
|
|
|
|
|
|
|
# Create symlinks
|
2016-05-26 14:32:08 +02:00
|
|
|
Symlink-or-Copy "$binDataPath\language" "$dataPath\language" > $null
|
2016-06-13 00:42:53 +02:00
|
|
|
Symlink-or-Copy "$binDataPath\shaders" "$dataPath\shaders" > $null
|
2016-05-26 14:32:08 +02:00
|
|
|
Symlink-or-Copy "$binDataPath\title" "$dataPath\title" > $null
|
2016-05-03 18:51:32 +02:00
|
|
|
|
2015-12-11 00:02:05 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
function Build-OpenRCT2()
|
|
|
|
{
|
|
|
|
Write-Host "Building OpenRCT2 ($Configuration)..." -ForegroundColor Cyan
|
2015-12-11 01:20:09 +01:00
|
|
|
|
|
|
|
$target = ""
|
|
|
|
if ($Rebuild)
|
|
|
|
{
|
|
|
|
$target = "/t:rebuild"
|
|
|
|
}
|
2016-04-09 19:59:45 +02:00
|
|
|
msbuild $rootPath\openrct2.sln /p:Breakpad=$Breakpad /p:Configuration=$Configuration /p:Platform=Win32 $target /v:minimal | Write-Host
|
2015-12-11 00:02:05 +01:00
|
|
|
return $LASTEXITCODE
|
|
|
|
}
|
|
|
|
|
|
|
|
function Build-G2()
|
|
|
|
{
|
|
|
|
# Check if OpenRCT2 binary exists
|
|
|
|
if (-not (Test-Path $openrct2Path))
|
|
|
|
{
|
|
|
|
Write-Host "You must build OpenRCT2 first before g2.dat can be built." -ForegroundColor Red
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host "Building g2.dat..." -ForegroundColor Cyan
|
|
|
|
& $openrct2Path sprite build "$binPath\data\g2.dat" "$rootPath\resources\g2"
|
|
|
|
return $LASTEXITCODE
|
|
|
|
}
|
|
|
|
|
|
|
|
function Build-All()
|
|
|
|
{
|
|
|
|
if (($result = (Build-Data )) -ne 0) { return $result }
|
|
|
|
if (($result = (Build-OpenRCT2)) -ne 0) { return $result }
|
|
|
|
if (($result = (Build-G2 )) -ne 0) { return $result }
|
|
|
|
}
|
|
|
|
|
|
|
|
# Script entry point
|
|
|
|
switch ($Task)
|
|
|
|
{
|
|
|
|
"data" { $result = Build-Data }
|
|
|
|
"openrct2" { $result = Build-OpenRCT2 }
|
|
|
|
"g2" { $result = Build-G2 }
|
|
|
|
"all" { $result = Build-All }
|
|
|
|
default { Write-Host "Unknown build task." -ForegroundColor Red
|
|
|
|
$result = 1 }
|
|
|
|
}
|
|
|
|
exit $result
|