-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·287 lines (243 loc) · 7.62 KB
/
build.sh
File metadata and controls
executable file
·287 lines (243 loc) · 7.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/bin/bash
# Claude Code Proxy - Build Script
# Builds Universal Binary DMG for macOS (Intel + Apple Silicon)
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
PROJECT_NAME="ccb"
VERSION="1.0"
QT_PATH="${QT_PATH:-/Users/firshme/Qt/6.10.1/macos}"
BUILD_DIR="build"
DMG_NAME="${PROJECT_NAME}-${VERSION}-universal.dmg"
# Print banner
echo -e "${BLUE}"
echo "============================================="
echo " Claude Code Proxy - Build Script"
echo " Version: ${VERSION}"
echo "============================================="
echo -e "${NC}"
# Check Qt installation
check_qt() {
echo -e "${YELLOW}[1/6] Checking Qt installation...${NC}"
if [ ! -d "$QT_PATH" ]; then
echo -e "${RED}Error: Qt not found at $QT_PATH${NC}"
echo "Please set QT_PATH environment variable or install Qt 6.10.1"
echo "Example: export QT_PATH=/path/to/Qt/6.10.1/macos"
exit 1
fi
if [ ! -f "$QT_PATH/bin/qmake" ]; then
echo -e "${RED}Error: qmake not found in $QT_PATH/bin${NC}"
exit 1
fi
QT_VERSION=$("$QT_PATH/bin/qmake" -query QT_VERSION)
echo -e "${GREEN}✓ Found Qt $QT_VERSION at $QT_PATH${NC}"
}
# Check dependencies
check_dependencies() {
echo -e "${YELLOW}[2/6] Checking dependencies...${NC}"
# Check cmake
if ! command -v cmake &> /dev/null; then
echo -e "${RED}Error: cmake not found. Please install cmake.${NC}"
exit 1
fi
CMAKE_VERSION=$(cmake --version | head -n1)
echo -e "${GREEN}✓ $CMAKE_VERSION${NC}"
# Check Xcode command line tools
if ! command -v clang &> /dev/null; then
echo -e "${RED}Error: Xcode command line tools not found.${NC}"
echo "Please run: xcode-select --install"
exit 1
fi
CLANG_VERSION=$(clang --version | head -n1)
echo -e "${GREEN}✓ $CLANG_VERSION${NC}"
# Check hdiutil (for DMG creation)
if ! command -v hdiutil &> /dev/null; then
echo -e "${RED}Error: hdiutil not found.${NC}"
exit 1
fi
echo -e "${GREEN}✓ hdiutil available${NC}"
}
# Clean build directory
clean_build() {
echo -e "${YELLOW}[3/6] Cleaning build directory...${NC}"
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
echo -e "${GREEN}✓ Removed old build directory${NC}"
fi
mkdir -p "$BUILD_DIR"
echo -e "${GREEN}✓ Created fresh build directory${NC}"
}
# Configure with CMake
configure() {
echo -e "${YELLOW}[4/6] Configuring with CMake...${NC}"
cd "$BUILD_DIR"
cmake \
-DCMAKE_PREFIX_PATH="$QT_PATH" \
-DCMAKE_BUILD_TYPE=Release \
..
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ CMake configuration successful${NC}"
else
echo -e "${RED}Error: CMake configuration failed${NC}"
exit 1
fi
cd ..
}
# Build the project
build() {
echo -e "${YELLOW}[5/6] Building project...${NC}"
cd "$BUILD_DIR"
# Get number of CPU cores for parallel build
CORES=$(sysctl -n hw.ncpu)
echo "Building with $CORES parallel jobs..."
cmake --build . --parallel "$CORES"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Build successful${NC}"
else
echo -e "${RED}Error: Build failed${NC}"
exit 1
fi
cd ..
}
# Deploy and create DMG
create_dmg() {
echo -e "${YELLOW}[6/6] Creating DMG installer...${NC}"
cd "$BUILD_DIR"
# Deploy Qt frameworks and create DMG
cmake --build . --target dmg
if [ $? -eq 0 ] && [ -f "$DMG_NAME" ]; then
echo -e "${GREEN}✓ DMG created successfully${NC}"
else
echo -e "${RED}Error: DMG creation failed${NC}"
exit 1
fi
cd ..
}
# Verify the build
verify_build() {
echo ""
echo -e "${BLUE}=============================================${NC}"
echo -e "${BLUE} Build Verification${NC}"
echo -e "${BLUE}=============================================${NC}"
APP_PATH="$BUILD_DIR/${PROJECT_NAME}.app"
DMG_PATH="$BUILD_DIR/$DMG_NAME"
BINARY_PATH="$APP_PATH/Contents/MacOS/$PROJECT_NAME"
# Check app bundle
if [ -d "$APP_PATH" ]; then
echo -e "${GREEN}✓ App bundle: $APP_PATH${NC}"
APP_SIZE=$(du -sh "$APP_PATH" | cut -f1)
echo " Size: $APP_SIZE"
else
echo -e "${RED}✗ App bundle not found${NC}"
fi
# Check architectures
if [ -f "$BINARY_PATH" ]; then
ARCHS=$(lipo -info "$BINARY_PATH" 2>/dev/null | sed 's/.*are: //')
echo -e "${GREEN}✓ Architectures: $ARCHS${NC}"
fi
# Check deployment target
if [ -f "$BINARY_PATH" ]; then
MINOS=$(otool -l "$BINARY_PATH" | grep -A 3 "LC_BUILD_VERSION" | grep "minos" | head -1 | awk '{print $2}')
echo -e "${GREEN}✓ Minimum macOS: $MINOS${NC}"
fi
# Check DMG
if [ -f "$DMG_PATH" ]; then
DMG_SIZE=$(du -sh "$DMG_PATH" | cut -f1)
echo -e "${GREEN}✓ DMG: $DMG_PATH${NC}"
echo " Size: $DMG_SIZE"
else
echo -e "${RED}✗ DMG not found${NC}"
fi
# Check Info.plist
PLIST_PATH="$APP_PATH/Contents/Info.plist"
if [ -f "$PLIST_PATH" ]; then
MIN_VERSION=$(plutil -p "$PLIST_PATH" | grep LSMinimumSystemVersion | sed 's/.*=> "//' | sed 's/"//')
echo -e "${GREEN}✓ LSMinimumSystemVersion: $MIN_VERSION${NC}"
fi
}
# Print summary
print_summary() {
echo ""
echo -e "${BLUE}=============================================${NC}"
echo -e "${GREEN} Build Complete!${NC}"
echo -e "${BLUE}=============================================${NC}"
echo ""
echo "Output files:"
echo " App: $(pwd)/$BUILD_DIR/${PROJECT_NAME}.app"
echo " DMG: $(pwd)/$BUILD_DIR/$DMG_NAME"
echo ""
echo "Supported platforms:"
echo " - macOS 13.0+ (Ventura, Sonoma, Sequoia)"
echo " - Intel Mac (x86_64)"
echo " - Apple Silicon (arm64)"
echo ""
}
# Main execution
main() {
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Working directory: $SCRIPT_DIR"
echo ""
check_qt
check_dependencies
clean_build
configure
build
create_dmg
verify_build
print_summary
}
# Parse command line arguments
case "${1:-}" in
clean)
echo "Cleaning build directory..."
rm -rf "$BUILD_DIR"
echo "Done."
;;
configure)
check_qt
check_dependencies
clean_build
configure
;;
build)
cd build 2>/dev/null || { echo "Run './build.sh configure' first"; exit 1; }
cmake --build . --parallel
;;
dmg)
cd build 2>/dev/null || { echo "Run './build.sh' first"; exit 1; }
cmake --build . --target dmg
;;
verify)
verify_build
;;
help|--help|-h)
echo "Usage: $0 [command]"
echo ""
echo "Commands:"
echo " (none) Full build (clean, configure, build, dmg)"
echo " clean Remove build directory"
echo " configure Configure CMake only"
echo " build Build only (requires configure first)"
echo " dmg Create DMG only (requires build first)"
echo " verify Verify the build output"
echo " help Show this help message"
echo ""
echo "Environment variables:"
echo " QT_PATH Path to Qt installation (default: /Users/firshme/Qt/6.10.1/macos)"
echo ""
echo "Examples:"
echo " ./build.sh # Full build"
echo " ./build.sh clean # Clean only"
echo " QT_PATH=/opt/Qt/6.8/macos ./build.sh # Use different Qt"
;;
*)
main
;;
esac