2021-01-18 15:48:06 +00:00
|
|
|
param (
|
|
|
|
[Parameter(Mandatory = $true)][string]$version,
|
|
|
|
[Parameter(Mandatory = $true)][string]$arch
|
|
|
|
)
|
|
|
|
|
2021-11-03 16:49:26 +00:00
|
|
|
Set-MpPreference -DisableRealtimeMonitoring $true
|
|
|
|
|
2022-11-17 12:52:38 +00:00
|
|
|
if ($arch -eq "arm64") {
|
|
|
|
# TODO: Remove when TeamCity subproject for windows/arm64 is set up.
|
|
|
|
Exit 0
|
|
|
|
}
|
|
|
|
|
2021-05-06 17:05:17 +00:00
|
|
|
# Install Chocolatey
|
|
|
|
#Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
|
|
|
|
|
2021-01-18 15:48:06 +00:00
|
|
|
# Install MinGW.
|
2022-07-11 21:48:51 +00:00
|
|
|
choco install -y mingw
|
2021-01-18 15:48:06 +00:00
|
|
|
|
|
|
|
# Install Procdump
|
|
|
|
if (-Not(Test-Path "C:\procdump"))
|
|
|
|
{
|
|
|
|
mkdir C:\procdump
|
|
|
|
Invoke-WebRequest -UserAgent wget -Uri https://download.sysinternals.com/files/Procdump.zip -OutFile C:\procdump\procdump.zip
|
|
|
|
&7z x -oC:\procdump\ C:\procdump\procdump.zip > $null
|
|
|
|
}
|
|
|
|
|
2021-01-26 04:48:27 +00:00
|
|
|
$env:PATH += ";C:\procdump;C:\mingw64\bin"
|
|
|
|
|
|
|
|
function GetGo($version) {
|
|
|
|
$env:GOROOT = "C:\go\$version"
|
|
|
|
if (-Not(Test-Path $env:GOROOT))
|
|
|
|
{
|
|
|
|
$file = "$version.windows-$arch.zip"
|
|
|
|
$url = "https://dl.google.com/go/$file"
|
|
|
|
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
|
|
|
|
&7z x -oC:\go $file > $null
|
|
|
|
Move-Item -Path C:\go\go -Destination $env:GOROOT -force
|
|
|
|
}
|
2021-01-18 15:48:06 +00:00
|
|
|
}
|
2021-01-26 04:48:27 +00:00
|
|
|
|
|
|
|
if ($version -eq "gotip") {
|
2021-12-22 18:26:21 +00:00
|
|
|
#Exit 0
|
2021-01-26 04:48:27 +00:00
|
|
|
$latest = Invoke-WebRequest -Uri https://golang.org/VERSION?m=text -UseBasicParsing | Select-Object -ExpandProperty Content
|
|
|
|
GetGo $latest
|
|
|
|
$env:GOROOT_BOOTSTRAP = $env:GOROOT
|
|
|
|
$env:GOROOT = "C:\go\go-tip"
|
|
|
|
Write-Host "Building Go with GOROOT_BOOTSTRAP $env:GOROOT_BOOTSTRAP"
|
|
|
|
if (-Not(Test-Path $env:GOROOT)) {
|
|
|
|
git clone https://go.googlesource.com/go C:\go\go-tip
|
|
|
|
Push-Location -Path C:\go\go-tip\src
|
|
|
|
} else {
|
|
|
|
Push-Location -Path C:\go\go-tip\src
|
|
|
|
git pull
|
|
|
|
}
|
|
|
|
.\make.bat
|
|
|
|
Pop-Location
|
|
|
|
} else {
|
|
|
|
# Install Go
|
|
|
|
Write-Host "Finding latest patch version for $version"
|
2021-07-24 18:14:45 +00:00
|
|
|
$versions = Invoke-WebRequest -Uri 'https://golang.org/dl/?mode=json&include=all' -UseBasicParsing | foreach {$_.Content} | ConvertFrom-Json
|
|
|
|
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version($|\.)" | Sort-Object -Descending | Select-Object -First 1
|
|
|
|
if ($v -eq $null) {
|
|
|
|
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version(rc)" | Sort-Object -Descending | Select-Object -First 1
|
|
|
|
}
|
|
|
|
if ($v -eq $null) {
|
|
|
|
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version(beta)" | Sort-Object -Descending | Select-Object -First 1
|
|
|
|
}
|
|
|
|
Write-Host "Go $v on $arch"
|
|
|
|
GetGo $v
|
2021-01-18 15:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$env:GOPATH = "C:\gopath"
|
2021-01-26 04:48:27 +00:00
|
|
|
$env:PATH += ";$env:GOROOT\bin;$env:GOPATH\bin"
|
2021-01-18 15:48:06 +00:00
|
|
|
Write-Host $env:PATH
|
|
|
|
Write-Host $env:GOROOT
|
|
|
|
Write-Host $env:GOPATH
|
2021-01-26 04:48:27 +00:00
|
|
|
|
2021-01-18 15:48:06 +00:00
|
|
|
go version
|
|
|
|
go env
|
2021-05-06 17:05:17 +00:00
|
|
|
go run _scripts/make.go test
|
2022-05-31 23:03:57 +00:00
|
|
|
$x = $LastExitCode
|
2022-05-03 17:35:24 +00:00
|
|
|
if ($version -ne "gotip") {
|
|
|
|
Exit $x
|
|
|
|
}
|
2022-09-21 20:39:44 +00:00
|
|
|
|
|
|
|
# TODO: Remove once we have a windows/arm64 builder.
|
|
|
|
# Test windows/arm64 compiles.
|
|
|
|
$env:GOARCH = "arm64"
|
|
|
|
go run _scripts/make.go build --tags exp.winarm64
|
|
|
|
$x = $LastExitCode
|
|
|
|
if ($version -ne "gotip") {
|
|
|
|
Exit $x
|
|
|
|
}
|