Update GaCy-GO

This commit is contained in:
CAtlas0784 committed 2026-10-28 18:54:43 +07:00
1 parent da8a32f60d
commit 0cbe460e49
345 files changed
+98202 -77559

No files matched your search

+20 -6
View File
@@ -21,15 +21,17 @@ function Resolve-ProjectPath([string]$Path) {
if ([IO.Path]::IsPathRooted($Path)) { return [IO.Path]::GetFullPath($Path) }
return [IO.Path]::GetFullPath((Join-Path $PSScriptRoot $Path))
}
function Stop-ProjectServer([string]$Name) {
$target = Resolve-ProjectPath ($Name + '.exe')
function Stop-ProjectServerAt([string]$Name, [string]$Target) {
Get-Process -Name $Name -ErrorAction SilentlyContinue | ForEach-Object {
if ($_.Path -and [string]::Equals($_.Path, $target, [StringComparison]::OrdinalIgnoreCase)) {
if ($_.Path -and [string]::Equals($_.Path, $Target, [StringComparison]::OrdinalIgnoreCase)) {
Stop-Process -Id $_.Id -ErrorAction Stop
if (-not $_.WaitForExit(5000)) { throw "Server did not stop: $target" }
if (-not $_.WaitForExit(5000)) { throw "Server did not stop: $Target" }
}
}
}
function Stop-ProjectServer([string]$Name) {
Stop-ProjectServerAt $Name (Resolve-ProjectPath ($Name + '.exe'))
}
function Start-ProjectServer([string]$Name) {
$path = Resolve-ProjectPath ($Name + '.exe')
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "$Name is not built. Run build first." }
@@ -40,18 +42,29 @@ function Start-ProjectServer([string]$Name) {
}
function Build-Servers {
$go = Resolve-GoToolchain $settings.launcher
$shipDirectory = Resolve-ProjectPath 'for ship'
New-Item -ItemType Directory -Path $shipDirectory -Force | Out-Null
foreach ($name in @('gameserver', 'sdkserver')) {
$next = Resolve-ProjectPath ($name + '-go.next.exe')
& $go build -o $next ('./cmd/' + $name)
if ($LASTEXITCODE -ne 0) { throw "Build failed: $name. Existing binaries were not replaced." }
$shipName = $name + '-go'
$shipNext = Join-Path $shipDirectory ($shipName + '.next.exe')
& $go build -tags ship -o $shipNext ('./cmd/' + $name)
if ($LASTEXITCODE -ne 0) { throw "Shipping build failed: $name. Existing binaries were not replaced." }
}
foreach ($name in @('gameserver-go', 'sdkserver-go')) {
$next = Resolve-ProjectPath ($name + '.next.exe')
$target = Resolve-ProjectPath ($name + '.exe')
$shipNext = Join-Path $shipDirectory ($name + '.next.exe')
$shipTarget = Join-Path $shipDirectory ($name + '.exe')
Stop-ProjectServer $name
Stop-ProjectServerAt $name $shipTarget
Move-Item -LiteralPath $next -Destination $target -Force
Move-Item -LiteralPath $shipNext -Destination $shipTarget -Force
}
Write-Host 'Build successful. Binaries are in the project root.'
Write-Host "Build successful. Standard binaries are in the project root; self-contained binaries are in '$shipDirectory'."
}
function Start-External([string]$Setting, [string]$EnvironmentName) {
$path = [Environment]::GetEnvironmentVariable($EnvironmentName)
@@ -155,6 +168,7 @@ try {
Write-Host '[1] Build, start servers and game (default)'
Write-Host '[2] Start servers | [3] SDK only | [4] Game server only'
Write-Host '[5] Start servers and proxy | [6] Build only | [7] Exit | [8] Stop servers'
Write-Host '[9] Check/install Go build requirement'
$Action = Read-Host 'Select'
if ([string]::IsNullOrWhiteSpace($Action)) { $Action = '1' }
}
@@ -165,7 +179,7 @@ try {
{ $_ -in @('4','gs') } { Start-ProjectServer 'gameserver-go'; break }
{ $_ -in @('5','proxy') } { Start-ProjectServer 'sdkserver-go'; Start-ProjectServer 'gameserver-go'; Start-External 'proxy_path' 'GAC_PROXY_PATH'; break }
{ $_ -in @('6','build') } { Build-Servers; break }
'requirements' { $go = Resolve-GoToolchain $settings.launcher; Write-Host "Go ready: $go"; break }
{ $_ -in @('9','requirements') } { $go = Resolve-GoToolchain $settings.launcher; Write-Host "Go ready: $go"; break }
'7' { break }
{ $_ -in @('8','stop') } { Stop-ProjectServer 'sdkserver-go'; Stop-ProjectServer 'gameserver-go'; break }
default { throw "Unknown action: $Action" }