-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all.sh
More file actions
executable file
·165 lines (145 loc) · 4.63 KB
/
build_all.sh
File metadata and controls
executable file
·165 lines (145 loc) · 4.63 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
#!/bin/bash
# Cross-platform build script for toxee
# This script builds the application for all supported platforms
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if Flutter is installed
if ! command -v flutter &> /dev/null; then
print_error "Flutter is not installed or not in PATH"
exit 1
fi
print_info "Flutter version: $(flutter --version | head -n 1)"
# Get the script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
# Build tim2tox native library first
print_info "Building tim2tox native library..."
TIM2TOX_DIR="$SCRIPT_DIR/third_party/tim2tox"
if [ -d "$TIM2TOX_DIR" ]; then
# Ensure tim2tox submodules (e.g. c-toxcore) are initialized
if [ -f "$TIM2TOX_DIR/.gitmodules" ] && { [ -d "$TIM2TOX_DIR/.git" ] || [ -f "$TIM2TOX_DIR/.git" ]; }; then
print_info "Initializing tim2tox submodules (c-toxcore)..."
(cd "$TIM2TOX_DIR" && git submodule update --init --recursive)
fi
cd "$TIM2TOX_DIR"
if [ -f "build.sh" ]; then
./build.sh
else
print_warn "build.sh not found in tim2tox, skipping native library build"
print_warn "Please build tim2tox manually before building the Flutter app"
fi
cd "$SCRIPT_DIR"
else
print_warn "tim2tox directory not found, skipping native library build"
fi
# Parse command line arguments
BUILD_MODE="release"
PLATFORMS=""
CLEAN=false
while [[ $# -gt 0 ]]; do
case $1 in
--mode)
BUILD_MODE="$2"
shift 2
;;
--platform)
PLATFORMS="$PLATFORMS $2"
shift 2
;;
--clean)
CLEAN=true
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --mode MODE Build mode: debug, profile, or release (default: release)"
echo " --platform PLATFORM Build for specific platform: macos, linux, windows, android, ios"
echo " Can be specified multiple times. If not specified, builds for all available platforms."
echo " --clean Clean build before building"
echo " --help Show this help message"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Bootstrap dependencies (submodules, vendor SDK, overrides)
print_info "Bootstrapping dependencies..."
dart run tool/bootstrap_deps.dart
# Clean if requested
if [ "$CLEAN" = true ]; then
print_info "Cleaning build..."
flutter clean
fi
# Get dependencies
print_info "Getting Flutter dependencies..."
flutter pub get
# Determine which platforms to build
if [ -z "$PLATFORMS" ]; then
# Build for all available platforms
PLATFORMS="macos linux windows android ios"
print_info "Building for all available platforms: $PLATFORMS"
else
print_info "Building for specified platforms: $PLATFORMS"
fi
# Build for each platform
for PLATFORM in $PLATFORMS; do
print_info "Building for $PLATFORM ($BUILD_MODE)..."
case $PLATFORM in
macos)
if [[ "$OSTYPE" == "darwin"* ]]; then
flutter build macos --$BUILD_MODE
print_info "macOS build completed"
else
print_warn "Skipping macOS build (not on macOS)"
fi
;;
linux)
flutter build linux --$BUILD_MODE
print_info "Linux build completed"
;;
windows)
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
flutter build windows --$BUILD_MODE
print_info "Windows build completed"
else
print_warn "Skipping Windows build (not on Windows)"
fi
;;
android)
flutter build apk --$BUILD_MODE
print_info "Android build completed"
;;
ios)
if [[ "$OSTYPE" == "darwin"* ]]; then
flutter build ios --$BUILD_MODE --no-codesign
print_info "iOS build completed (unsigned)"
else
print_warn "Skipping iOS build (not on macOS)"
fi
;;
*)
print_error "Unknown platform: $PLATFORM"
;;
esac
done
print_info "Build process completed!"