Ensure st-compile
is used properly
This commit is contained in:
parent
0c6a4fc0ba
commit
e63b364a2f
1 changed files with 17 additions and 2 deletions
19
compile.sh
Normal file → Executable file
19
compile.sh
Normal file → Executable file
|
@ -1,6 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
projectPattern="*.uvprojx";
|
projectPattern="*.uvprojx";
|
||||||
|
|
||||||
|
if [ "$#" -gt 1 ]
|
||||||
|
then
|
||||||
|
1>&2 echo "Error: Invalid number of arguments: $#";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]
|
||||||
|
then
|
||||||
|
echo "Usage: ${BASH_SOURCE[0]} <path-to-project-or-source-file>";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function handle_status() {
|
function handle_status() {
|
||||||
if [ $1 -ne 0 ]; then
|
if [ $1 -ne 0 ]; then
|
||||||
echo "Error: $2 (status code: $1)";
|
echo "Error: $2 (status code: $1)";
|
||||||
|
@ -153,6 +166,8 @@ function chooseTarget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName="$(realpath "$1")";
|
fileName="$(realpath "$1")";
|
||||||
|
test -f "$fileName";
|
||||||
|
handle_status "$?" "The specified file \"$1\" does not exist!";
|
||||||
|
|
||||||
if [[ "$fileName" =~ \.uvprojx$ ]]
|
if [[ "$fileName" =~ \.uvprojx$ ]]
|
||||||
then
|
then
|
||||||
|
@ -213,7 +228,7 @@ then
|
||||||
then
|
then
|
||||||
outputName="$(realpath "$projectRoot/$buildPath/$outputName")";
|
outputName="$(realpath "$projectRoot/$buildPath/$outputName")";
|
||||||
outputFile="$outputName.axf";
|
outputFile="$outputName.axf";
|
||||||
echo "The File Has Been Built to \`$outputFile\`.";
|
echo "The File Has Been Built to \"$outputFile\".";
|
||||||
pyocd list | {
|
pyocd list | {
|
||||||
grep '^No available' &&
|
grep '^No available' &&
|
||||||
{
|
{
|
||||||
|
@ -228,5 +243,5 @@ then
|
||||||
handle_status 1 "The project could not be built!";
|
handle_status 1 "The project could not be built!";
|
||||||
fi;
|
fi;
|
||||||
else
|
else
|
||||||
handle_status 1 "No project file for \`${fileName}\` could be found."
|
handle_status 1 "No project file for \"${fileName}\" could be found."
|
||||||
fi;
|
fi;
|
||||||
|
|
Loading…
Reference in a new issue