2024-04-19 08:59:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-04-26 10:16:10 +00:00
|
|
|
# Validate arguments
|
2024-04-19 08:59:05 +00:00
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo "Usage: $0 <source_file>"
|
|
|
|
exit
|
|
|
|
fi
|
2024-04-26 10:16:10 +00:00
|
|
|
|
|
|
|
# Parse arguments
|
2024-04-19 08:59:05 +00:00
|
|
|
file=${1##*/}
|
|
|
|
dir=${1%/*}
|
|
|
|
filename="${file%.*}"
|
2024-04-26 10:16:10 +00:00
|
|
|
|
|
|
|
# Go to source directory
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
cd "$dir" || exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Compile and clean up
|
2024-04-19 08:59:05 +00:00
|
|
|
pcompile "$file" || exit
|
|
|
|
for f in *; do
|
|
|
|
if [[ "$f" =~ ^.+\.(o|elf|map|sym)$ ]]; then
|
|
|
|
rm "$f"
|
|
|
|
fi
|
|
|
|
done
|
2024-04-26 10:16:10 +00:00
|
|
|
|
|
|
|
# Program and open terminal
|
2024-04-19 08:59:05 +00:00
|
|
|
ldpic32 "$filename.hex" || exit
|
|
|
|
pterm || exit
|
2024-04-26 10:16:10 +00:00
|
|
|
|
|
|
|
# Go back to original directory
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
cd - || exit
|
|
|
|
fi
|