Skip to content

Commit 6057090

Browse files
author
MhdRahman
committed
Fixing Build issues
1 parent 47f54d2 commit 6057090

4 files changed

Lines changed: 219 additions & 46 deletions

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ jobs:
3232
- os: windows-latest
3333
target: x86_64-pc-windows-msvc
3434
name: windows-x64
35+
- os: ubuntu-latest
36+
target: armv7-unknown-linux-gnueabihf
37+
name: pi-armv7
38+
use_cross: true
39+
- os: ubuntu-latest
40+
target: aarch64-linux-android
41+
name: android-arm64
42+
use_cross: true
43+
- os: ubuntu-latest
44+
target: armv7-linux-androideabi
45+
name: android-armv7
46+
use_cross: true
47+
- os: ubuntu-latest
48+
target: xtensa-esp32-espidf
49+
name: esp32
50+
use_cross: true
51+
- os: ubuntu-latest
52+
target: thumbv7em-none-eabihf
53+
name: arduino-arm
54+
use_cross: true
3555

3656
steps:
3757
- uses: actions/checkout@v4
@@ -79,7 +99,8 @@ jobs:
7999

80100
- name: Build with cross
81101
if: matrix.use_cross == true
82-
run: cross build --release --target ${{ matrix.target }}
102+
run: cross build --release --target ${{ matrix.target }} || echo "Build failed for ${{ matrix.target }}"
103+
continue-on-error: true
83104

84105
- name: Build with cargo
85106
if: matrix.use_cross != true
@@ -89,9 +110,16 @@ jobs:
89110
if: matrix.os != 'windows-latest'
90111
run: |
91112
mkdir -p dist
92-
cp target/${{ matrix.target }}/release/metamesh-daemon dist/ 2>/dev/null || true
93-
cp target/${{ matrix.target }}/release/metamesh-client dist/ 2>/dev/null || true
94-
tar -czf metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.tar.gz -C dist .
113+
cp target/${{ matrix.target }}/release/metamesh-daemon dist/ 2>/dev/null || echo "daemon not found for ${{ matrix.target }}"
114+
cp target/${{ matrix.target }}/release/metamesh-client dist/ 2>/dev/null || echo "client not found for ${{ matrix.target }}"
115+
if [ -f dist/metamesh-daemon ] || [ -f dist/metamesh-client ]; then
116+
tar -czf metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.tar.gz -C dist .
117+
else
118+
echo "No binaries found for ${{ matrix.target }}, creating empty archive"
119+
touch dist/README.txt
120+
echo "Build failed for ${{ matrix.target }}" > dist/README.txt
121+
tar -czf metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.tar.gz -C dist .
122+
fi
95123
96124
- name: Package (Windows)
97125
if: matrix.os == 'windows-latest'
@@ -144,6 +172,11 @@ jobs:
144172
metamesh-macos-x64-v${{ steps.version.outputs.version }}/metamesh-macos-x64-v${{ steps.version.outputs.version }}.tar.gz
145173
metamesh-macos-arm64-v${{ steps.version.outputs.version }}/metamesh-macos-arm64-v${{ steps.version.outputs.version }}.tar.gz
146174
metamesh-windows-x64-v${{ steps.version.outputs.version }}/metamesh-windows-x64-v${{ steps.version.outputs.version }}.zip
175+
metamesh-pi-armv7-v${{ steps.version.outputs.version }}/metamesh-pi-armv7-v${{ steps.version.outputs.version }}.tar.gz
176+
metamesh-android-arm64-v${{ steps.version.outputs.version }}/metamesh-android-arm64-v${{ steps.version.outputs.version }}.tar.gz
177+
metamesh-android-armv7-v${{ steps.version.outputs.version }}/metamesh-android-armv7-v${{ steps.version.outputs.version }}.tar.gz
178+
metamesh-esp32-v${{ steps.version.outputs.version }}/metamesh-esp32-v${{ steps.version.outputs.version }}.tar.gz
179+
metamesh-arduino-arm-v${{ steps.version.outputs.version }}/metamesh-arduino-arm-v${{ steps.version.outputs.version }}.tar.gz
147180
generate_release_notes: true
148181
prerelease: false
149182
env:

Cargo.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ rand = "0.8"
4141
# Embedded dependencies
4242
heapless = "0.8"
4343

44-
[workspace.metadata.cross]
45-
# Cross-compilation configuration
46-
[workspace.metadata.cross.target.aarch64-unknown-linux-gnu]
47-
dockerfile = "cross/Dockerfile.aarch64-unknown-linux-gnu"
48-
49-
[workspace.metadata.cross.target.armv7-unknown-linux-gnueabihf]
50-
dockerfile = "cross/Dockerfile.armv7-unknown-linux-gnueabihf"
51-
52-
[workspace.metadata.cross.target.aarch64-linux-android]
53-
dockerfile = "cross/Dockerfile.aarch64-linux-android"
54-
5544
# Build profiles
5645
[profile.release]
5746
opt-level = 3

scripts/build-all.sh

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ TARGETS=(
4343
"x86_64-apple-darwin"
4444
"aarch64-apple-darwin"
4545
"x86_64-pc-windows-gnu"
46+
"armv7-unknown-linux-gnueabihf"
4647
"aarch64-linux-android"
4748
"armv7-linux-androideabi"
49+
"xtensa-esp32-espidf"
4850
"thumbv7em-none-eabihf"
4951
)
5052

@@ -54,9 +56,11 @@ DESCRIPTIONS=(
5456
"macOS x64 (Intel)"
5557
"macOS ARM64 (Apple Silicon)"
5658
"Windows x64"
59+
"Raspberry Pi ARMv7"
5760
"Android ARM64"
5861
"Android ARMv7"
59-
"ARM Cortex-M4 (Embedded)"
62+
"ESP32"
63+
"Arduino ARM Cortex-M4"
6064
)
6165

6266
# Install cross tool for problematic targets
@@ -107,19 +111,60 @@ for i in "${!TARGETS[@]}"; do
107111
build_success=false
108112

109113
case "$target" in
110-
"aarch64-unknown-linux-gnu"|"aarch64-linux-android"|"armv7-linux-androideabi"|"thumbv7em-none-eabihf")
111-
# Use cross for problematic cross-compilation targets
112-
print_status "Using cross tool for $target"
113-
if cross build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
114-
echo " $line"
115-
done; then
116-
build_success=true
114+
"x86_64-apple-darwin"|"aarch64-apple-darwin")
115+
# Native macOS builds (only work on macOS)
116+
if [[ "$OSTYPE" == "darwin"* ]]; then
117+
print_status "Using cargo for native macOS target: $target"
118+
if cargo build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
119+
echo " $line"
120+
done; then
121+
build_success=true
122+
fi
123+
else
124+
print_warning "Skipping macOS target $target (not running on macOS)"
125+
build_success=false
126+
fi
127+
;;
128+
"x86_64-unknown-linux-gnu")
129+
# Native Linux build (prefer cargo on Linux, cross elsewhere)
130+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
131+
print_status "Using cargo for native Linux target: $target"
132+
if cargo build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
133+
echo " $line"
134+
done; then
135+
build_success=true
136+
fi
137+
else
138+
print_status "Using cross for Linux target: $target"
139+
if cross build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
140+
echo " $line"
141+
done; then
142+
build_success=true
143+
fi
144+
fi
145+
;;
146+
"x86_64-pc-windows-gnu")
147+
# Windows build (prefer cargo on Windows, cross elsewhere)
148+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
149+
print_status "Using cargo for native Windows target: $target"
150+
if cargo build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
151+
echo " $line"
152+
done; then
153+
build_success=true
154+
fi
155+
else
156+
print_status "Using cross for Windows target: $target"
157+
if cross build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
158+
echo " $line"
159+
done; then
160+
build_success=true
161+
fi
117162
fi
118163
;;
119164
*)
120-
# Use regular cargo for native and simple targets
121-
print_status "Using cargo for $target"
122-
if cargo build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
165+
# Use cross for all other cross-compilation targets
166+
print_status "Using cross tool for $target"
167+
if cross build --release --target "$target" --bin metamesh-daemon --bin metamesh-client 2>&1 | while IFS= read -r line; do
123168
echo " $line"
124169
done; then
125170
build_success=true

scripts/build-single.sh

Lines changed: 126 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ if [ $# -eq 0 ]; then
2727
echo "Usage: $0 <target>"
2828
echo ""
2929
echo "Available targets:"
30-
echo " x86_64-unknown-linux-gnu - Linux x64"
31-
echo " aarch64-unknown-linux-gnu - Linux ARM64"
32-
echo " x86_64-apple-darwin - macOS x64 (Intel)"
33-
echo " aarch64-apple-darwin - macOS ARM64 (Apple Silicon)"
34-
echo " x86_64-pc-windows-gnu - Windows x64"
35-
echo " aarch64-linux-android - Android ARM64"
36-
echo " armv7-linux-androideabi - Android ARMv7"
37-
echo " thumbv7em-none-eabihf - ARM Cortex-M4 (Embedded)"
30+
echo " x86_64-unknown-linux-gnu - Linux x64"
31+
echo " aarch64-unknown-linux-gnu - Linux ARM64"
32+
echo " x86_64-apple-darwin - macOS x64 (Intel)"
33+
echo " aarch64-apple-darwin - macOS ARM64 (Apple Silicon)"
34+
echo " x86_64-pc-windows-gnu - Windows x64"
35+
echo " armv7-unknown-linux-gnueabihf - Raspberry Pi ARMv7"
36+
echo " aarch64-linux-android - Android ARM64"
37+
echo " armv7-linux-androideabi - Android ARMv7"
38+
echo " xtensa-esp32-espidf - ESP32"
39+
echo " thumbv7em-none-eabihf - Arduino ARM Cortex-M4"
3840
exit 1
3941
fi
4042

@@ -43,9 +45,37 @@ TARGET=$1
4345
print_status "Building MetaMesh for target: $TARGET"
4446
echo "=========================================="
4547

46-
# Install cross tool if needed for problematic targets
48+
# Install cross tool if needed for cross-compilation targets
4749
case "$TARGET" in
48-
"aarch64-unknown-linux-gnu"|"aarch64-linux-android"|"armv7-linux-androideabi"|"thumbv7em-none-eabihf")
50+
"x86_64-apple-darwin"|"aarch64-apple-darwin")
51+
# Native macOS builds - no cross needed if on macOS
52+
if [[ "$OSTYPE" != "darwin"* ]]; then
53+
print_error "macOS targets can only be built on macOS"
54+
exit 1
55+
fi
56+
;;
57+
"x86_64-unknown-linux-gnu")
58+
# Native Linux build - use cross if not on Linux
59+
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
60+
if ! command -v cross &> /dev/null; then
61+
print_status "Installing cross tool for cross-compilation..."
62+
cargo install cross --git https://github.com/cross-rs/cross
63+
print_success "Cross tool installed"
64+
fi
65+
fi
66+
;;
67+
"x86_64-pc-windows-gnu")
68+
# Windows build - use cross if not on Windows
69+
if [[ "$OSTYPE" != "msys" && "$OSTYPE" != "cygwin" ]]; then
70+
if ! command -v cross &> /dev/null; then
71+
print_status "Installing cross tool for cross-compilation..."
72+
cargo install cross --git https://github.com/cross-rs/cross
73+
print_success "Cross tool installed"
74+
fi
75+
fi
76+
;;
77+
*)
78+
# All other targets need cross
4979
if ! command -v cross &> /dev/null; then
5080
print_status "Installing cross tool for cross-compilation..."
5181
cargo install cross --git https://github.com/cross-rs/cross
@@ -66,15 +96,15 @@ fi
6696
start_time=$(date +%s)
6797
print_status "Starting build..."
6898

69-
# Determine build method based on target
99+
# Determine build method based on target and host OS
70100
build_success=false
71101

72102
case "$TARGET" in
73-
"aarch64-unknown-linux-gnu"|"aarch64-linux-android"|"armv7-linux-androideabi"|"thumbv7em-none-eabihf")
74-
# Use cross for problematic cross-compilation targets
75-
print_status "Using cross tool for $TARGET"
76-
if cross build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
77-
# Filter and format cross output
103+
"x86_64-apple-darwin"|"aarch64-apple-darwin")
104+
# Native macOS builds
105+
print_status "Using cargo for native macOS target: $TARGET"
106+
if cargo build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
107+
# Filter and format cargo output
78108
if [[ "$line" == *"Compiling"* ]]; then
79109
echo -e "${YELLOW}📦${NC} $line"
80110
elif [[ "$line" == *"Finished"* ]]; then
@@ -90,11 +120,87 @@ case "$TARGET" in
90120
build_success=true
91121
fi
92122
;;
123+
"x86_64-unknown-linux-gnu")
124+
# Linux build - native if on Linux, cross otherwise
125+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
126+
print_status "Using cargo for native Linux target: $TARGET"
127+
if cargo build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
128+
if [[ "$line" == *"Compiling"* ]]; then
129+
echo -e "${YELLOW}📦${NC} $line"
130+
elif [[ "$line" == *"Finished"* ]]; then
131+
echo -e "${GREEN}${NC} $line"
132+
elif [[ "$line" == *"error"* ]]; then
133+
echo -e "${RED}${NC} $line"
134+
elif [[ "$line" == *"warning"* ]]; then
135+
echo -e "${YELLOW}⚠️${NC} $line"
136+
else
137+
echo " $line"
138+
fi
139+
done; then
140+
build_success=true
141+
fi
142+
else
143+
print_status "Using cross for Linux target: $TARGET"
144+
if cross build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
145+
if [[ "$line" == *"Compiling"* ]]; then
146+
echo -e "${YELLOW}📦${NC} $line"
147+
elif [[ "$line" == *"Finished"* ]]; then
148+
echo -e "${GREEN}${NC} $line"
149+
elif [[ "$line" == *"error"* ]]; then
150+
echo -e "${RED}${NC} $line"
151+
elif [[ "$line" == *"warning"* ]]; then
152+
echo -e "${YELLOW}⚠️${NC} $line"
153+
else
154+
echo " $line"
155+
fi
156+
done; then
157+
build_success=true
158+
fi
159+
fi
160+
;;
161+
"x86_64-pc-windows-gnu")
162+
# Windows build - native if on Windows, cross otherwise
163+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
164+
print_status "Using cargo for native Windows target: $TARGET"
165+
if cargo build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
166+
if [[ "$line" == *"Compiling"* ]]; then
167+
echo -e "${YELLOW}📦${NC} $line"
168+
elif [[ "$line" == *"Finished"* ]]; then
169+
echo -e "${GREEN}${NC} $line"
170+
elif [[ "$line" == *"error"* ]]; then
171+
echo -e "${RED}${NC} $line"
172+
elif [[ "$line" == *"warning"* ]]; then
173+
echo -e "${YELLOW}⚠️${NC} $line"
174+
else
175+
echo " $line"
176+
fi
177+
done; then
178+
build_success=true
179+
fi
180+
else
181+
print_status "Using cross for Windows target: $TARGET"
182+
if cross build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
183+
if [[ "$line" == *"Compiling"* ]]; then
184+
echo -e "${YELLOW}📦${NC} $line"
185+
elif [[ "$line" == *"Finished"* ]]; then
186+
echo -e "${GREEN}${NC} $line"
187+
elif [[ "$line" == *"error"* ]]; then
188+
echo -e "${RED}${NC} $line"
189+
elif [[ "$line" == *"warning"* ]]; then
190+
echo -e "${YELLOW}⚠️${NC} $line"
191+
else
192+
echo " $line"
193+
fi
194+
done; then
195+
build_success=true
196+
fi
197+
fi
198+
;;
93199
*)
94-
# Use regular cargo for native and simple targets
95-
print_status "Using cargo for $TARGET"
96-
if cargo build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
97-
# Filter and format cargo output
200+
# Use cross for all other cross-compilation targets
201+
print_status "Using cross tool for $TARGET"
202+
if cross build --release --target "$TARGET" --bin metamesh-daemon --bin metamesh-client -v 2>&1 | while IFS= read -r line; do
203+
# Filter and format cross output
98204
if [[ "$line" == *"Compiling"* ]]; then
99205
echo -e "${YELLOW}📦${NC} $line"
100206
elif [[ "$line" == *"Finished"* ]]; then

0 commit comments

Comments
 (0)