Work in progress; some improvements to the instantiation bit (factorise certain things, etc.)

This commit is contained in:
Laurence Withers 2006-07-25 19:49:22 +01:00
parent 6a5f7bb01f
commit 34237efa4b
3 changed files with 31 additions and 31 deletions

View File

@ -1,13 +1,10 @@
if [ $# -ne 2 ] if [ $# -ne 2 ]
then then
print_failure "Not enough arguments after module; need CNAME HEADER_NAME." print_failure "Not enough arguments after module; need HEADER_NAME."
echo "CNAME is the C identifier version of the module name."
echo "HEADER_NAME is the name of the header file." echo "HEADER_NAME is the name of the header file."
exit 1 exit 1
fi fi
CNAME=$1
shift
HEADER_NAME=$1 HEADER_NAME=$1
shift shift
@ -33,12 +30,9 @@ do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1
do_cmd cd src/${NAME} || exit 1 do_cmd cd src/${NAME} || exit 1
do_cmd rm instantiate || exit 1 do_cmd rm instantiate || exit 1
do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 do_parameter_subst NAMEMINUSL HEADER_NAME
do_cmd find . -type f -exec sed -e "s,@CNAME@,${CNAME},g" -i {} \; || exit 1
do_cmd find . -type f -exec sed -e "s,@NAMEMINUSL@,${NAMEMINUSL},g" -i {} \; || exit 1 true
do_cmd find . -type f -exec sed -e "s,@HEADER_NAME@,${HEADER_NAME},g" -i {} \; || exit 1
do_cmd grep "@TODO@" * || exit 1
print_success "Module instantiated."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4; # kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4 # vim: expandtab:ts=4:sw=4

View File

@ -1,13 +1,10 @@
if [ $# -ne 2 ] if [ $# -ne 2 ]
then then
print_failure "Not enough arguments after module; need CNAME HEADER_NAME." print_failure "Not enough arguments after module; need HEADER_NAME."
echo "CNAME is the C identifier version of the module name."
echo "HEADER_NAME is the name of the header file." echo "HEADER_NAME is the name of the header file."
exit 1 exit 1
fi fi
CNAME=$1
shift
HEADER_NAME=$1 HEADER_NAME=$1
shift shift
@ -33,12 +30,9 @@ do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1
do_cmd cd src/${NAME} || exit 1 do_cmd cd src/${NAME} || exit 1
do_cmd rm instantiate || exit 1 do_cmd rm instantiate || exit 1
do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 do_parameter_subst NAMEMINUSL HEADER_NAME
do_cmd find . -type f -exec sed -e "s,@CNAME@,${CNAME},g" -i {} \; || exit 1
do_cmd find . -type f -exec sed -e "s,@NAMEMINUSL@,${NAMEMINUSL},g" -i {} \; || exit 1 true
do_cmd find . -type f -exec sed -e "s,@HEADER_NAME@,${HEADER_NAME},g" -i {} \; || exit 1
do_cmd grep "@TODO@" * || exit 1
print_success "Module instantiated."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4; # kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4 # vim: expandtab:ts=4:sw=4

View File

@ -13,6 +13,7 @@
# Get the directory of the repository (needed to include functions file) # Get the directory of the repository (needed to include functions file)
cd $(dirname $0) cd $(dirname $0)
cd $(dirname $(pwd)) cd $(dirname $(pwd))
P=$(basename $(pwd))
[ -z "${VERBOSE}" ] && VERBOSE="0" [ -z "${VERBOSE}" ] && VERBOSE="0"
source scripts/functions.sh || exit 1 source scripts/functions.sh || exit 1
@ -45,22 +46,33 @@ fi
# function used to replace variables # function to rename a package to a bash/C identifier
# assumes that we're in the directory to replace files in get_cname() {
# for each argument X, it will replace @X@ with ${X} echo $1 | tr +- p_
do_parameter_subst() {
do_cmd source ~/.lwbuildrc || exit 1
for param in AUTHOR EMAIL VIM_MODELINE KATE_MODELINE $@
do
seds="${seds} -e s,@${param}@,${!param},g"
done
do_cmd find . -type f -exec sed ${seds} -i {} \; || exit 1
} }
source ${TEMPLATE}/instantiate # function used to replace variables
# assumes that we're in the directory to replace files in
# for each argument X, it will replace @X@ with ${X}
do_parameter_subst() {
CNAME=$(get_cname ${NAME})
do_cmd source ~/.lwbuildrc || exit 1
for param in P NAME CNAME AUTHOR EMAIL VIM_MODELINE KATE_MODELINE $@
do
do_cmd_redir sedscript echo "s,@${param}@,${!param},g" || exit 1
done
do_cmd find . -type f -a -not -name sedscript -exec sed -f sedscript -i {} \; || exit 1
do_cmd rm sedscript || exit 1
}
do_cmd source ${TEMPLATE}/instantiate || exit 1
print_success "Module instantiated"
grep -r "@TODO@" .
true
# kate: replace-trailing-space-save true; space-indent true; tab-width 4; # kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4 # vim: expandtab:ts=4:sw=4