#!/bin/bash

echo "Cur dir: $(pwd)"

mkdir /mnt/r/WNodePython
cd /mnt/r/WNodePython
rsync -av --prune-empty-dirs --include "*/" --include "*.py" --exclude "*" --exclude "*.*" "/home/kevin/ws_cloud/Programme Python/WNodePython/pysmartnode/" ./pysmartnode/ --delete
rsync -av --prune-empty-dirs --include "*/" --include "*.py" --exclude "*" --exclude "*.*" "/home/kevin/ws_cloud/Programme Python/WNodePython/_testing/" ./_testing/ --delete
rsync -av --prune-empty-dirs  --include "*/" --include "*.py" --exclude "*" --exclude "*.*" "/home/kevin/ws_cloud/Programme Python/WNodePython/external_modules/" ./external_modules/ --delete

function foo {
                   echo $1
                   #local res=$(/home/kevin/.local/bin/strip-hints --only-assigns-and-defs --only-test-for-changes $1)
                   #if [[ $res = "True" ]]; then
                   #    echo "$1 stripped of hints"
                   #    v=$(/home/kevin/.local/bin/strip-hints --only-assigns-and-defs $1)
                   #    echo "$v" > $1
                   #else
                   #    echo $1 $res
                   #fi
                   ~/micropython/mpy-cross/mpy-cross -march=xtensawin $1;
                   rm $1
                }
export -f foo
for d in pysmartnode _testing external_modules 
do

find ./$d -name \*.py -exec bash -c 'foo "$@"' bash {} \;
done
echo "generated bytecode"