diff --git a/scripts/build.c++.lib/instantiate b/scripts/build.c++.lib/instantiate index 9ef0cca..3c88ca6 100644 --- a/scripts/build.c++.lib/instantiate +++ b/scripts/build.c++.lib/instantiate @@ -1,13 +1,10 @@ if [ $# -ne 2 ] then - print_failure "Not enough arguments after module; need CNAME HEADER_NAME." - echo "CNAME is the C identifier version of the module name." + print_failure "Not enough arguments after module; need HEADER_NAME." echo "HEADER_NAME is the name of the header file." exit 1 fi -CNAME=$1 -shift HEADER_NAME=$1 shift @@ -33,12 +30,9 @@ do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 do_cmd cd src/${NAME} || exit 1 do_cmd rm instantiate || exit 1 -do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 -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 -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." +do_parameter_subst NAMEMINUSL HEADER_NAME + +true # kate: replace-trailing-space-save true; space-indent true; tab-width 4; # vim: expandtab:ts=4:sw=4 diff --git a/scripts/build.c.lib/instantiate b/scripts/build.c.lib/instantiate index 9ef0cca..3c88ca6 100644 --- a/scripts/build.c.lib/instantiate +++ b/scripts/build.c.lib/instantiate @@ -1,13 +1,10 @@ if [ $# -ne 2 ] then - print_failure "Not enough arguments after module; need CNAME HEADER_NAME." - echo "CNAME is the C identifier version of the module name." + print_failure "Not enough arguments after module; need HEADER_NAME." echo "HEADER_NAME is the name of the header file." exit 1 fi -CNAME=$1 -shift HEADER_NAME=$1 shift @@ -33,12 +30,9 @@ do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 do_cmd cd src/${NAME} || exit 1 do_cmd rm instantiate || exit 1 -do_cmd find . -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || exit 1 -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 -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." +do_parameter_subst NAMEMINUSL HEADER_NAME + +true # kate: replace-trailing-space-save true; space-indent true; tab-width 4; # vim: expandtab:ts=4:sw=4 diff --git a/scripts/module-create.sh b/scripts/module-create.sh index 6bd34f6..d714ea1 100755 --- a/scripts/module-create.sh +++ b/scripts/module-create.sh @@ -13,6 +13,7 @@ # Get the directory of the repository (needed to include functions file) cd $(dirname $0) cd $(dirname $(pwd)) +P=$(basename $(pwd)) [ -z "${VERBOSE}" ] && VERBOSE="0" source scripts/functions.sh || exit 1 @@ -45,22 +46,33 @@ fi -# 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() { - 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 +# function to rename a package to a bash/C identifier +get_cname() { + echo $1 | tr +- p_ } -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; # vim: expandtab:ts=4:sw=4