File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 8181
8282existing_files=$( mpremote fs ls " :/${LIBDIR} /${PKGDIR} " )
8383
84- for py in $SRCDIR /* ; do
85- f_name=` basename $py `
86- if [ " $ext " = " mpy" ]; then
84+ for filename in $SRCDIR /* ; do
85+ f_name=` basename $filename `
86+ source_extension=" ${f_name##* .} "
87+ destination_extension=$source_extension
88+
89+ if [ " $ext " = " mpy" ] && [ " $source_extention " = " py" ]; then
8790 echo " Compiling $SRCDIR /$f_name to $SRCDIR /${f_name% .* } .$ext "
8891 mpy-cross " $SRCDIR /$f_name "
92+ destination_extension=$ext
8993 fi
9094
91- if [[ $existing_files == * " ${f_name% .* } .py" * ]]; then
92- delete_file " :/${LIBDIR} /$PKGDIR /${f_name% .* } .py"
95+ # Make sure previous versions of the given file are deleted.
96+ if [[ $existing_files == * " ${f_name% .* } .$source_extension " * ]]; then
97+ delete_file " :/${LIBDIR} /$PKGDIR /${f_name% .* } .$source_extension "
9398 fi
9499
95- if [[ $existing_files == * " ${f_name% .* } .mpy" * ]]; then
100+ # Check if source file has a .py extension and if a .mpy file exists on the board
101+ if [ " $source_extension " = " py" ] && [[ $existing_files == * " ${f_name% .* } .mpy" * ]]; then
96102 delete_file " :/${LIBDIR} /$PKGDIR /${f_name% .* } .mpy"
97103 fi
98104
99- copy_file $SRCDIR /${f_name% .* } .$ext " :/${LIBDIR} /$PKGDIR /${f_name% .* } .$ext "
105+ # Copy either the .py or .mpy file to the board depending on the chosen option
106+ copy_file $SRCDIR /${f_name% .* } .$destination_extension " :/${LIBDIR} /$PKGDIR /${f_name% .* } .$destination_extension "
100107done
101108
102109if [ " $ext " = " mpy" ]; then
You can’t perform that action at this time.
0 commit comments