2015-12-10 01:13:20 +01:00
|
|
|
#########################################################
|
|
|
|
# Script to install the latest dependencies for OpenRCT2
|
|
|
|
#########################################################
|
|
|
|
param (
|
2015-12-23 17:56:05 +01:00
|
|
|
[switch]$Force,
|
|
|
|
[switch]$Quiet
|
2015-12-10 01:13:20 +01:00
|
|
|
)
|
2015-12-11 00:02:05 +01:00
|
|
|
Write-Host "Installing OpenRCT2 development environment for Windows" -ForegroundColor Cyan
|
2015-12-10 01:13:20 +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-10 01:13:20 +01:00
|
|
|
|
2015-12-12 19:55:10 +01:00
|
|
|
# Constants
|
2016-05-20 13:17:32 +02:00
|
|
|
$libsVersion = 8
|
|
|
|
$libsUrl = "https://github.com/OpenRCT2/Dependencies/releases/download/v$libsVersion/openrct2-libs-vs2015.zip"
|
2015-12-10 01:13:20 +01:00
|
|
|
|
|
|
|
# Get paths
|
2015-12-12 19:55:10 +01:00
|
|
|
$rootPath = Get-RootPath
|
2015-12-10 01:13:20 +01:00
|
|
|
$libsPath = Join-Path $rootPath "lib"
|
2016-01-09 18:53:25 +01:00
|
|
|
$zipPath = Join-Path $libsPath "openrct2-libs-vs2015.zip"
|
2015-12-10 01:13:20 +01:00
|
|
|
$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)
|
|
|
|
{
|
2015-12-23 17:56:05 +01:00
|
|
|
if (-not $Quiet -and (Prompt-User "Dependencies already exists, reinstall?"))
|
2015-12-10 01:13:20 +01:00
|
|
|
{
|
|
|
|
$updateLibs = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$updateLibs = $true
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download latest version of the dependencies
|
|
|
|
if ($updateLibs) {
|
2015-12-11 00:02:05 +01:00
|
|
|
Write-Host "Updating dependencies..." -ForegroundColor Cyan
|
2015-12-10 01:13:20 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|