-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all_platforms.sh
More file actions
executable file
Β·177 lines (155 loc) Β· 6.63 KB
/
build_all_platforms.sh
File metadata and controls
executable file
Β·177 lines (155 loc) Β· 6.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
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
# Build paddle_decoder for ALL platforms from Linux
# Targets: Linux, Windows, macOS (Intel + Apple Silicon)
export PATH="$HOME/osxcross/target/bin:$PATH"
which x86_64-apple-darwin23.5-clang
cd /home/developer/rust/paddle_decoder_cross_platform
set -e
echo "π Building paddle_decoder for ALL platforms..."
echo ""
# Check prerequisites
echo "π Checking prerequisites..."
# Check for osxcross and auto-add to PATH if found
SKIP_MACOS=1
if [ -d "$HOME/osxcross/target/bin" ]; then
# osxcross directory exists, check if it's in PATH
if ! echo "$PATH" | grep -q "osxcross"; then
echo "π§ Found osxcross but not in PATH - adding temporarily..."
export PATH="$HOME/osxcross/target/bin:$PATH"
fi
# Now check if we can actually use it
if command -v x86_64-apple-darwin23.5-clang &> /dev/null || \
command -v x86_64-apple-darwin20.4-clang &> /dev/null || \
command -v aarch64-apple-darwin23.5-clang &> /dev/null; then
echo "β osxcross found and ready"
SKIP_MACOS=0
else
echo "β οΈ Warning: osxcross found but clang not working"
SKIP_MACOS=1
fi
else
echo "β οΈ Warning: osxcross not installed at ~/osxcross"
echo " To enable macOS builds, run: ./setup_macos_crosscompile.sh"
fi
# Check for MinGW (64-bit and 32-bit)
MINGW_64_AVAILABLE=0
MINGW_32_AVAILABLE=0
MSVC_AVAILABLE=0
if command -v x86_64-w64-mingw32-gcc &> /dev/null; then
echo "β MinGW-w64 (64-bit) found"
MINGW_64_AVAILABLE=1
fi
if command -v i686-w64-mingw32-gcc &> /dev/null; then
echo "β MinGW-w64 (32-bit) found"
MINGW_32_AVAILABLE=1
fi
# Check for MSVC linker (only works on Windows or with Wine)
if command -v link.exe &> /dev/null 2>&1 || [ -n "$WINEPREFIX" ]; then
echo "β MSVC toolchain found"
MSVC_AVAILABLE=1
fi
if [ $MINGW_64_AVAILABLE -eq 0 ] && [ $MINGW_32_AVAILABLE -eq 0 ] && [ $MSVC_AVAILABLE -eq 0 ]; then
echo "β οΈ Warning: No Windows toolchains found - Windows builds will be skipped"
echo " Install MinGW with: sudo pacman -S mingw-w64-gcc"
fi
echo ""
# Create release directory
mkdir -p release
# Linux (native)
echo "π§ Building for Linux x86_64..."
cargo build --release
cp target/release/paddle_decoder release/paddle_decoder_linux_amd64
echo "β
Linux build complete"
echo ""
# Windows builds (cross-compile)
if [ $MINGW_64_AVAILABLE -eq 1 ] || [ $MINGW_32_AVAILABLE -eq 1 ] || [ $MSVC_AVAILABLE -eq 1 ]; then
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "πͺ Building Windows binaries..."
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
# Windows x86_64 GNU
if [ $MINGW_64_AVAILABLE -eq 1 ]; then
echo "Building Windows x86_64 (GNU)..."
rustup target add x86_64-pc-windows-gnu 2>/dev/null || true
cargo build --release --target x86_64-pc-windows-gnu
cp target/x86_64-pc-windows-gnu/release/paddle_decoder.exe release/paddle_decoder_win64_gnu.exe
echo "β
Windows x86_64 GNU build complete"
echo ""
fi
# Windows i686 GNU (32-bit)
if [ $MINGW_32_AVAILABLE -eq 1 ]; then
echo "Building Windows i686 (32-bit GNU)..."
rustup target add i686-pc-windows-gnu 2>/dev/null || true
cargo build --release --target i686-pc-windows-gnu
cp target/i686-pc-windows-gnu/release/paddle_decoder.exe release/paddle_decoder_win32_gnu.exe
echo "β
Windows i686 GNU build complete"
echo ""
fi
# Windows x86_64 MSVC
if [ $MSVC_AVAILABLE -eq 1 ]; then
echo "Building Windows x86_64 (MSVC)..."
rustup target add x86_64-pc-windows-msvc 2>/dev/null || true
cargo build --release --target x86_64-pc-windows-msvc
cp target/x86_64-pc-windows-msvc/release/paddle_decoder.exe release/paddle_decoder_win64_msvc.exe
echo "β
Windows x86_64 MSVC build complete"
echo ""
else
echo "βοΈ Skipping Windows MSVC build (MSVC toolchain not available on Linux)"
echo " Note: MSVC builds work best on native Windows"
echo ""
fi
else
echo "βοΈ Skipping all Windows builds (no toolchains available)"
echo ""
fi
# macOS Intel (cross-compile)
if [ $SKIP_MACOS -eq 0 ]; then
echo "π Building for macOS x86_64 (Intel)..."
rustup target add x86_64-apple-darwin 2>/dev/null || true
cargo build --release --target x86_64-apple-darwin
cp target/x86_64-apple-darwin/release/paddle_decoder release/paddle_decoder_x86_64_macOS
echo "β
macOS Intel build complete"
echo ""
# macOS Apple Silicon (cross-compile)
echo "π Building for macOS aarch64 (Apple Silicon)..."
rustup target add aarch64-apple-darwin 2>/dev/null || true
cargo build --release --target aarch64-apple-darwin
cp target/aarch64-apple-darwin/release/paddle_decoder release/paddle_decoder_aarch64_macOS
echo "β
macOS Apple Silicon build complete"
echo ""
else
echo "βοΈ Skipping macOS builds (osxcross not available)"
echo ""
fi
# Summary
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β¨ BUILD SUMMARY"
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π Binary sizes:"
ls -lh release/paddle_decoder_* 2>/dev/null || echo "No binaries built"
echo ""
echo "π― Built platforms:"
if [ -f "release/paddle_decoder_linux_amd64" ]; then
echo " β
Linux (x86_64): release/paddle_decoder_linux_amd64"
fi
if [ -f "release/paddle_decoder_win64_gnu.exe" ]; then
echo " β
Windows x86_64 (GNU): release/paddle_decoder_win64_gnu.exe"
fi
if [ -f "release/paddle_decoder_win32_gnu.exe" ]; then
echo " β
Windows i686/32-bit (GNU): release/paddle_decoder_win32_gnu.exe"
fi
if [ -f "release/paddle_decoder_win64_msvc.exe" ]; then
echo " β
Windows x86_64 (MSVC): release/paddle_decoder_win64_msvc.exe"
fi
if [ -f "release/paddle_decoder_x86_64_macOS" ]; then
echo " β
macOS Intel (x86_64): release/paddle_decoder_x86_64_macOS"
fi
if [ -f "release/paddle_decoder_aarch64_macOS" ]; then
echo " β
macOS Apple Silicon (ARM64): release/paddle_decoder_aarch64_macOS"
fi
echo ""
# Count built platforms
BUILT_COUNT=$(ls release/paddle_decoder_* 2>/dev/null | wc -l)
echo "π¦ Total platforms built: $BUILT_COUNT"
echo ""