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