sly1/scripts/match_file.sh

32 lines
962 B
Bash
Raw Normal View History

2023-12-08 07:53:46 +00:00
#!/bin/bash
# Get the name of the source file as a parameter
source_file="$1"
# Check if the source file parameter is empty
if [ -z "$source_file" ]; then
echo "No source file specified!"
echo " Usage: $0 <source_file>"
exit 1
fi
# Strip the extension from the source file
source_basename="$(basename "$source_file" | cut -d. -f1)"
# Set working dir to project dir and make object file
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
codematcher_path="$project_dir/tools/codematcher"
pushd $project_dir > /dev/null
2023-12-08 07:53:46 +00:00
echo "Compiling $source_basename.o..."
make clean > /dev/null
make obj/debug/$source_basename.o > /dev/null
2023-12-08 07:53:46 +00:00
# CD to codematcher directory and invoke codematcher with the compiled object file
2023-12-08 07:53:46 +00:00
echo "Matching $source_basename.o..."
cd tools/codematcher >/dev/null
./codematcher may_proto.elf --match "$project_dir/obj/debug/$source_basename.o"
2023-12-08 07:53:46 +00:00
# Move back to the original directory
popd >/dev/null
popd >/dev/null