v2rayA/build-in-pwsh.ps1

62 lines
2.0 KiB
PowerShell
Raw Permalink Normal View History

2022-09-19 21:07:16 +08:00
Write-Host $PSScriptRoot
Function Get-build-tools(){
if ([String]::IsNullOrEmpty($(Get-Command git -ErrorAction ignore))) {
Write-Output "You don't install git, please install it and add it to your path."
}
if ([String]::IsNullOrEmpty($(Get-Command yarn -ErrorAction ignore))) {
Write-Output "You don't install yarn, please install it and add it to your path."
Write-Output "You should also install Node.js to make yarn work fine."
}
if ([String]::IsNullOrEmpty($(Get-Command go -ErrorAction ignore))) {
Write-Output "You don't install go, please install it and add it to your path."
}
if ([String]::IsNullOrEmpty($(Get-Command git -ErrorAction ignore))) {
exit 1
}
if ([String]::IsNullOrEmpty($(Get-Command yarn -ErrorAction ignore))) {
exit 1
}
if ([String]::IsNullOrEmpty($(Get-Command go -ErrorAction ignore))) {
exit 1
}
2021-09-17 17:21:58 +08:00
}
2022-09-19 21:07:16 +08:00
Function Build-v2rayA(){
#Get OS
2022-11-06 22:33:12 +08:00
if ([String]::IsNullOrEmpty($(Test-Path ${env:windir} -ErrorAction Ignore))) {
2022-09-19 21:07:16 +08:00
$v2rayaBin = "v2raya"
}
else {
2022-09-19 21:07:16 +08:00
$v2rayaBin = "v2raya.exe"
}
#Get Paths
$TerminalPath = Get-Item -LiteralPath ./ | ForEach-Object -Process { $_.FullName }
$CurrentPath = $PSScriptRoot
Set-Location -Path "$CurrentPath"
2022-09-19 21:07:16 +08:00
#Get Informations
$DateLong = git log -1 --format="%cd" --date=short
$Date = $DateLong -replace "-"; ""
$count = git rev-list --count HEAD
$commit = git rev-parse --short HEAD
#Version
$version = "unstable-$date.r$count.$commit"
#Disable CGO
${env:CGO_ENABLED} = "0"
#Set yarn's output path
2022-09-20 07:15:18 +08:00
${env:OUTPUT_DIR} = "$CurrentPath/service/server/router/web"
2022-09-19 21:07:16 +08:00
#Build Web Panel
2022-09-20 07:15:18 +08:00
Set-Location -Path "$CurrentPath/gui"
2022-09-19 21:07:16 +08:00
yarn; yarn build
#Build v2rayA
Set-Location -Path "$CurrentPath/service"
go build -ldflags "-X github.com/v2rayA/v2rayA/conf.Version=$version -s -w" -o "$CurrentPath/$v2rayaBin"
Set-Location -Path "$TerminalPath"
}
2021-09-17 17:21:58 +08:00
2022-09-19 21:07:16 +08:00
Set-PSDebug -Trace 1
Get-build-tools
Build-v2rayA
Set-PSDebug -Trace 0