From d12c36aa2a0989864eb4490e86da6e9d9f657876 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Tue, 25 Jul 2006 19:59:37 +0100 Subject: [PATCH] Work in progress on simplifying instantiation. --- scripts/build.c++.app/build.app | 14 +++++++------- scripts/build.c++.app/build.install-app | 2 +- scripts/build.c++.app/build.monolithic | 8 ++++---- scripts/build.c++.app/instantiate | 18 ++---------------- scripts/build.c++.lib/instantiate | 18 ++---------------- scripts/build.c.lib/instantiate | 18 ++---------------- scripts/module-create.sh | 12 ++++++++++++ 7 files changed, 30 insertions(+), 60 deletions(-) diff --git a/scripts/build.c++.app/build.app b/scripts/build.c++.app/build.app index 0bf8dd5..4b38f97 100644 --- a/scripts/build.c++.app/build.app +++ b/scripts/build.c++.app/build.app @@ -1,21 +1,21 @@ # These are external variables, and shouldn't clash with anything else -# @NAME@ -# @NAME@_BUILT +# @CNAME@ +# @CNAME@_BUILT # -if [ -z ${@NAME@_BUILT} ] +if [ -z ${@CNAME@_BUILT} ] then - @NAME@="obj/@NAME@" + @CNAME@="obj/@NAME@" EXTRAS="@TODO@" # cflags, libs - echo "Building application ${@NAME@}..." + echo "Building application ${@CNAME@}..." do_cmd source src/@NAME@/build.monolithic || return 1 MODIFIED=0 for test in ${MONOLITHIC_TESTS} ${SRC} do - if [ ${test} -nt ${@NAME@} ] + if [ ${test} -nt ${@CNAME@} ] then MODIFIED=1 break @@ -33,7 +33,7 @@ then print_success "Application up to date" fi - @NAME@_BUILT=1 + @CNAME@_BUILT=1 fi diff --git a/scripts/build.c++.app/build.install-app b/scripts/build.c++.app/build.install-app index 8703591..739cc0c 100644 --- a/scripts/build.c++.app/build.install-app +++ b/scripts/build.c++.app/build.install-app @@ -5,7 +5,7 @@ build_dir_tree "${BINDIR}" || return 1 # install binary echo "Installing binaries into '${BINDIR}'" -install_file "${@NAME@}" "${BINDIR}" 0755 || return 1 +install_file "${@CNAME@}" "${BINDIR}" 0755 || return 1 print_success "Done" # kate: @KATE_MODELINE@ diff --git a/scripts/build.c++.app/build.monolithic b/scripts/build.c++.app/build.monolithic index 87d167b..53f171c 100644 --- a/scripts/build.c++.app/build.monolithic +++ b/scripts/build.c++.app/build.monolithic @@ -1,16 +1,16 @@ # These are external variables, and shouldn't clash with anything else -# @NAME@_MONOLITHIC +# @CNAME@_MONOLITHIC # SRC="obj/@NAME@.cpp" MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic" -if [ -z "${@NAME@_MONOLITHIC}" ] +if [ -z "${@CNAME@_MONOLITHIC}" ] then - MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.cpp)" + MONOLITHIC_SOURCE="$(echo src/@NAME@/TopSource.cpp)" make_monolithic ${SRC} C || return 1 - @NAME@_MONOLITHIC=1 + @CNAME@_MONOLITHIC=1 MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" fi diff --git a/scripts/build.c++.app/instantiate b/scripts/build.c++.app/instantiate index f8f4e51..9fb90de 100644 --- a/scripts/build.c++.app/instantiate +++ b/scripts/build.c++.app/instantiate @@ -4,22 +4,8 @@ then exit 1 fi -if [ -e src/${NAME} ] -then - print_failure "src/${NAME} already exists." - exit 1 -fi - -echo "Instantiating module src/${NAME}..." - -do_cmd mkdir src/${NAME} || exit 1 -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 grep "@TODO@" * || exit 1 -print_success "Module instantiated." +do_parameter_subst +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 3c88ca6..8915e29 100644 --- a/scripts/build.c++.lib/instantiate +++ b/scripts/build.c++.lib/instantiate @@ -1,6 +1,6 @@ -if [ $# -ne 2 ] +if [ $# -ne 1 ] then - print_failure "Not enough arguments after module; need HEADER_NAME." + print_failure "Wrong number of arguments after module; need HEADER_NAME." echo "HEADER_NAME is the name of the header file." exit 1 fi @@ -8,12 +8,6 @@ fi HEADER_NAME=$1 shift -if [ -e src/${NAME} ] -then - print_failure "src/${NAME} already exists." - exit 1 -fi - if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] then echo "Warning: your module name does not begin with 'lib'. You will" @@ -23,15 +17,7 @@ else NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" fi -echo "Instantiating module src/${NAME}..." - -do_cmd mkdir src/${NAME} || exit 1 -do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 - -do_cmd cd src/${NAME} || exit 1 -do_cmd rm instantiate || exit 1 do_parameter_subst NAMEMINUSL HEADER_NAME - true # kate: replace-trailing-space-save true; space-indent true; tab-width 4; diff --git a/scripts/build.c.lib/instantiate b/scripts/build.c.lib/instantiate index 3c88ca6..8915e29 100644 --- a/scripts/build.c.lib/instantiate +++ b/scripts/build.c.lib/instantiate @@ -1,6 +1,6 @@ -if [ $# -ne 2 ] +if [ $# -ne 1 ] then - print_failure "Not enough arguments after module; need HEADER_NAME." + print_failure "Wrong number of arguments after module; need HEADER_NAME." echo "HEADER_NAME is the name of the header file." exit 1 fi @@ -8,12 +8,6 @@ fi HEADER_NAME=$1 shift -if [ -e src/${NAME} ] -then - print_failure "src/${NAME} already exists." - exit 1 -fi - if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] then echo "Warning: your module name does not begin with 'lib'. You will" @@ -23,15 +17,7 @@ else NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" fi -echo "Instantiating module src/${NAME}..." - -do_cmd mkdir src/${NAME} || exit 1 -do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 - -do_cmd cd src/${NAME} || exit 1 -do_cmd rm instantiate || exit 1 do_parameter_subst NAMEMINUSL HEADER_NAME - true # kate: replace-trailing-space-save true; space-indent true; tab-width 4; diff --git a/scripts/module-create.sh b/scripts/module-create.sh index d714ea1..0d840c8 100755 --- a/scripts/module-create.sh +++ b/scripts/module-create.sh @@ -69,7 +69,19 @@ do_parameter_subst() { +if [ -e "src/${NAME}" ] +then + print_failure "Module 'src/${NAME}' already exists" + exit 1 +fi + +echo "Instantiating module 'src/${NAME}'..." +do_cmd cp -r ${TEMPLATE} src/${NAME} || exit 1 +do_cmd cd src/${NAME} || exit 1 +do_cmd rm instantiate || exit 1 + do_cmd source ${TEMPLATE}/instantiate || exit 1 + print_success "Module instantiated" grep -r "@TODO@" . true