From ce7afb92fd4e33f2f9ab34527f622ee9fe0d7e21 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 26 Aug 2016 00:45:57 +0100 Subject: [PATCH] Migrate update libs to msbuild project --- openrct2.proj | 41 +++++++++++++++++++-- openrct2.targets | 20 +++++++++- scripts/ps/common.psm1 | 83 ------------------------------------------ scripts/ps/install.ps1 | 63 -------------------------------- 4 files changed, 57 insertions(+), 150 deletions(-) delete mode 100644 scripts/ps/common.psm1 delete mode 100644 scripts/ps/install.ps1 diff --git a/openrct2.proj b/openrct2.proj index 34dddea81c..77abbbeb1a 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -18,6 +18,7 @@ 0.0.5 + 9 $(COMPUTERNAME) $(GIT_COMMIT_SHA1.Substring(0, 7)) @@ -52,6 +53,13 @@ OpenRCT2-$(Version)$(VersionExtension)-windows + + + https://github.com/OpenRCT2/Dependencies/releases/download/v$(TargetLibsVersion)/openrct2-libs-vs2015.zip + $(RootDir)lib\ + $(LibsPath)libversion + + @@ -91,9 +99,36 @@ + + + + + 0 + $([System.IO.File]::ReadAllText($(LibsVersionPath)).Trim()) + true + + + + + + + - - + + $(LibsPath)openrct2-libs-vs2015.zip + + + + + + + + + + + + + @@ -106,7 +141,7 @@ - + $(GIT_COMMIT_SHA1_SHORT) $(BuildString) ($(GIT_BRANCH)) diff --git a/openrct2.targets b/openrct2.targets index b6d141c4fb..cb86b35663 100644 --- a/openrct2.targets +++ b/openrct2.targets @@ -3,7 +3,7 @@ + AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> @@ -105,4 +105,22 @@ + + + + + + + + + + + + + diff --git a/scripts/ps/common.psm1 b/scripts/ps/common.psm1 deleted file mode 100644 index 17868366cf..0000000000 --- a/scripts/ps/common.psm1 +++ /dev/null @@ -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 - } -} diff --git a/scripts/ps/install.ps1 b/scripts/ps/install.ps1 deleted file mode 100644 index 9d5fc99185..0000000000 --- a/scripts/ps/install.ps1 +++ /dev/null @@ -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 -}