-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·117 lines (104 loc) · 2.46 KB
/
build.sh
File metadata and controls
executable file
·117 lines (104 loc) · 2.46 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
#!/bin/bash
# Build script for ClearURLs Bot with optimization options
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default options
BUILD_TYPE="release"
STRIP=true
SHOW_TIME=true
VERBOSE=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-d|--debug)
BUILD_TYPE="debug"
shift
;;
--no-strip)
STRIP=false
shift
;;
--no-time)
SHOW_TIME=false
shift
;;
-v|--verbose)
VERBOSE=true
shift
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -d, --debug Build debug version (default: release)"
echo " --no-strip Don't strip binary symbols"
echo " --no-time Don't show build time"
echo " -v, --verbose Verbose cargo output"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo -e "${BLUE}🚀 ClearURLs Bot Build Script${NC}"
echo ""
# Show build info
echo -e "${YELLOW}Build Configuration:${NC}"
echo " Type: $BUILD_TYPE"
echo " Strip: $STRIP"
echo " Show time: $SHOW_TIME"
echo ""
# Build command
if [ "$BUILD_TYPE" = "debug" ]; then
BUILD_CMD="cargo build"
BINARY="target/debug/clear_urls_bot"
else
BUILD_CMD="cargo build --release"
BINARY="target/release/clear_urls_bot"
fi
# Add verbose flag
if [ "$VERBOSE" = true ]; then
BUILD_CMD="$BUILD_CMD --verbose"
fi
# Build
echo -e "${YELLOW}Building...${NC}"
if [ "$SHOW_TIME" = true ]; then
time $BUILD_CMD
else
$BUILD_CMD
fi
# Check if binary exists
if [ ! -f "$BINARY" ]; then
echo -e "${RED}❌ Build failed: Binary not found${NC}"
exit 1
fi
# Get binary size before strip
SIZE_BEFORE=$(ls -lh "$BINARY" | awk '{print $5}')
echo ""
echo -e "${GREEN}✅ Build successful!${NC}"
echo " Binary: $BINARY"
echo " Size: $SIZE_BEFORE"
# Strip binary if requested
if [ "$STRIP" = true ] && [ "$BUILD_TYPE" = "release" ]; then
echo ""
echo -e "${YELLOW}Stripping binary...${NC}"
strip "$BINARY"
SIZE_AFTER=$(ls -lh "$BINARY" | awk '{print $5}')
SAVED=$(($(stat -f%z "$BINARY" 2>/dev/null || stat -c%s "$BINARY" 2>/dev/null || echo 0)))
echo -e "${GREEN}✅ Stripped successfully!${NC}"
echo " Size: $SIZE_BEFORE → $SIZE_AFTER"
fi
# Final summary
echo ""
echo -e "${BLUE}Summary:${NC}"
du -sh target/
echo ""
echo -e "${GREEN}Ready to deploy! 🎉${NC}"