diff --git a/scripts/build.c++.tests/build.tests b/scripts/build.c++.tests/build.tests index a4dce09..c616bea 100644 --- a/scripts/build.c++.tests/build.tests +++ b/scripts/build.c++.tests/build.tests @@ -2,11 +2,11 @@ # @NAME@_BUILT # -#@TODO@ build_target libs || return 1 +build_target @TEST_LIBS@ || return 1 -if [ -z ${@NAME@_BUILT} ] +if [ -z ${@CNAME@_BUILT} ] then - LIBS="" # @TODO@ internal libs + LIBS="@LINK_LIBS@" EXTRAS="" # @TODO@ libs, cflags echo "Building test programs..." @@ -36,7 +36,7 @@ then print_success "All tests built" - @NAME@_BUILT=1 + @CNAME@_BUILT=1 fi # kate: @KATE_MODELINE@ diff --git a/scripts/build.c++.tests/instantiate b/scripts/build.c++.tests/instantiate index 49e9e24..54ae426 100644 --- a/scripts/build.c++.tests/instantiate +++ b/scripts/build.c++.tests/instantiate @@ -1,25 +1,28 @@ -if [ $# -ne 0 ] +if [ $# -lt 1 ] then - print_failure "Unexpected extra parameters." + print_failure "You must specify the library modules to link against." exit 1 fi -if [ -e src/${NAME} ] -then - print_failure "src/${NAME} already exists." - exit 1 -fi +TEST_LIBS=$@ +for lib in ${TEST_LIBS} +do + cname="$(get_cname ${lib})" + LINK_LIBS="\${${cname}} ${LINK_LIBS}" + if [ ! -e ../${lib}/build.lib ] + then + print_failure "src/${lib} is not a library" + exit 1 + fi -echo "Instantiating module src/${NAME}..." + # HACK -- we need to extract the library's header name + do_cmd export ${cname}_MONOLITHIC="1" + do_cmd source ../${lib}/build.monolithic || exit 1 + TEST_HEADERS="#include \"${HDR}\"\n${TEST_HEADERS}" +done -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 TEST_LIBS LINK_LIBS TEST_HEADERS +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++.tests/template b/scripts/build.c++.tests/template index 2e8f5ee..007d255 100644 --- a/scripts/build.c++.tests/template +++ b/scripts/build.c++.tests/template @@ -5,8 +5,7 @@ * http://www.gnu.org/copyleft/gpl.html for details. */ -@TODO@ includes - +@TEST_HEADERS@ #include @@ -39,6 +38,6 @@ int main(int argc, char* argv[]) } /* options for text editors -kate: replace-trailing-space-save true; space-indent true; tab-width 4; -vim: expandtab:ts=4:sw=4 +kate: @KATE_MODELINE@ +vim: @VIM_MODELINE@ */ diff --git a/scripts/build.c.tests/build.tests b/scripts/build.c.tests/build.tests index 2daf8b7..b810139 100644 --- a/scripts/build.c.tests/build.tests +++ b/scripts/build.c.tests/build.tests @@ -2,17 +2,17 @@ # @NAME@_BUILT # -#@TODO@ build_target libs || return 1 +build_target @TEST_LIBS@ || return 1 -if [ -z ${@NAME@_BUILT} ] +if [ -z ${@CNAME@_BUILT} ] then - LIBS="" # @TODO@ internal libs + LIBS="@LINK_LIBS@" EXTRAS="" # @TODO@ libs, cflags echo "Building test programs..." do_cmd mkdir -p obj/tests || return 1 - for SRC in src/@NAME@/*.c + for SRC in src/@NAME@/*.cpp do TEST="obj/tests/$(basename ${SRC} | sed -e 's,.c$,,')" MODIFIED=0 @@ -36,7 +36,7 @@ then print_success "All tests built" - @NAME@_BUILT=1 + @CNAME@_BUILT=1 fi # kate: @KATE_MODELINE@ diff --git a/scripts/build.c.tests/instantiate b/scripts/build.c.tests/instantiate index 49e9e24..54ae426 100644 --- a/scripts/build.c.tests/instantiate +++ b/scripts/build.c.tests/instantiate @@ -1,25 +1,28 @@ -if [ $# -ne 0 ] +if [ $# -lt 1 ] then - print_failure "Unexpected extra parameters." + print_failure "You must specify the library modules to link against." exit 1 fi -if [ -e src/${NAME} ] -then - print_failure "src/${NAME} already exists." - exit 1 -fi +TEST_LIBS=$@ +for lib in ${TEST_LIBS} +do + cname="$(get_cname ${lib})" + LINK_LIBS="\${${cname}} ${LINK_LIBS}" + if [ ! -e ../${lib}/build.lib ] + then + print_failure "src/${lib} is not a library" + exit 1 + fi -echo "Instantiating module src/${NAME}..." + # HACK -- we need to extract the library's header name + do_cmd export ${cname}_MONOLITHIC="1" + do_cmd source ../${lib}/build.monolithic || exit 1 + TEST_HEADERS="#include \"${HDR}\"\n${TEST_HEADERS}" +done -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 TEST_LIBS LINK_LIBS TEST_HEADERS +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.tests/template b/scripts/build.c.tests/template index aa03aff..cde078e 100644 --- a/scripts/build.c.tests/template +++ b/scripts/build.c.tests/template @@ -5,9 +5,8 @@ * http://www.gnu.org/copyleft/gpl.html for details. */ -@TODO@ includes - -#include "stdio.h" +@TEST_HEADERS@ +#include @@ -23,12 +22,13 @@ int main(int argc, char* argv[]) } int ret = 0; + // TODO return ret; } /* options for text editors -kate: replace-trailing-space-save true; space-indent true; tab-width 4; -vim: expandtab:ts=4:sw=4 +kate: @KATE_MODELINE@ +vim: @VIM_MODELINE@ */ diff --git a/scripts/module-create.sh b/scripts/module-create.sh index cbea1f6..eb63895 100755 --- a/scripts/module-create.sh +++ b/scripts/module-create.sh @@ -14,6 +14,7 @@ cd $(dirname $0) cd $(dirname $(pwd)) P=$(basename $(pwd)) +TOP=$(pwd) [ -z "${VERBOSE}" ] && VERBOSE="0" source scripts/functions.sh || exit 1 @@ -76,6 +77,7 @@ then fi cleanup() { + cd ${TOP} rm -rf "src/${NAME}" print_failure "Removed 'src/${NAME}'" exit 1