This commit is contained in:
2026-08-16 13:41:43 -03:00
parent 7b8e7bfbd0
commit 96ea761b72
76 changed files with 1399 additions and 3847 deletions
+11 -2
View File
@@ -15,12 +15,17 @@
param(
# Only build the Android client .so (skip the Linux servers).
[switch]$ClientOnly,
# Where to drop libdragontcp_client.so. Defaults to android\lib\arm64-v8a
# under this script; build_apk.ps1 passes its own app directory explicitly,
# which is what makes this work regardless of how the tree is nested.
[string]$AndroidLibDir,
# Path to the go executable.
[string]$GoBin = $(if ($env:GO_BIN) { $env:GO_BIN } else { 'go' })
)
$ErrorActionPreference = 'Stop'
$Root = $PSScriptRoot
if (-not $AndroidLibDir) { $AndroidLibDir = Join-Path $Root 'android\lib\arm64-v8a' }
function Invoke-Go {
param([hashtable]$Env, [string[]]$GoArgs)
@@ -40,16 +45,20 @@ function Invoke-Go {
$go = Get-Command $GoBin -ErrorAction SilentlyContinue
if (-not $go) { throw "Go compiler not found. Install from https://go.dev/dl/ or set -GoBin." }
New-Item -ItemType Directory -Force -Path "$Root\bin", "$Root\android\lib\arm64-v8a" | Out-Null
New-Item -ItemType Directory -Force -Path "$Root\bin", $AndroidLibDir | Out-Null
Push-Location "$Root\core"
try {
$ldflags = '-ldflags=-s -w'
Write-Host '[core] Android ARM64 client...' -ForegroundColor Cyan
Invoke-Go @{ CGO_ENABLED = '0'; GOOS = 'android'; GOARCH = 'arm64' } `
@('build', '-trimpath', $ldflags, '-o', "$Root\android\lib\arm64-v8a\libdragontcp_client.so", './cmd/dragontcp-client')
@('build', '-trimpath', $ldflags, '-o', (Join-Path $AndroidLibDir 'libdragontcp_client.so'), './cmd/dragontcp-client')
if (-not $ClientOnly) {
Write-Host '[core] Linux AMD64 client...' -ForegroundColor Cyan
Invoke-Go @{ CGO_ENABLED = '0'; GOOS = 'linux'; GOARCH = 'amd64' } `
@('build', '-trimpath', $ldflags, '-o', "$Root\bin\dragontcp-hybrid-client-linux-amd64", './cmd/dragontcp-client')
Write-Host '[core] Linux AMD64 server...' -ForegroundColor Cyan
Invoke-Go @{ CGO_ENABLED = '0'; GOOS = 'linux'; GOARCH = 'amd64' } `
@('build', '-trimpath', $ldflags, '-o', "$Root\bin\dragontcp-hybrid-server-linux-amd64", './cmd/dragontcp-server')