跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

build.sh

80 行 · 3.7 KB历史下载
1#!/bin/bash
2set -euo pipefail
3mobile_dir="$(cd "$(dirname "$0")" && pwd)"
4cd "$mobile_dir"
5case "${1:-}" in
6 android|ios) platform="$1" ;;
7 android-release) platform=android ;;
8 ios-ipa|ios-ipa-basic)
9 platform=ios
10 if [[ $# != 2 || ! $2 =~ ^[A-Z0-9]{10}$ ]]; then
11 echo "Usage: mobile/build.sh $1 TEAM_ID (10 uppercase letters or digits)" >&2
12 exit 2
13 fi
14 ;;
15 *) echo "Usage: mobile/build.sh android | android-release | ios | ios-ipa TEAM_ID | ios-ipa-basic TEAM_ID" >&2; exit 2 ;;
16esac
17if [[ "$platform" == ios ]]; then
18 # xcrun distinguishes a missing SDK from a pending Xcode license or setup step.
19 xcrun --sdk iphoneos --show-sdk-path >/dev/null
20fi
21mkdir -p .build/bin ".build/$platform"
22node build-ui.mjs
23if [[ "$platform" == android ]]; then bash android/fetch-webkit.sh "$mobile_dir/.build/android"; fi
24bash scripts/licenses.sh
25(
26 cd bindings
27 go build -o ../.build/bin/gomobile golang.org/x/mobile/cmd/gomobile
28 go build -o ../.build/bin/gobind golang.org/x/mobile/cmd/gobind
29)
30export PATH="$mobile_dir/.build/bin:$PATH"
31if [[ -n "${JAVA_HOME:-}" ]]; then export PATH="$JAVA_HOME/bin:$PATH"; fi
32if [[ "$platform" == ios ]]; then
33 brand=".build/ios/Assets.xcassets/CageMark.imageset"
34 mkdir -p "$brand"
35 cp ../ui/src/logo.png "$brand/mark.png"
36 printf '%s\n' '{"images":[{"filename":"mark.png","idiom":"universal"}],"info":{"author":"xcode","version":1}}' > "$brand/Contents.json"
37 devices=".build/ios/Assets.xcassets/PairDevices.imageset"
38 mkdir -p "$devices"
39 cp assets/pair-devices.png "$devices/devices.png"
40 sed 's/mark.png/devices.png/' "$brand/Contents.json" > "$devices/Contents.json"
41 icon=".build/ios/Assets.xcassets/AppIcon.appiconset"
42 mkdir -p "$icon"
43 printf '%s\n' '{"info":{"author":"xcode","version":1}}' > ".build/ios/Assets.xcassets/Contents.json"
44 cp ios/AppIcon.json "$icon/Contents.json"
45 sips -z 1024 1024 ../ui/src/logo.png --out "$icon/Cage.png" >/dev/null
46 # One arm64 iPhone slice and one simulator slice for this Mac.
47 # Each platform framework is then passed to -create-xcframework exactly once.
48 (cd bindings && gomobile bind -target="ios/arm64,iossimulator/$(go env GOHOSTARCH)" -iosversion=17.0 -o "$mobile_dir/.build/ios/Cagemobile.xcframework" .)
49 if [[ "$1" == ios-ipa* ]]; then
50 scheme=CageMobile
51 if [[ "$1" == ios-ipa-basic ]]; then scheme=CageMobileBasic; fi
52 output=$(mktemp -d "$mobile_dir/.build/ios/device-XXXXXXXX")
53 xcodebuild -project ios/CageMobile.xcodeproj -scheme "$scheme" -configuration Release \
54 -destination 'generic/platform=iOS' -archivePath "$output/CageMobile.xcarchive" \
55 DEVELOPMENT_TEAM="$2" archive
56 xcodebuild -exportArchive -archivePath "$output/CageMobile.xcarchive" \
57 -exportOptionsPlist ios/DebuggingExport.plist -exportPath "$output/export"
58 ipa="$output/export/$scheme.ipa"
59 # Inspect the exported payload, which Xcode can re-sign after archiving.
60 ditto -x -k "$ipa" "$output/check"
61 app="$output/check/Payload/$scheme.app"
62 test -s "$app/embedded.mobileprovision"
63 codesign --verify --deep --strict "$app"
64 rm -r "$output/check"
65 printf 'Cage iPhone development IPA: %s\n' "$ipa"
66 else
67 xcodebuild -project ios/CageMobile.xcodeproj -target CageMobile -sdk iphoneos -configuration Debug \
68 CODE_SIGNING_ALLOWED=NO SYMROOT="$mobile_dir/.build/ios/products" OBJROOT="$mobile_dir/.build/ios/obj" build
69 fi
70else
71 : "${ANDROID_HOME:?Set ANDROID_HOME to the Android SDK directory}"
72 (cd bindings && gomobile bind -target=android/arm64 -androidapi=26 \
73 -ldflags='-extldflags=-Wl,-z,max-page-size=16384,-z,common-page-size=16384' \
74 -o "$mobile_dir/.build/android/Cagemobile.aar" .)
75 if [[ "$1" == android-release ]]; then
76 bash android/package.sh --release
77 else
78 bash android/package.sh
79 fi
80fi