You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1014 B
35 lines
1014 B
#!/usr/bin/env bash
|
|
|
|
if test ! -f "project.yml"; then
|
|
echo -e "no project.yml was found -> generation failed\nplease run this command from the root of the project directory"
|
|
exit 1
|
|
fi
|
|
if test -z $1; then
|
|
echo "no file path was provided -> generation failed"
|
|
exit 1
|
|
fi
|
|
|
|
name="$(basename $1)"
|
|
mkdir -p "test/$(dirname $1)"
|
|
mkdir -p "src/$(dirname $1)"
|
|
|
|
testcontent="#include \"unity.h\"\n#include \"$1.h\"\n\nvoid setUp(void){}\nvoid tearDown(void){}"
|
|
filecontent="#include \"$name.h\""
|
|
headercontent="#ifndef ${name^^}_H\n#define ${name^^}_H\n\n\n#endif"
|
|
|
|
if test -e "test/test_$1.c"; then
|
|
echo "the file test/test_$1.c already exists -> generation failed"
|
|
exit 1
|
|
fi
|
|
if test -e "src/$1.c"; then
|
|
echo "the file src/$1.c already exists -> generation failed"
|
|
exit 1
|
|
fi
|
|
if test -e "src/$1.h"; then
|
|
echo "the file src/$1.h already exists -> generation failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e $testcontent > "test/test_$1.c"
|
|
echo -e $filecontent > "src/$1.c"
|
|
echo -e $headercontent > "src/$1.h"
|