move scripts into ps sub directory

This commit is contained in:
IntelOrca
2015-12-12 18:55:10 +00:00
parent cb5dab3e57
commit 26908d8a9c
6 changed files with 28 additions and 15 deletions

78
scripts/ps/build.ps1 Normal file
View File

@@ -0,0 +1,78 @@
#########################################################
# Script to build different parts of OpenRCT2
#########################################################
[CmdletBinding()]
param (
[Parameter(Mandatory = $false, Position = 1)]
[string]$Task = "openrct2",
[Parameter(Mandatory = $false)]
[string]$Configuration = "Release",
[Parameter(Mandatory = $false)]
[switch]$Rebuild = $false
)
# Setup
$ErrorActionPreference = "Stop"
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
# Get paths
$rootPath = Get-RootPath
$binPath = Join-Path $rootPath "bin"
$openrct2Path = Join-Path $binPath "openrct2.exe"
function Build-Data()
{
Write-Host "Copying data to bin..." -ForegroundColor Cyan
New-Item -Force -ItemType Directory $binPath > $null
Copy-Item -Force -Recurse "$rootPath\data" $binPath
return 0
}
function Build-OpenRCT2()
{
Write-Host "Building OpenRCT2 ($Configuration)..." -ForegroundColor Cyan
$target = ""
if ($Rebuild)
{
$target = "/t:rebuild"
}
msbuild $rootPath\openrct2.sln /p:Configuration=$Configuration /p:Platform=Win32 $target /v:minimal | Write-Host
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

18
scripts/ps/common.psm1 Normal file
View File

@@ -0,0 +1,18 @@
#########################################################
# Common functions for OpenRCT2 PowerShell scripts
#########################################################
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
function Get-RootPath()
{
return Split-Path (Split-Path $scriptsPath)
}
function Prompt-User($message)
{
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$choice = $host.UI.PromptForChoice("", $message, $options, 1)
return ($choice -eq 0)
}

62
scripts/ps/install.ps1 Normal file
View File

@@ -0,0 +1,62 @@
#########################################################
# Script to install the latest dependencies for OpenRCT2
#########################################################
param (
[switch]$Force
)
Write-Host "Installing OpenRCT2 development environment for Windows" -ForegroundColor Cyan
# Setup
$ErrorActionPreference = "Stop"
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
# Constants
$libsUrl = "https://openrct2.website/files/orctlibs-vs.zip"
$libsVersion = 4
# Get paths
$rootPath = Get-RootPath
$libsPath = Join-Path $rootPath "lib"
$zipPath = Join-Path $libsPath "orctlibs.zip"
$libsVersionPath = Join-Path $libsPath "libversion"
# Check if we need to update the dependencies
$currentLibsVersion = 0
$updateLibs = $true
if (Test-Path $libsVersionPath)
{
$currentLibsVersion = [IO.File]::ReadAllText($libsVersionPath)
}
if ($currentLibsVersion -ge $libsVersion)
{
$updateLibs = $false
}
# Check if user needs to download dependencies
$libsPathExists = Test-Path $libsPath
if ($libsPathExists -and -not $updateLibs -and -not $Force)
{
if (Prompt-User "Dependencies already exists, reinstall?")
{
$updateLibs = $true
}
}
else
{
$updateLibs = $true
}
# Download latest version of the dependencies
if ($updateLibs) {
Write-Host "Updating dependencies..." -ForegroundColor Cyan
Remove-Item -Force -Recurse $libsPath -ErrorAction SilentlyContinue
New-Item -Force -ItemType Directory $libsPath > $null
Invoke-WebRequest $libsUrl -OutFile $zipPath
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $libsPath)
Remove-Item $zipPath -Force -ErrorAction SilentlyContinue
$libsVersion | Set-Content $libsVersionPath
}

89
scripts/ps/publish.ps1 Normal file
View File

@@ -0,0 +1,89 @@
#########################################################
# Script to build and package OpenRCT2
# - Sets the source code preprocessor defines
# - Builds a clean release of OpenRCT2
# - Creates a ZIP for distribution
#########################################################
param (
[string]$server = "",
[string]$buildNo = ""
)
# Setup
$ErrorActionPreference = "Stop"
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
# Get paths
$rootPath = Get-RootPath
# Set build attributes
function do-prepareSource($build_server = "", $build_number = "")
{
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)
$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;
$defineString = ""
foreach ($key in $defines.Keys) {
$value = $defines[$key]
if ($value -is [System.String]) {
$value = $value.Replace('"', '\"')
}
$defineString += "$key=""$value"";";
}
# Set the environment variable which the msbuild project will use
$env:OPENRCT2_DEFINES = $defineString;
}
# Building OpenRCT2
function do-build()
{
Write-Host "Building OpenRCT2..." -ForegroundColor Cyan
& "$scriptsPath\build.ps1" all -Rebuild
}
# Package
function do-package()
{
Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan
$releaseDir = "$rootPath\bin"
$distDir = "$rootPath\distribution"
$tempDir = "$rootPath\artifacts\temp"
$outZip = "$rootPath\artifacts\openrct2.zip"
# Create new temp directory
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
New-Item -Force -ItemType Directory $tempDir > $null
# Copy files to be archived
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
# Create archive
7za a -tzip -mx9 $outZip "$tempDir\*"
# Remove temp directory
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
}
do-prepareSource $server $buildNo
do-build
do-package

1
scripts/ps/run.ps1 Normal file
View File

@@ -0,0 +1 @@
&("..\bin\openrct2.exe") $args