Skip to content

Commit abc7103

Browse files
committed
Compile .py to .mpy and use _build folder
1 parent a5048f5 commit abc7103

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

circuitpython_tools.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
shopt -s expand_aliases
4+
5+
# TODO: uh, fix this
6+
alias mpy_cross="/Users/tommy/circuitpython/mpy-cross/mpy-cross"
7+
38
{
49

510
function help() {
@@ -25,11 +30,27 @@ device="/Volumes/CIRCUITPY"
2530
subject="main.py" # TODO: parameterize
2631

2732
function deploy() {
28-
echo "SYNCING"
33+
rm -rf "_build/"
34+
35+
# Compile .py files to .mpy and move to _build
36+
for file in lib/*.py lib/**/*.py; do
37+
path_without_extension=$(echo "$file" | cut -f 1 -d '.')
38+
mpy_path="$path_without_extension.mpy"
39+
echo "$file -> $mpy_path"
40+
mpy_cross $file
41+
mkdir -p "$(dirname "_build/$file")"
42+
mv -f -v "$mpy_path" "_build/$mpy_path"
43+
done
44+
45+
# Copy subject and any remaining .mpy files to _build
46+
for file in "$subject" lib/*.mpy lib/**/*.mpy; do
47+
cp -v "$file" "_build/$file"
48+
done
49+
2950
rsync \
3051
--archive --verbose --compress \
31-
"$subject" \
32-
/Volumes/CIRCUITPY/
52+
"_build/" \
53+
"$device"
3354
}
3455

3556
function watch() {

0 commit comments

Comments
 (0)