2020-10-02 19:01:54 +02:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
# Configures a build envrionment for nim-status-client on windows.
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
|
2020-10-04 12:07:59 +02:00
|
|
|
# Helpers
|
|
|
|
|
function Install-Scoop {
|
|
|
|
|
if ((Get-Command scoop -ErrorAction SilentlyContinue) -ne $null) {
|
|
|
|
|
Write-Host "Scoop already installed!"
|
|
|
|
|
} else {
|
|
|
|
|
Write-Host "Installing Scoop package manager..."
|
|
|
|
|
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2026-07-24 10:46:18 +02:00
|
|
|
# Throw error on native command failure, which is not the default behavior.
|
|
|
|
|
# $PSNativeCommandUseErrorActionPreference works only in PowerShell 7.4.
|
|
|
|
|
function run {
|
|
|
|
|
$cmd = $args[0]
|
|
|
|
|
$cmdArgs = @($args | Select-Object -Skip 1)
|
|
|
|
|
& $cmd @cmdArgs
|
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
|
throw "ERROR: Exit code $LASTEXITCODE for command: '$cmd $cmdArgs'"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 17:06:20 +03:00
|
|
|
# Install Protobuf tool necessary to generate status-go files.
|
|
|
|
|
function Install-Protobuf-Go {
|
|
|
|
|
$ProtocGenVersion = "v1.34.1"
|
|
|
|
|
$ProtocGenZIP = "protoc-gen-go.$ProtocGenVersion.windows.amd64.zip"
|
|
|
|
|
$ProtocGenURL = "https://github.com/protocolbuffers/protobuf-go/releases/download/$ProtocGenVersion/$ProtocGenZIP"
|
|
|
|
|
$ProtocGenSHA256 = "403a619c4698fe5c4162c7f855803de3e8d8e0c187d7d51cbeb8d599f7a5a073"
|
|
|
|
|
(New-Object System.Net.WebClient).DownloadFile($ProtocGenURL, "$env:USERPROFILE\$ProtocGenZIP")
|
|
|
|
|
$ProtocGenRealSHA256 = (Get-Filehash -algorithm SHA256 "$env:USERPROFILE\$ProtocGenZIP").Hash
|
|
|
|
|
if ($ProtocGenRealSHA256 -ne $ProtocGenSHA256) {
|
|
|
|
|
throw "SHA256 hash does not match for $ProtocGenZIP !"
|
|
|
|
|
}
|
|
|
|
|
New-Item "$env:USERPROFILE\go\bin" -ItemType Directory -ea 0
|
2026-07-24 10:46:18 +02:00
|
|
|
run 7z x "-o$env:USERPROFILE\go\bin" -y "$env:USERPROFILE\$ProtocGenZIP"
|
2024-10-08 17:06:20 +03:00
|
|
|
}
|
|
|
|
|
|
2026-01-27 21:37:18 +01:00
|
|
|
function Scoop-Install([string]$package, [string]$version) {
|
2026-02-12 15:56:27 +01:00
|
|
|
$appName = ($package -split '/')[-1]
|
2026-01-27 21:37:18 +01:00
|
|
|
$fullName = "$package@$version"
|
2026-02-12 15:56:27 +01:00
|
|
|
|
|
|
|
|
if (Test-Path "C:\ProgramData\scoop\apps\$appName\$version") {
|
2026-01-27 21:37:18 +01:00
|
|
|
Write-Host "Already installed: $fullName"
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop list $appName
|
2026-01-27 21:37:18 +01:00
|
|
|
} else {
|
|
|
|
|
Write-Host "Installing: $fullName"
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop install --global "$fullName"
|
2026-01-27 21:37:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 19:01:54 +02:00
|
|
|
# Install Git and other dependencies
|
2020-10-04 12:07:59 +02:00
|
|
|
function Install-Dependencies {
|
|
|
|
|
Write-Host "Installing dependencies..."
|
2023-06-06 10:10:03 +02:00
|
|
|
if (!(scoop bucket list | Where { $_.Name -eq "extras" })) {
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop bucket add extras
|
2023-06-06 10:10:03 +02:00
|
|
|
}
|
2026-02-12 15:56:27 +01:00
|
|
|
if (!(scoop bucket list | Where { $_.Name -eq "status" })) {
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop bucket add status "https://github.com/status-im/infra-scoop-bucket.git"
|
2026-02-12 15:56:27 +01:00
|
|
|
}
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop update
|
2026-01-27 21:37:18 +01:00
|
|
|
# Trying to 'hold' git breaks due to how hosts are bootstrapped.
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop install --global git 7zip innounp dos2unix findutils wget rcedit
|
2026-01-27 21:37:18 +01:00
|
|
|
# Old versions can cause weird Scoop install errors.
|
2026-07-24 10:46:18 +02:00
|
|
|
run scoop update --global 7zip innounp
|
2026-01-27 21:37:18 +01:00
|
|
|
# WARNING: Remember to update PATH in ci/Jenkinsfile.windows.
|
2026-02-12 15:56:27 +01:00
|
|
|
Scoop-Install 'status/go' '1.24.7'
|
|
|
|
|
Scoop-Install 'status/nim' '2.2.6'
|
|
|
|
|
Scoop-Install 'status/cmake' '3.31.6'
|
|
|
|
|
Scoop-Install 'status/python' '3.13.5'
|
|
|
|
|
Scoop-Install 'status/mingw-winlibs' '15.2.0-13.0.0-r5'
|
|
|
|
|
Scoop-Install 'status/vcredist2022' '14.44.35211.0'
|
|
|
|
|
Scoop-Install 'status/protobuf' '3.20.1'
|
|
|
|
|
Scoop-Install 'status/openssl-lts' '3.0.19'
|
|
|
|
|
Scoop-Install 'status/inno-setup' '6.7.0'
|
|
|
|
|
Scoop-Install 'status/msys2' '2025-12-13'
|
2026-06-18 17:22:34 +03:00
|
|
|
Scoop-Install 'status/llvm' '22.1.8'
|
2026-08-10 19:57:34 +05:30
|
|
|
Scoop-Install 'status/temurin17-jdk' '17.0.19-10'
|
2026-02-11 14:35:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Install-MSYS2-Packages {
|
|
|
|
|
Write-Host "Installing MSYS2 MinGW64 packages..."
|
|
|
|
|
$msys2Bash = "C:\ProgramData\scoop\apps\msys2\current\usr\bin\bash.exe"
|
2026-06-18 11:09:36 +03:00
|
|
|
$packages = "mingw-w64-x86_64-rust mingw-w64-x86_64-postgresql mingw-w64-x86_64-pkgconf"
|
2026-02-11 14:35:25 +01:00
|
|
|
& $msys2Bash -lc "pacman -S --noconfirm --needed $packages"
|
2020-10-04 12:07:59 +02:00
|
|
|
}
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2020-10-04 12:07:59 +02:00
|
|
|
function Install-Qt-SDK {
|
|
|
|
|
Write-Host "Installing Qt $QtVersion SDK..."
|
2026-07-24 10:46:18 +02:00
|
|
|
run pip install aqtinstall
|
|
|
|
|
run aqt install-qt -O "C:\Qt" windows desktop $QtVersion win64_msvc2022_64 -m all
|
2020-10-04 12:07:59 +02:00
|
|
|
}
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2025-06-03 13:41:06 +02:00
|
|
|
# Install Microsoft Visual C++ Build Tools 17.13.35
|
2020-10-04 12:07:59 +02:00
|
|
|
function Install-VC-BuildTools {
|
2026-07-24 10:46:18 +02:00
|
|
|
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
|
|
|
$buildToolsPath = if (Test-Path $vswhere) {
|
|
|
|
|
& $vswhere `
|
|
|
|
|
-products Microsoft.VisualStudio.Product.BuildTools `
|
|
|
|
|
-latest `
|
|
|
|
|
-requires Microsoft.VisualStudio.Workload.VCTools `
|
|
|
|
|
-property installationPath
|
|
|
|
|
}
|
|
|
|
|
# Installer fails with exit code 1 if Build Tools already present.
|
|
|
|
|
if ($buildToolsPath) {
|
|
|
|
|
Write-Host "Visual Studio Build Tools already installed."
|
|
|
|
|
Return
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 13:41:06 +02:00
|
|
|
$VCBuildToolsUrl = "https://aka.ms/vs/17/release/vs_BuildTools.exe"
|
2020-10-04 12:07:59 +02:00
|
|
|
$VCBuildToolsExe = "$HOME\Downloads\vs_BuildTools.exe"
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2020-10-04 12:07:59 +02:00
|
|
|
Write-Host "Downloading Microsoft Visual C++ Build Tools..."
|
|
|
|
|
(New-Object System.Net.WebClient).DownloadFile($VCBuildToolsUrl, $VCBuildToolsExe)
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2020-10-04 12:07:59 +02:00
|
|
|
Write-Host "Installing Microsoft Visual C++ Build Tools..."
|
|
|
|
|
$VCBuildToolsArgs = $(
|
|
|
|
|
"--installPath", "C:\BuildTools",
|
|
|
|
|
"--quiet", "--wait", "--norestart", "--nocache",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.Workload.MSBuildTools",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.Workload.VCTools",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
|
2021-04-19 16:45:46 +02:00
|
|
|
"--add", "Microsoft.VisualStudio.Component.Windows10SDK.10240",
|
2020-10-04 12:07:59 +02:00
|
|
|
"--add", "Microsoft.VisualStudio.Component.Windows10SDK.14393",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.Component.Windows81SDK",
|
2023-06-20 20:48:06 +02:00
|
|
|
"--add", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81",
|
|
|
|
|
"--add", "Microsoft.VisualStudio.ComponentGroup.UWP.VC.v141.BuildTools"
|
2020-10-04 12:07:59 +02:00
|
|
|
)
|
2026-07-24 10:46:18 +02:00
|
|
|
$process = Start-Process -Wait -PassThru -FilePath $VCBuildToolsExe -ArgumentList $VCBuildToolsArgs
|
|
|
|
|
if ($process.ExitCode -ne 0) {
|
|
|
|
|
throw "ERROR: Build tools installation failed wit exit code: $($process.ExitCode)"
|
|
|
|
|
}
|
2020-10-04 12:07:59 +02:00
|
|
|
}
|
2020-10-02 19:01:54 +02:00
|
|
|
|
2020-10-04 12:07:59 +02:00
|
|
|
function Show-Success-Message {
|
|
|
|
|
Write-Host @"
|
2020-10-02 19:01:54 +02:00
|
|
|
|
|
|
|
|
SUCCESS!
|
|
|
|
|
|
|
|
|
|
Before you attempt to build nim-status-client you'll need a few environment variables set:
|
|
|
|
|
|
2025-06-03 13:41:06 +02:00
|
|
|
export QTDIR="/c/Qt/$QtVersion/msvc2022_64"
|
|
|
|
|
export Qt5_DIR="/c/Qt/$QtVersion/msvc2022_64"
|
2026-06-19 14:34:55 +03:00
|
|
|
export VCINSTALLDIR="/c/BuildTools/VC"
|
2026-06-18 11:09:36 +03:00
|
|
|
|
2020-10-02 19:01:54 +02:00
|
|
|
You might also have to include the following paths in your `$PATH:
|
|
|
|
|
|
2024-10-08 17:06:20 +03:00
|
|
|
export PATH=`"$env:USERPROFILE/go/bin:`$PATH`"
|
2021-07-15 14:12:18 +03:00
|
|
|
export PATH=`"/c/BuildTools/MSBuild/Current/Bin:`$PATH`"
|
2025-06-03 13:41:06 +02:00
|
|
|
export PATH=`"/c/BuildTools/VC/Tools/MSVC/14.44.35207/bin:`$PATH`"
|
2025-08-04 13:35:58 +02:00
|
|
|
export PATH=`"/c/ProgramData/scoop/apps/openssl-lts/current/bin:`$PATH`"
|
2021-07-15 14:12:18 +03:00
|
|
|
export PATH=`"/c/ProgramData/scoop/apps/inno-setup/current:`$PATH`"
|
2026-08-07 15:39:06 +03:00
|
|
|
export PATH=`"/c/ProgramData/scoop/apps/temurin17-jdk/17.0.19-10/bin:`$PATH`"
|
2020-10-02 19:01:54 +02:00
|
|
|
"@
|
2020-10-04 12:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Stop the script after first error
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
# Version of Qt SDK available form aqt
|
2026-03-25 22:48:57 +05:30
|
|
|
$QtVersion = "6.11.0"
|
2020-10-04 12:07:59 +02:00
|
|
|
|
|
|
|
|
# Don't run when sourcing script
|
|
|
|
|
If ($MyInvocation.InvocationName -ne ".") {
|
|
|
|
|
Install-Scoop
|
|
|
|
|
Install-Dependencies
|
2026-02-11 14:35:25 +01:00
|
|
|
Install-MSYS2-Packages
|
2024-10-08 17:06:20 +03:00
|
|
|
Install-Protobuf-Go
|
2020-10-04 12:07:59 +02:00
|
|
|
Install-Qt-SDK
|
|
|
|
|
Install-VC-BuildTools
|
|
|
|
|
Show-Success-Message
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|