V14
This commit is contained in:
+11
-2
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user