-
Notifications
You must be signed in to change notification settings - Fork 531
Expand file tree
/
Copy pathappveyor_helpers.ps1
More file actions
96 lines (84 loc) · 2.32 KB
/
appveyor_helpers.ps1
File metadata and controls
96 lines (84 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Helper function to extract vars out of the vsvars batch file
function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}
# Helper function to provide the bin-folder path to mingw
function Get-MinGWBin() {
if ($env:Platform -like '*64') {
Write-Output 'C:\Tools\mingw64\bin'
}
else {
Write-Output 'C:\Tools\mingw32\bin'
}
}
# Helper function to provide the toolchain file for clang
function Get-ClangToolchainFilename() {
if ($env:Platform -like '*64') {
Write-Output 'clang+mingw-win64.toolchain.cmake'
}
else {
Write-Output 'clang+mingw-win32.toolchain.cmake'
}
}
# Helper function to provide the bin-folder path to cygwin
function Get-CygwinBin() {
if ($env:Platform -like '*64') {
Write-Output 'C:\cygwin64\bin'
}
else {
Write-Output 'C:\cygwin\bin'
}
}
function Add-PathFolder($folder)
{
if (-not (Test-Path $folder))
{
Write-Host "Not adding $folder to the PATH, it does not exist"
}
[bool]$alreadyInPath = $false
[System.Collections.ArrayList]$pathFolders = New-Object System.Collections.ArrayList
$env:Path -split ";" | foreach { $pathFolders.Add($_) | Out-Null }
for ([int]$i = 0; $i -lt $pathFolders.Count; $i++)
{
if ([string]::Compare($pathFolders[$i], $folder, $true) -eq 0)
{
$alreadyInPath = $true
break
}
}
if (-not $alreadyInPath)
{
Write-Host "Adding $folder to the PATH"
$pathFolders.Insert(0, $folder)
$env:Path = $pathFolders -join ";"
}
}
function Remove-PathFolder($folder)
{
[System.Collections.ArrayList]$pathFolders = New-Object System.Collections.ArrayList
$env:Path -split ";" | foreach { $pathFolders.Add($_) | Out-Null }
for ([int]$i = 0; $i -lt $pathFolders.Count; $i++)
{
if ([string]::Compare($pathFolders[$i], $folder, $true) -eq 0)
{
Write-Host "Removing $folder from the PATH"
$pathFolders.RemoveAt($i)
$i--
}
}
$env:Path = $pathFolders -join ";"
}
function Set-Path($newPath)
{
$env:RestorePath = $env:Path
$env:Path = $newPath
}
function Restore-Path()
{
$env:Path = $env:RestorePath
}