2 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
 
   4 # SPDX-License-Identifier: MIT
 
   7 export MPYCROSS=`realpath ../../../circuitpython_2.2.3/mpy-cross/mpy-cross`
 
   9 # switch to test sources
 
  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 {} {}"
 
  22 #switch to test libraries
 
  25 # Compile adafruit libraries to bytecode and upload
 
  26 for SUBMODULE in `find . -mindepth 1 -maxdepth 1 -type d `
 
  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 {} {}"
 
  43 # switch to adafruit_blinka source
 
  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