-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·259 lines (225 loc) · 8.52 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·259 lines (225 loc) · 8.52 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
#!/bin/bash
# Quick build script for Tabular
# Usage: ./build.sh [platform]
# Platforms: macos, linux, linux-aarch64, windows, all
set -e
APP_NAME="Tabular"
# Ambil versi dari Cargo.toml supaya sinkron
VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2)
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if required tools are installed
check_dependencies() {
print_status "Checking dependencies..."
if ! command -v cargo &> /dev/null; then
print_error "Cargo is not installed. Please install Rust first."
exit 1
fi
if ! command -v make &> /dev/null; then
print_error "Make is not installed. Please install make."
exit 1
fi
print_success "All dependencies are available!"
}
# Show help
show_help() {
echo "🛠️ Tabular Build Script"
echo "======================="
echo ""
echo "Usage: $0 [PLATFORM] [OPTIONS]"
echo ""
echo "Platforms:"
echo " macos - Build macOS universal + .app (DMG optional)"
echo " macos-pkg - Build macOS .app lalu signed .pkg (App Store / distribusi)"
echo " linux - Build + package Linux (x86_64 + aarch64)"
echo " linux-aarch64- Build + package Linux (aarch64 only)"
echo " windows - Build + package Windows (x86_64 + aarch64)"
echo " all - Release build semua platform"
echo ""
echo "Options:"
echo " --deps - Install build dependencies first"
echo " --clean - Clean before building"
echo " --help - Show this help message"
echo ""
echo "Examples:"
echo " $0 macos # Build macOS only"
echo " $0 linux --clean # Clean and build Linux"
echo " $0 all --deps # Install deps and build all"
echo ""
}
# Parse command line arguments
PLATFORM="all"
BUILD_PKG=false
INSTALL_DEPS=false
CLEAN_FIRST=false
while [[ $# -gt 0 ]]; do
case $1 in
macos|macos-pkg|linux|linux-aarch64|windows|all)
PLATFORM="$1"
shift
;;
--deps)
INSTALL_DEPS=true
shift
;;
--clean)
CLEAN_FIRST=true
shift
;;
--help|-h)
show_help
exit 0
;;
*)
print_error "Unknown option: $1"
show_help
exit 1
;;
esac
done
# Main build function
main() {
print_status "Starting build for platform: $PLATFORM"
check_dependencies
# Install dependencies if requested
if [ "$INSTALL_DEPS" = true ]; then
print_status "Installing build dependencies..."
make install-deps
fi
# Clean if requested
if [ "$CLEAN_FIRST" = true ]; then
print_status "Cleaning previous builds..."
make clean
fi
# Build based on platform
case $PLATFORM in
macos)
print_status "Building macOS universal binary and App Store ready bundle..."
print_status "Setting up environment variables for code signing..."
# Export environment variables for code signing
export APPLE_ID=''
export APPLE_TEAM_ID=''
export APPLE_BUNDLE_ID=''
export PASSWORD=''
export APPLE_IDENTITY=''
export APPLE_IDENTITY_INS=''
# NOTE: DMG TANPA SANDBOX -> JANGAN set APPLE_APP_IDENTITY di sini.
# Jika ingin membuat versi App Store (sandbox), jalankan:
# APPLE_APP_IDENTITY='3rd Party Mac Developer Application: PT. VNEU TEKNOLOGI INDONESIA (YD4J5Z6A4G)' sh build.sh macos
# atau buat target khusus.
unset APPLE_APP_IDENTITY
# Note: APPLE_PASSWORD dan NOTARIZE=1 perlu di-set manual jika mau notarize
echo "✅ Environment variables set for code signing"
echo "📝 Note: For notarization, manually set APPLE_PASSWORD and NOTARIZE=1"
echo "ℹ️ DMG akan dibangun dengan entitlements non-sandbox (Developer ID)."
make clean
make bundle-macos
make pkg-macos-store
sh notarize.sh
print_success "macOS build completed!"
;;
macos-pkg)
# Export environment variables for code signing
export APPLE_ID=''
export APPLE_TEAM_ID=''
export APPLE_BUNDLE_ID=''
export PASSWORD=''
# export APPLE_IDENTITY=''
export APPLE_IDENTITY=''
print_status "Building macOS .app + signed .pkg"
if [ -z "$APPLE_IDENTITY" ]; then
print_warning "APPLE_IDENTITY belum diset. Contoh: export APPLE_IDENTITY='Apple Distribution: Nama (TEAMID)'"
fi
if [ -z "$APPLE_BUNDLE_ID" ]; then
print_warning "APPLE_BUNDLE_ID belum diset (contoh: id.tabular.database)"
fi
make pkg-macos-store || {
print_error "Gagal membuat pkg. Pastikan env & provisioning profile benar."
exit 1
}
print_success "macOS pkg build completed!"
;;
linux)
print_status "Building Linux binaries..."
# Ensure targets are available
rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu || true
# Prefer cross if available, fallback to cargo
print_status "Using cargo to build x86_64 and aarch64"
cargo build --release --target x86_64-unknown-linux-gnu
# Prepare dist directory
mkdir -p dist/linux
cp target/x86_64-unknown-linux-gnu/release/tabular dist/linux/tabular-x86_64 || true
# Also keep explicit target-name copies
cp target/x86_64-unknown-linux-gnu/release/tabular dist/linux/tabular-x86_64-unknown-linux-gnu || true
# Package tarballs
(cd dist/linux && tar -czf tabular-${VERSION}-linux-x86_64.tar.gz tabular-x86_64) || true
(cd dist/linux && tar -czf tabular-x86_64-unknown-linux-gnu.tar.gz tabular-x86_64-unknown-linux-gnu) || true
print_success "Linux build completed!"
;;
linux-aarch64)
print_status "Building Linux aarch64 binary..."
rustup target add aarch64-unknown-linux-gnu || true
if command -v cross >/dev/null 2>&1; then
print_status "Using cross to build aarch64"
cross build --release --target aarch64-unknown-linux-gnu
else
print_status "Using cargo to build aarch64"
cargo build --release --target aarch64-unknown-linux-gnu
fi
mkdir -p dist/linux
cp target/aarch64-unknown-linux-gnu/release/tabular dist/linux/tabular-aarch64 || true
cp target/aarch64-unknown-linux-gnu/release/tabular dist/linux/tabular-aarch64-unknown-linux-gnu || true
(cd dist/linux && tar -czf tabular-${VERSION}-linux-aarch64.tar.gz tabular-aarch64) || true
(cd dist/linux && tar -czf tabular-aarch64-unknown-linux-gnu.tar.gz tabular-aarch64-unknown-linux-gnu) || true
print_success "Linux aarch64 build completed!"
;;
windows)
print_status "Building Windows binaries..."
make bundle-windows
print_success "Windows build completed!"
;;
all)
print_status "Building for all platforms..."
make release
print_success "All platform builds completed!"
;;
*)
print_error "Unknown platform: $PLATFORM"
exit 1
;;
esac
# Show build results
echo ""
print_success "🎉 Build completed successfully!"
echo ""
print_status "📦 Generated files:"
if [ -d "dist" ]; then
find dist -type f \( -name "*.dmg" -o -name "*.pkg" -o -name "*.app" -o -name "*.tar.gz" -o -name "*.zip" \) | while read -r file; do
size=$(ls -lh "$file" | awk '{print $5}')
echo " 📁 $file ($size)"
done
else
print_warning "No distribution files found. Build may have failed."
fi
echo ""
print_status "✨ Ready for distribution!"
}
# Run main function
main "$@"