-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathInstallVcpkgPackages.ps1
58 lines (52 loc) · 1.72 KB
/
InstallVcpkgPackages.ps1
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
try {
cls
$CurrentDir = $PSScriptRoot
$CurrentDir
# Rename Control folder
"Rename Control folder"
Rename-Item "$CurrentDir\src\Control" -NewName Control_
# Check vcpkg install:
$VcpkgFolder = "$CurrentDir\src\vcpkg"
"Test to see if folder [$VcpkgFolder] exists"
if (Test-Path -Path $VcpkgFolder) {
"Path exists!"
} else {
"Path doesn't exist. Will try to update submodule"
git --version
git submodule update --remote
}
# Test again:
if (!(Test-Path -Path $VcpkgFolder)) {
"Can't get the vcpkg submodule. Try to pull the repo again and enable submodules"
return
}
"Check if vcpkg.exe exists:"
if (!(Test-Path -Path $VcpkgFolder\vcpkg.exe -PathType Leaf))
{
"vcpkg.exe does not exists, will try to generate it"
Start-Process -FilePath $VcpkgFolder\bootstrap-vcpkg.bat -Wait -NoNewWindow
}else{
"$VcpkgFolder\vcpkg.exe exists"
}
# Check again
if (!(Test-Path -Path $VcpkgFolder\vcpkg.exe -PathType Leaf)){
"Can't generate vcpkg.exe. Run bootstrap-vcpkg.bat manually"
return
}
"Run vcpkg.exe install"
Set-Location $CurrentDir\src\
# Sadly only one triplet can be installed, so added in the pre-build event as well:
Start-Process -FilePath $VcpkgFolder\vcpkg.exe -ArgumentList "Install --triplet=x64-windows" -Wait -NoNewWindow
Set-Location $CurrentDir
}
catch {
Write-Host "An error occurred:"
Write-Host $_.ScriptStackTrace
Write-Host $_
}
finally {
# Always rename back:
"Rename Control folder back"
Set-Location $CurrentDir
Rename-Item "$CurrentDir\src\Control_" -NewName Control -ErrorAction SilentlyContinue
}