Work in progress on simplifying instantiation.

This commit is contained in:
Laurence Withers 2006-07-25 19:59:37 +01:00
parent 8bff482066
commit d12c36aa2a
7 changed files with 30 additions and 60 deletions

View File

@ -1,21 +1,21 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# @NAME@ # @CNAME@
# @NAME@_BUILT # @CNAME@_BUILT
# #
if [ -z ${@NAME@_BUILT} ] if [ -z ${@CNAME@_BUILT} ]
then then
@NAME@="obj/@NAME@" @CNAME@="obj/@NAME@"
EXTRAS="@TODO@" # cflags, libs EXTRAS="@TODO@" # cflags, libs
echo "Building application ${@NAME@}..." echo "Building application ${@CNAME@}..."
do_cmd source src/@NAME@/build.monolithic || return 1 do_cmd source src/@NAME@/build.monolithic || return 1
MODIFIED=0 MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC} for test in ${MONOLITHIC_TESTS} ${SRC}
do do
if [ ${test} -nt ${@NAME@} ] if [ ${test} -nt ${@CNAME@} ]
then then
MODIFIED=1 MODIFIED=1
break break
@ -33,7 +33,7 @@ then
print_success "Application up to date" print_success "Application up to date"
fi fi
@NAME@_BUILT=1 @CNAME@_BUILT=1
fi fi

View File

@ -5,7 +5,7 @@ build_dir_tree "${BINDIR}" || return 1
# install binary # install binary
echo "Installing binaries into '${BINDIR}'" echo "Installing binaries into '${BINDIR}'"
install_file "${@NAME@}" "${BINDIR}" 0755 || return 1 install_file "${@CNAME@}" "${BINDIR}" 0755 || return 1
print_success "Done" print_success "Done"
# kate: @KATE_MODELINE@ # kate: @KATE_MODELINE@

View File

@ -1,16 +1,16 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# @NAME@_MONOLITHIC # @CNAME@_MONOLITHIC
# #
SRC="obj/@NAME@.cpp" SRC="obj/@NAME@.cpp"
MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic" MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic"
if [ -z "${@NAME@_MONOLITHIC}" ] if [ -z "${@CNAME@_MONOLITHIC}" ]
then 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 make_monolithic ${SRC} C || return 1
@NAME@_MONOLITHIC=1 @CNAME@_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi fi

View File

@ -4,22 +4,8 @@ then
exit 1 exit 1
fi fi
if [ -e src/${NAME} ] do_parameter_subst
then true
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."
# 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,6 +1,6 @@
if [ $# -ne 2 ] if [ $# -ne 1 ]
then 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." echo "HEADER_NAME is the name of the header file."
exit 1 exit 1
fi fi
@ -8,12 +8,6 @@ fi
HEADER_NAME=$1 HEADER_NAME=$1
shift shift
if [ -e src/${NAME} ]
then
print_failure "src/${NAME} already exists."
exit 1
fi
if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ]
then then
echo "Warning: your module name does not begin with 'lib'. You will" 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,,')" NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')"
fi 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 do_parameter_subst NAMEMINUSL HEADER_NAME
true 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;

View File

@ -1,6 +1,6 @@
if [ $# -ne 2 ] if [ $# -ne 1 ]
then 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." echo "HEADER_NAME is the name of the header file."
exit 1 exit 1
fi fi
@ -8,12 +8,6 @@ fi
HEADER_NAME=$1 HEADER_NAME=$1
shift shift
if [ -e src/${NAME} ]
then
print_failure "src/${NAME} already exists."
exit 1
fi
if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ]
then then
echo "Warning: your module name does not begin with 'lib'. You will" 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,,')" NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')"
fi 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 do_parameter_subst NAMEMINUSL HEADER_NAME
true 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;

View File

@ -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 do_cmd source ${TEMPLATE}/instantiate || exit 1
print_success "Module instantiated" print_success "Module instantiated"
grep -r "@TODO@" . grep -r "@TODO@" .
true true