Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,35 @@ if ($failed) {
Copy-Item $PSScriptRoot/tools/add-path.ps1 $target -Force -ErrorAction Ignore

$relative = Resolve-Path $target -Relative
Write-Host -ForegroundColor Green "`nEXE's are copied to $target ($relative)"
if (!$Clippy) {
Write-Host -ForegroundColor Green "`nEXE's are copied to $target ($relative)"

# remove the other target in case switching between them
$dirSeparator = [System.IO.Path]::DirectorySeparatorChar
if ($Release) {
$oldTarget = $target.Replace($dirSeparator + 'release', $dirSeparator + 'debug')
}
else {
$oldTarget = $target.Replace($dirSeparator + 'debug', $dirSeparator + 'release')
}
$env:PATH = $env:PATH.Replace($oldTarget, '')

$paths = $env:PATH.Split([System.IO.Path]::PathSeparator)
$found = $false
foreach ($path in $paths) {
if ($path -eq $target) {
$found = $true
break
# remove the other target in case switching between them
$dirSeparator = [System.IO.Path]::DirectorySeparatorChar
if ($Release) {
$oldTarget = $target.Replace($dirSeparator + 'release', $dirSeparator + 'debug')
}
else {
$oldTarget = $target.Replace($dirSeparator + 'debug', $dirSeparator + 'release')
}
$env:PATH = $env:PATH.Replace($oldTarget, '')

$paths = $env:PATH.Split([System.IO.Path]::PathSeparator)
$found = $false
foreach ($path in $paths) {
if ($path -eq $target) {
$found = $true
break
}
}
}

# remove empty entries from path
$env:PATH = [string]::Join([System.IO.Path]::PathSeparator, $env:PATH.Split([System.IO.Path]::PathSeparator, [StringSplitOptions]::RemoveEmptyEntries))
# remove empty entries from path
$env:PATH = [string]::Join([System.IO.Path]::PathSeparator, $env:PATH.Split([System.IO.Path]::PathSeparator, [StringSplitOptions]::RemoveEmptyEntries))

if (!$found) {
Write-Host -ForegroundCOlor Yellow "Adding $target to `$env:PATH"
$env:PATH += [System.IO.Path]::PathSeparator + $target
if (!$found) {
Write-Host -ForegroundCOlor Yellow "Adding $target to `$env:PATH"
$env:PATH += [System.IO.Path]::PathSeparator + $target
}
}

if ($Test) {
Expand Down