-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·74 lines (60 loc) · 2.02 KB
/
dev.sh
File metadata and controls
executable file
·74 lines (60 loc) · 2.02 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
#!/bin/bash
# dev.sh - Compile and run with mpremote mount for development
set -e
SRC_DIR="src"
BUILD_DIR="build"
# Color codes
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
# Check for mpy-cross
if ! command -v mpy-cross &> /dev/null; then
echo -e "${RED}Error: mpy-cross not found. Install with: pip install mpy-cross${NC}"
exit 1
fi
# Check for mpremote
if ! command -v mpremote &> /dev/null; then
echo -e "${RED}Error: mpremote not found. Install with: pip install mpremote${NC}"
exit 1
fi
echo -e "${YELLOW}=== Compiling .py to .mpy ===${NC}"
echo " (skipping src/assets/ — frozen into firmware, not needed on filesystem)"
# Clean and create build directory
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# Find all .py files and compile them (assets are frozen in firmware)
FAILED=0
while read -r pyfile; do
# Get relative path from src/
REL_PATH="${pyfile#$SRC_DIR/}"
# Change extension to .mpy
MPY_PATH="$BUILD_DIR/${REL_PATH%.py}.mpy"
# Create subdirectory if needed
mkdir -p "$(dirname "$MPY_PATH")"
echo -n " Compiling $REL_PATH..."
if mpy-cross -march=xtensawin "$pyfile" -o "$MPY_PATH" 2>/tmp/mpy_cross_err; then
echo -e " ${GREEN}✓${NC}"
else
echo -e " ${RED}✗${NC}"
cat /tmp/mpy_cross_err
FAILED=1
fi
done < <(find "$SRC_DIR" -name "*.py" -not -path "$SRC_DIR/assets/*")
if [ "$FAILED" -eq 1 ]; then
echo -e "${RED}Compilation failed. Fix the errors above and try again.${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}=== Compilation complete ===${NC}"
echo ""
echo -e "${YELLOW}=== Converting level files ===${NC}"
mkdir -p "$BUILD_DIR/platformer_levels"
for txt in levels/level_*.txt; do
name=$(basename "${txt%.txt}")
python3 tools/convert_level.py "$txt" "$name" "$BUILD_DIR/platformer_levels" --quiet
done
echo ""
echo -e "${YELLOW}=== Mounting and running ===${NC}"
echo "(If boot.py is installed, hold A+B or wait for the 1s interrupt window)"
mpremote mount "$BUILD_DIR" exec "import main; main.main()"