Feature: Add on-demand TLS transport with hot-switch to the Android client
Reuse the Linux OpenSSL TlsChannel implementation (platform guard widened to __linux__); the trust anchor lives in the app-private filesDir, injected via TlsSetAnchorDir in nativeInit before the connection thread starts. COMMAND_TLS_ENABLE/DISABLE save/remove the anchor, hot-reload and reconnect only when the transport actually changes, so the master menu takes effect within seconds without restarting the app. Login reports RES_TLS, refreshed before each re-login. The reconnect flag is consumed before the drop check and cleared before reconnecting so a switch racing a disconnect cannot cause an extra reconnect/login cycle. Cross-compile OpenSSL 3.5.0 per ABI with build_openssl_android.sh (NDK clang + MSYS2 perl/make), integrated into build_android_libs.ps1 (-OpenSslOnly). Static libs and per-ABI headers are tracked like the existing libzstd/libsign prebuilts; --exclude-libs keeps OpenSSL symbols private to libyama.so, isolated from the Java-layer Conscrypt. Co-Authored-By: Qoder <noreply@qoder.com>
This commit is contained in:
1 parent
36618b0ad0
commit
51747dc0ea
586 files changed
+183905
-35
No files matched your search
@@ -1,9 +1,12 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Build libzstd.a and libsign.a for Android (4 ABIs)
|
||||
Build libzstd.a, libsign.a and OpenSSL (libssl.a/libcrypto.a) for Android (4 ABIs)
|
||||
.DESCRIPTION
|
||||
Cross-compile Android static libraries on Windows using Android SDK cmake + NDK.
|
||||
Supports: arm64-v8a / armeabi-v7a (device), x86 / x86_64 (emulator)
|
||||
OpenSSL is built by build_openssl_android.sh (perl Configure + make). On Windows it
|
||||
needs MSYS2 (bash + full perl + make: pacman -S perl make); Git for Windows' stripped
|
||||
perl lacks required modules, and its bash loses env vars across MSYS runtimes.
|
||||
|
||||
Usage:
|
||||
cd C:\github\YAMA\android
|
||||
@@ -14,12 +17,14 @@
|
||||
-SimplePluginsPath Path to SimplePlugins repo (default: sibling directory)
|
||||
-ZstdOnly Build libzstd.a only
|
||||
-SignOnly Build libsign.a only
|
||||
-OpenSslOnly Build OpenSSL (libssl.a/libcrypto.a) only
|
||||
#>
|
||||
param(
|
||||
[switch]$Force,
|
||||
[string]$SimplePluginsPath = "",
|
||||
[switch]$ZstdOnly,
|
||||
[switch]$SignOnly
|
||||
[switch]$SignOnly,
|
||||
[switch]$OpenSslOnly
|
||||
)
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -80,11 +85,11 @@ if (-not $SIGN_SRC) {
|
||||
$SIGN_SRC = (Resolve-Path $candidate).Path
|
||||
}
|
||||
}
|
||||
if ((-not $ZstdOnly) -and (-not (Test-Path "$SIGN_SRC\license_unix.cpp"))) {
|
||||
if ((-not $ZstdOnly) -and (-not $OpenSslOnly) -and (-not (Test-Path "$SIGN_SRC\license_unix.cpp"))) {
|
||||
Write-Error "SimplePlugins not found: $SIGN_SRC`nUse -SimplePluginsPath C:\path\to\SimplePlugins"
|
||||
exit 1
|
||||
}
|
||||
if (-not $ZstdOnly) { Write-Host "sign: $SIGN_SRC" }
|
||||
if ((-not $ZstdOnly) -and (-not $OpenSslOnly)) { Write-Host "sign: $SIGN_SRC" }
|
||||
|
||||
# -- Common variables ----------------------------------------------------------
|
||||
$TOOLCHAIN = "$NDK\build\cmake\android.toolchain.cmake"
|
||||
@@ -94,7 +99,7 @@ $LIB_BASE = "$SCRIPT_DIR\app\src\main\cpp\lib"
|
||||
# ==============================================================================
|
||||
# Part 1 - libzstd.a
|
||||
# ==============================================================================
|
||||
if (-not $SignOnly) {
|
||||
if (-not $SignOnly -and -not $OpenSslOnly) {
|
||||
$ZSTD_VER = "1.5.7"
|
||||
$ZSTD_SRC = "$SCRIPT_DIR\zstd-$ZSTD_VER"
|
||||
|
||||
@@ -152,7 +157,7 @@ if (-not $SignOnly) {
|
||||
# ==============================================================================
|
||||
# Part 2 - libsign.a
|
||||
# ==============================================================================
|
||||
if (-not $ZstdOnly) {
|
||||
if (-not $ZstdOnly -and -not $OpenSslOnly) {
|
||||
foreach ($ABI in $ABIS) {
|
||||
$outFile = "$LIB_BASE\$ABI\libsign.a"
|
||||
if ((Test-Path $outFile) -and (-not $Force)) {
|
||||
@@ -187,6 +192,42 @@ if (-not $ZstdOnly) {
|
||||
Remove-Item -Recurse -Force "$SCRIPT_DIR\sign_build" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# Part 3 - OpenSSL (libssl.a / libcrypto.a)
|
||||
# ==============================================================================
|
||||
if (-not $ZstdOnly -and -not $SignOnly) {
|
||||
# OpenSSL 走 perl Configure + make(非 cmake),需要完整 perl。Git for Windows 的
|
||||
# 精简 perl 缺模块,且其 bash 与 MSYS2 跨运行时传子进程会丢环境变量,故优先用 MSYS2 bash。
|
||||
$BASH = $null
|
||||
if (Test-Path "C:\msys64\usr\bin\bash.exe") { $BASH = "C:\msys64\usr\bin\bash.exe" }
|
||||
if (-not $BASH) {
|
||||
$bashCmd = Get-Command bash -ErrorAction SilentlyContinue
|
||||
if ($bashCmd) { $BASH = $bashCmd.Source }
|
||||
}
|
||||
if (-not $BASH) {
|
||||
Write-Error "bash not found. Install MSYS2 (https://www.msys2.org) for OpenSSL's perl/make toolchain."
|
||||
exit 1
|
||||
}
|
||||
Write-Host "bash: $BASH"
|
||||
|
||||
# Windows 路径转 bash 形式(C:\foo -> /c/foo)
|
||||
$ndkBash = "/" + $NDK.Substring(0,1).ToLower() + ($NDK.Substring(2) -replace '\\','/')
|
||||
$scriptBash = "/" + $SCRIPT_DIR.Substring(0,1).ToLower() + ($SCRIPT_DIR.Substring(2) -replace '\\','/')
|
||||
$forceEnv = if ($Force) { "FORCE=1 " } else { "" }
|
||||
|
||||
foreach ($ABI in $ABIS) {
|
||||
$sslOut = "$LIB_BASE\$ABI\libssl.a"
|
||||
$cryptoOut = "$LIB_BASE\$ABI\libcrypto.a"
|
||||
if ((Test-Path $sslOut) -and (Test-Path $cryptoOut) -and (-not $Force)) {
|
||||
Write-Host "`n[skip] openssl $ABI -- already exists (use -Force to rebuild)"
|
||||
continue
|
||||
}
|
||||
Write-Host "`n===== openssl $ABI ====="
|
||||
& $BASH -c "export ANDROID_NDK='$ndkBash'; cd '$scriptBash'; ${forceEnv}./build_openssl_android.sh $ABI"
|
||||
if ($LASTEXITCODE -ne 0) { Write-Error "OpenSSL build failed for $ABI (see output above)"; exit 1 }
|
||||
}
|
||||
}
|
||||
|
||||
# -- Summary -------------------------------------------------------------------
|
||||
Write-Host "`n===== Done ====="
|
||||
Get-ChildItem $LIB_BASE -Recurse -Filter "*.a" | Sort-Object FullName |
|
||||
|
||||
Reference in new issue
Block a user