1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 09:14:58 +01:00

Migrate update libs to msbuild project

This commit is contained in:
Ted John
2016-08-26 00:45:57 +01:00
parent f416da96f4
commit ce7afb92fd
4 changed files with 57 additions and 150 deletions

View File

@@ -1,83 +0,0 @@
#########################################################
# Common functions for OpenRCT2 PowerShell scripts
#########################################################
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
function AppExists($app)
{
$result = (Get-Command $app -CommandType Application -ErrorAction SilentlyContinue)
return ($result -ne $null -and $result.Count -gt 0)
}
function AddPath($path)
{
$env:path = "$path;$env: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)
}
function Resolve-PathFromBase($path)
{
$rootPath = Get-RootPath
if ($path.StartsWith($rootPath)) {
$path = $path.Remove(0, $rootPath.Length + 1)
}
return $path
}
function Symlink-or-Copy($path, $target)
{
$pathDirectory = Split-Path $path
$pathName = Split-Path $path -Leaf
$friendlyPath = Resolve-PathFromBase $path
$friendlyTarget = Resolve-PathFromBase $target
# If the path is not a symlink, copy files instead
$mustCopy = $false
if (Test-Path $path)
{
if (-not ((Get-Item $path).Attributes -band [IO.FileAttributes]::ReparsePoint))
{
$mustCopy = $true
}
}
$symlinkSuccessful = $false
if (-not $mustCopy)
{
try
{
Write-Host "Symlink $friendlyPath to $friendlyTarget..." -ForegroundColor Cyan
New-Item -Force -ItemType SymbolicLink -Path $pathDirectory -Name $pathName -Target $target -ErrorAction Stop
$symlinkSuccessful = $true
}
catch [System.Management.Automation.ParameterBindingException]
{
Write-Host " Your powershell can not create symlinks, try updating it" -ForegroundColor Red
}
catch [System.UnauthorizedAccessException]
{
Write-Host " You need to run powershell in administration mode to create symlinks" -ForegroundColor Red
}
}
if (-not $symlinkSuccessful)
{
Write-Host "Copying $friendlyTarget to $friendlyPath..." -ForegroundColor Cyan
New-Item -Force -Type Directory $path > $null
Copy-Item -Force -Recurse "$target\*" $path
}
}

View File

@@ -1,63 +0,0 @@
#########################################################
# Script to install the latest dependencies for OpenRCT2
#########################################################
param (
[switch]$Force,
[switch]$Quiet
)
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
$libsVersion = 9
$libsUrl = "https://github.com/OpenRCT2/Dependencies/releases/download/v$libsVersion/openrct2-libs-vs2015.zip"
# Get paths
$rootPath = Get-RootPath
$libsPath = Join-Path $rootPath "lib"
$zipPath = Join-Path $libsPath "openrct2-libs-vs2015.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 (-not $Quiet -and (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
}