mirror of https://github.com/OpenRCT2/OpenRCT2.git
turn publish into tasks and fix nsis installer
This commit is contained in:
parent
590923475b
commit
783cd2115a
|
@ -1,3 +1,3 @@
|
|||
$path = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
Write-Output "Building Windows Installer (NSIS script)";
|
||||
Write-Host "Building Windows Installer (NSIS script)";
|
||||
makensis /DVERSION_INCLUDE=$path\win32.txt $path\install.nsi > $path\win32.log;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
!define APPBITS 32 ; Define number of bits for the architecture
|
||||
!define EXTRA_VERSION "Vista, 7, 8.1 and 10"
|
||||
!define APPARCH "win32" ; Define the application architecture
|
||||
!define BINARY_DIR "${PATH_ROOT}build\Release"
|
||||
!define BINARY_DIR "${PATH_ROOT}bin"
|
||||
InstallDir "$PROGRAMFILES32\OpenRCT2\"
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
# - Creates a ZIP for distribution
|
||||
#########################################################
|
||||
param (
|
||||
[Parameter(Position = 1)]
|
||||
[string]$Task = "all",
|
||||
|
||||
[string]$Server = "",
|
||||
[string]$BuildNumber = "",
|
||||
[string]$GitBranch = "",
|
||||
|
@ -20,7 +23,7 @@ Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
|
|||
$rootPath = Get-RootPath
|
||||
|
||||
# Set build attributes
|
||||
function do-prepareSource()
|
||||
function Do-PrepareSource()
|
||||
{
|
||||
Write-Host "Setting build #defines..." -ForegroundColor Cyan
|
||||
if ($GitBranch -eq "")
|
||||
|
@ -48,19 +51,21 @@ function do-prepareSource()
|
|||
|
||||
# Set the environment variable which the msbuild project will use
|
||||
$env:OPENRCT2_DEFINES = $defineString;
|
||||
return 0
|
||||
}
|
||||
|
||||
# Building OpenRCT2
|
||||
function do-build()
|
||||
function Do-Build()
|
||||
{
|
||||
Write-Host "Building OpenRCT2..." -ForegroundColor Cyan
|
||||
& "$scriptsPath\build.ps1" all -Rebuild
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
# Package
|
||||
function do-package()
|
||||
function Do-Package()
|
||||
{
|
||||
Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan
|
||||
Write-Host "Publishing OpenRCT2 as zip..." -ForegroundColor Cyan
|
||||
$releaseDir = "$rootPath\bin"
|
||||
$distDir = "$rootPath\distribution"
|
||||
$tempDir = "$rootPath\artifacts\temp"
|
||||
|
@ -89,19 +94,25 @@ function do-package()
|
|||
if (-not (AppExists($7zcmd)))
|
||||
{
|
||||
Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red
|
||||
exit 1
|
||||
return 1
|
||||
}
|
||||
}
|
||||
& $7zcmd a -tzip -mx9 $outZip "$tempDir\*"
|
||||
& $7zcmd a -tzip -mx9 $outZip "$tempDir\*" | Write-Host
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to create zip." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
# Remove temp directory
|
||||
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
||||
return 0
|
||||
}
|
||||
|
||||
# Installer
|
||||
function do-installer()
|
||||
function Do-Installer()
|
||||
{
|
||||
Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan
|
||||
Write-Host "Publishing OpenRCT2 as installer..." -ForegroundColor Cyan
|
||||
$artifactsDir = "$rootPath\artifacts"
|
||||
$installerDir = "$rootPath\distribution\windows"
|
||||
|
||||
|
@ -113,26 +124,57 @@ function do-installer()
|
|||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to create installer." -ForegroundColor Red
|
||||
exit 1
|
||||
if (Test-Path -PathType Leaf "$installerDir\win32.log")
|
||||
{
|
||||
Get-Content "$installerDir\win32.log" | Write-Host
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
$binaries = (Get-ChildItem "$installerDir\*.exe" | Sort-Object -Property LastWriteTime -Descending)
|
||||
if ($binaries -eq 0)
|
||||
{
|
||||
Write-Host "Unable to find created installer." -ForegroundColor Red
|
||||
exit 1
|
||||
return 1
|
||||
}
|
||||
|
||||
Copy-Item $binaries[0].FullName $artifactsDir
|
||||
return 0
|
||||
}
|
||||
|
||||
do-prepareSource
|
||||
do-build
|
||||
if ($Installer)
|
||||
function Do-Task-Build()
|
||||
{
|
||||
do-installer
|
||||
if (($result = (Do-PrepareSource)) -ne 0) { return $result }
|
||||
if (($result = (Do-Build )) -ne 0) { return $result }
|
||||
return 0
|
||||
}
|
||||
else
|
||||
|
||||
function Do-Task-Package()
|
||||
{
|
||||
do-package
|
||||
if ($Installer)
|
||||
{
|
||||
if (($result = (Do-Installer)) -ne 0) { return $result }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($result = (Do-Package)) -ne 0) { return $result }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function Do-Task-All()
|
||||
{
|
||||
if (($result = (Do-Task-Build )) -ne 0) { return $result }
|
||||
if (($result = (Do-Task-Package)) -ne 0) { return $result }
|
||||
return 0
|
||||
}
|
||||
|
||||
# Script entry point
|
||||
switch ($Task)
|
||||
{
|
||||
"build" { $result = Do-Task-Build }
|
||||
"package" { $result = Do-Task-Package }
|
||||
"all" { $result = Do-Task-All }
|
||||
default { Write-Host "Unknown publish task." -ForegroundColor Red
|
||||
$result = 1 }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue