Files
terminalX/vendor/build/build-mosh.sh
kid 32520f09e0 feat: 完成 M2 mosh(LAN + tsnet 端到端验证)
- mosh(blinksh/ios C++)+protobuf-lite 交叉编译为 MoshCore.xcframework
  (CommonCrypto 后端、含 arm64 模拟器 slice;绕 autotools 用 CMake 直编 + 手写 config.h)
- tsnet 桥新增 UDP relay(StartMoshRelay:loopback↔tsnet.Dial 逐包搬运)
- MoshSession(pipe↔FILE*/pthread/SIGWINCH)+ MoshConnectScanner(TXCore,+4 单测=39)
- SSHTerminalModel 编排:SSH 引导 mosh-server→解析 MOSH CONNECT→relay→mosh 接管
- LAN 直连 + mosh-over-tsnet 均端到端验证通过,R1(tsnet UDP 数据报语义) 证伪

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-24 16:16:15 +08:00

77 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 交叉编译 mosh(blinksh/ios 分支) + protobuf-lite → MoshCore.xcframeworkiOS device/simulator/macOS
# crypto 后端 = Apple CommonCrypto系统内建特性宏由 build/mosh/config.h 手写提供(绕过 autotools
# 产出 library-only xcframework头文件与 modulemap 由包内 C target 提供,避免 modulemap 撞车,同 CSSHCore 教训)。
set -euo pipefail
BUILD="$(cd "$(dirname "$0")" && pwd)" # vendor/build
VENDOR="$(cd "$BUILD/.." && pwd)" # vendor
MOSH_SRC="$VENDOR/mosh/src"
PROTOBUF="$VENDOR/protobuf"
PROTOBUF_SRC="$PROTOBUF/src"
MOSH_CMAKE="$BUILD/mosh"
OUT="$BUILD/mosh-out"
ARTIFACTS="$VENDOR/../artifacts"
IOS_DEPLOY=17.0
MAC_DEPLOY=14.0
build_slice() {
local name="$1" sysname="$2" sysroot="$3" archs="$4" deploy="$5"
echo "==================== slice: $name ($archs @ $sysroot) ===================="
rm -rf "$OUT/$name"; mkdir -p "$OUT/$name"
local common=(
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_SYSTEM_NAME="$sysname"
-DCMAKE_OSX_SYSROOT="$sysroot"
-DCMAKE_OSX_ARCHITECTURES="$archs"
-DCMAKE_OSX_DEPLOYMENT_TARGET="$deploy"
)
# --- protobuf-lite仅 lite runtimemosh 的 .proto 是 proto2 + LITE_RUNTIME ---
cmake -S "$PROTOBUF" -B "$OUT/$name/protobuf" "${common[@]}" \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_PROTOC_BINARIES=OFF \
-Dprotobuf_BUILD_LIBPROTOC=OFF \
-Dprotobuf_BUILD_SHARED_LIBS=OFF \
-DCMAKE_CXX_STANDARD=14
cmake --build "$OUT/$name/protobuf" --target libprotobuf-lite -j8
# --- moshios我们的 CMakeLists编 src/*.cc ---
cmake -S "$MOSH_CMAKE" -B "$OUT/$name/mosh" "${common[@]}" \
-DMOSH_SRC="$MOSH_SRC" \
-DPROTOBUF_SRC="$PROTOBUF_SRC"
cmake --build "$OUT/$name/mosh" -j8
# --- 合并静态库 → 单一 libMoshCore.a ---
libtool -static -o "$OUT/$name/libMoshCore.a" \
"$OUT/$name/mosh/libmoshios.a" \
"$OUT/$name/protobuf/libprotobuf-lite.a"
echo "[+] $name$(lipo -archs "$OUT/$name/libMoshCore.a")"
}
pack_xcframework() {
echo "==================== packing MoshCore.xcframework (library-only) ===================="
rm -rf "$ARTIFACTS/MoshCore.xcframework"; mkdir -p "$ARTIFACTS"
local args=()
for s in "$@"; do
args+=(-library "$OUT/$s/libMoshCore.a")
done
xcodebuild -create-xcframework "${args[@]}" -output "$ARTIFACTS/MoshCore.xcframework"
echo "[+] MoshCore.xcframework:"; ls "$ARTIFACTS/MoshCore.xcframework"
}
case "${1:-all}" in
iossim) build_slice iossim iOS iphonesimulator "arm64;x86_64" "$IOS_DEPLOY" ;;
device) build_slice ios-arm64 iOS iphoneos "arm64" "$IOS_DEPLOY" ;;
macos) build_slice macos Darwin macosx "arm64" "$MAC_DEPLOY" ;;
all)
build_slice iossim iOS iphonesimulator "arm64;x86_64" "$IOS_DEPLOY"
build_slice ios-arm64 iOS iphoneos "arm64" "$IOS_DEPLOY"
build_slice macos Darwin macosx "arm64" "$MAC_DEPLOY"
pack_xcframework iossim ios-arm64 macos
;;
pack) shift; pack_xcframework "$@" ;;
esac