/ test / scripts / upload_feather_huzzah_circuitpython_put.sh
upload_feather_huzzah_circuitpython_put.sh
 1  #!/bin/sh
 2  PORT=/dev/ttyUSB0
 3  
 4  export MPYCROSS=`realpath ../../../circuitpython_2.2.3/mpy-cross/mpy-cross`
 5  
 6  # switch to test sources
 7  cd ../src
 8  # create test source directories on board
 9  find testing -type d | \
10          grep -v -E "(^./.git.*|^./.idea|^./.vscode|__pycache__)" | \
11          xargs -n1 -I {} sh -c "echo Creating directory {} ...; ampy --port ${PORT} mkdir --exists-okay  {}"
12  # compile source .py files to .mpy
13  find . -type f -name '*.py' | \
14      xargs -n1 -I {} sh -c "echo compiling {} ...; ${MPYCROSS} {}"
15  # upload bytecode .mpy files
16  find . -type f -name '*.mpy' | \
17          xargs -n1 -I {} sh -c "echo uploading {} ...; ampy --port ${PORT} put {} {}"
18  
19  #switch to test libraries
20  cd ../libraries/
21  
22  # Compile adafruit libraries to bytecode and upload
23  for SUBMODULE in `find . -mindepth 1 -maxdepth 1 -type d `
24  do
25      cd ${SUBMODULE}
26      # create adafruit library directories on board
27      find . -mindepth 1 -type d | \
28              grep -v -E "(^./.git.*|__pycache__|^./doc.*|^./example.*)" | \
29              xargs -n1 -I {} sh -c "echo Creating directory {} ...; ampy --port ${PORT} mkdir --exists-okay  {}"
30      # compile adafruit library .py files to .mpy
31      find . -type f -name '*.py' | \
32          grep -v -E "(^./conf.py|^./docs/conf.py|^./setup.py|^./example.*)" | \
33          xargs -n1 -I {} sh -c "echo compiling {} ...; ${MPYCROSS} {}"
34      # upload adafruit library .mpy files
35      find . -type f -name '*.mpy' | \
36          xargs -n1 -I {} sh -c "echo uploading {} ...; ampy --port ${PORT} put {} {}"
37      cd ../
38  done
39  
40  # switch to adafruit_blinka source
41  cd ../../src
42  
43  # create adafruit_blinka agnostic package for cross-platform logic
44  ampy --port $PORT mkdir --exists-okay adafruit_blinka
45  ampy --port $PORT mkdir --exists-okay adafruit_blinka/agnostic
46  # upload agnostic.mpy for platform detection
47  $MPYCROSS adafruit_blinka/agnostic/__init__.py
48  ampy --port $PORT put adafruit_blinka/agnostic/__init__.mpy adafruit_blinka/agnostic/__init__.mpy
49  # upload time.mpy for time logic
50  $MPYCROSS adafruit_blinka/agnostic/time.py
51  ampy --port $PORT put adafruit_blinka/agnostic/time.mpy adafruit_blinka/agnostic/time.mpy