mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #3439 from marcovmun/VS-build-fix
This commit is contained in:
commit
2aa73dcbe2
|
@ -28,9 +28,17 @@ $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
|
||||
$dataPath = "$rootPath\data"
|
||||
$binDataPath = "$binPath\data"
|
||||
|
||||
# Create data directory in bin
|
||||
Write-Host "Create data directory..." -ForegroundColor Cyan
|
||||
New-Item -Force -ItemType Directory $binDataPath > $null
|
||||
|
||||
# Create symlinks
|
||||
Symlink-or-Copy "$binDataPath\language" "$dataPath\language"
|
||||
Symlink-or-Copy "$binDataPath\title" "$dataPath\title"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -27,3 +27,57 @@ function Prompt-User($message)
|
|||
$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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue