aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--coin/provisioning/common/windows/grpc.ps126
-rw-r--r--coin/provisioning/common/windows/helpers.ps132
-rw-r--r--coin/provisioning/common/windows/install-ffmpeg.ps111
-rw-r--r--coin/provisioning/common/windows/protobuf.ps126
4 files changed, 36 insertions, 59 deletions
diff --git a/coin/provisioning/common/windows/grpc.ps1 b/coin/provisioning/common/windows/grpc.ps1
index 5e0e1bf9..49fe945f 100644
--- a/coin/provisioning/common/windows/grpc.ps1
+++ b/coin/provisioning/common/windows/grpc.ps1
@@ -144,31 +144,7 @@ $env:Path = $oldPath
### MSVC
-# Add cl to path if it is not already there
-if (!(Get-Command cl.exe -ErrorAction SilentlyContinue)) {
- $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
- $vc_component = "Microsoft.VisualStudio.Component.VC.CoreIde"
- # We pick the oldest build tools we can find and use that to be compatible with it and any newer version:
- # If MSVC has an ABI break this will stop working, and yet another build must be added.
- $vs_location = (& $vswhere -nologo -products * -requires $vc_component -sort -format value -property installationPath | Select-Object -Last 1)
- $vcvars_location = Join-Path $vs_location "VC\Auxiliary\Build\"
-
- Push-Location $vcvars_location
-
- # This snippet was stolen from https://stackoverflow.com/a/2124759
- # Grabs all the environment variables that the script has set and assigns it
- # to environment variables in PowerShell (calling batch files creates a
- # cmd.exe instance which does not propagate environment variables)
- cmd /c "vcvarsall.bat $env:PROCESSOR_ARCHITECTURE & set" |
- ForEach-Object {
- if ($_ -match "=") {
- $v = $_.Split("=");
- Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
- }
- }
-
- Pop-Location
-}
+EnterVSDevShell
build-install-grpc -CC "cl" -CXX "cl" -BuildType "Release" -Postfix "msvc"
diff --git a/coin/provisioning/common/windows/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1
index 1967b02a..8dd3721a 100644
--- a/coin/provisioning/common/windows/helpers.ps1
+++ b/coin/provisioning/common/windows/helpers.ps1
@@ -274,3 +274,35 @@ function DeleteSchedulerTask {
Write-Host "Disabling $Task from Task Scheduler"
SCHTASKS /DELETE /TN "Microsoft\Windows\$Task" /F
}
+
+function GetVSPath {
+ Param (
+ [string]$VSWhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe",
+ [string]$Component = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
+ )
+
+ return (& $VSWhere -nologo -latest -products * -requires $Component -property installationPath)
+}
+
+function EnterVSDevShell {
+ # Add cl to path if it is not already there.
+ if (Get-Command cl.exe -ErrorAction SilentlyContinue) {
+ return $true
+ }
+
+ $vsWere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+ $vcComponent = "Microsoft.VisualStudio.Component.VC.CoreIde"
+ # We pick the oldest build tools we can find and use that to be compatible with it and any newer version:
+ # If MSVC has an ABI break this will stop working, and yet another build must be added.
+ $VSPath = (& $vsWere -nologo -products * -requires $vcComponent -sort -format value -property installationPath | Select-Object -Last 1)
+
+ Write-Host "Enter VisualStudio developer shell"
+ try {
+ Import-Module "$VSPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
+ Enter-VsDevShell -VsInstallPath $VSPath -DevCmdArguments "-arch=x64 -no_logo"
+ } catch {
+ Write-Host "Failed to enter VisualStudio DevShell"
+ return $false
+ }
+ return $true
+}
diff --git a/coin/provisioning/common/windows/install-ffmpeg.ps1 b/coin/provisioning/common/windows/install-ffmpeg.ps1
index a608bdba..72c406f9 100644
--- a/coin/provisioning/common/windows/install-ffmpeg.ps1
+++ b/coin/provisioning/common/windows/install-ffmpeg.ps1
@@ -107,15 +107,8 @@ function InstallMingwFfmpeg {
function InstallMsvcFfmpeg {
- $vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
- #$vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional"
-
- Write-Host "Enter VisualStudio developer shell"
- try {
- Import-Module "$vsPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
- Enter-VsDevShell -VsInstallPath $vsPath -DevCmdArguments "-arch=x64 -no_logo"
- } catch {
- Write-Host "Failed to enter VisualStudio DevShell"
+ $result = EnterVSDevShell
+ if (-Not $result) {
return $false
}
diff --git a/coin/provisioning/common/windows/protobuf.ps1 b/coin/provisioning/common/windows/protobuf.ps1
index 306d3397..910be44b 100644
--- a/coin/provisioning/common/windows/protobuf.ps1
+++ b/coin/provisioning/common/windows/protobuf.ps1
@@ -104,31 +104,7 @@ $env:Path = $oldPath
### MSVC
-# Add cl to path if it is not already there
-if (!(Get-Command cl.exe -ErrorAction SilentlyContinue)) {
- $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
- $vc_component = "Microsoft.VisualStudio.Component.VC.CoreIde"
- # We pick the oldest build tools we can find and use that to be compatible with it and any newer version:
- # If MSVC has an ABI break this will stop working, and yet another build must be added.
- $vs_location = (& $vswhere -nologo -products * -requires $vc_component -sort -format value -property installationPath | Select-Object -Last 1)
- $vcvars_location = Join-Path $vs_location "VC\Auxiliary\Build\"
-
- Push-Location $vcvars_location
-
- # This snippet was stolen from https://stackoverflow.com/a/2124759
- # Grabs all the environment variables that the script has set and assigns it
- # to environment variables in PowerShell (calling batch files creates a
- # cmd.exe instance which does not propagate environment variables)
- cmd /c "vcvarsall.bat $env:PROCESSOR_ARCHITECTURE & set" |
- ForEach-Object {
- if ($_ -match "=") {
- $v = $_.Split("=");
- Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
- }
- }
-
- Pop-Location
-}
+EnterVSDevShell
# We pass along an extra argument to stop protobuf linking with the static runtime
build-install-protobuf -CC "cl" -CXX "cl" -BuildType "Release" -Postfix "msvc" -ExtraArguments @("-Dprotobuf_MSVC_STATIC_RUNTIME=OFF")