Major work in progress on build system module instantiation.

This commit is contained in:
Laurence Withers 2006-07-24 21:55:12 +01:00
parent 9e8d1e4c15
commit 11f2baa34b
53 changed files with 516 additions and 117 deletions

View File

@ -8,4 +8,5 @@
/* options for text editors /* options for text editors
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
*/ */

View File

@ -8,4 +8,5 @@
/* options for text editors /* options for text editors
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
*/ */

View File

@ -10,7 +10,7 @@ then
echo "Building application ${@NAME@}..." echo "Building application ${@NAME@}..."
source src/cppapp/build.monolithic source src/@NAME@/build.monolithic
MODIFIED=0 MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC} for test in ${MONOLITHIC_TESTS} ${SRC}
@ -36,3 +36,6 @@ then
@NAME@_BUILT=1 @NAME@_BUILT=1
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -7,3 +7,6 @@ build_dir_tree "${BINDIR}" || return 1
echo "Installing binaries into '${BINDIR}'" echo "Installing binaries into '${BINDIR}'"
install_file "${@NAME@}" "${BINDIR}" 0755 || return 1 install_file "${@NAME@}" "${BINDIR}" 0755 || return 1
print_success "Done" print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -13,3 +13,6 @@ then
@NAME@_MONOLITHIC=1 @NAME@_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -14,8 +14,12 @@ echo "Instantiating module src/${NAME}..."
do_cmd mkdir src/${NAME} || exit 1 do_cmd mkdir src/${NAME} || exit 1
do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1 do_cmd cp ${TEMPLATE}/* src/${NAME} || exit 1
do_cmd rm src/${NAME}/instantiate || exit 1
do_cmd find src/${NAME} -type f -exec sed -e "s,@NAME@,${NAME},g" -i {} \; || 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." print_success "Module instantiated."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,4 +1,4 @@
/* @P@/src/cpplib/BottomHeader.h /* @P@/src/@NAME@/BottomHeader.h
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
@ -8,4 +8,5 @@
/* options for text editors /* options for text editors
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
*/ */

View File

@ -1,14 +1,15 @@
/* @P@/src/cpplib/TopHeader.h /* @P@/src/@NAME@/TopHeader.h
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
*/ */
#ifndef HEADER_@PC@ #ifndef HEADER_@CNAME@
#define HEADER_@PC@ #define HEADER_@CNAME@
// standard includes, or includes needed for type declarations // standard includes, or includes needed for type declarations
/* options for text editors /* options for text editors
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
*/ */

View File

@ -1,13 +1,14 @@
/* @P@/src/cpplib/TopSource.cpp /* @P@/src/@NAME@/TopSource.cpp
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
*/ */
#include "@HEADER_NAME@" #include "@HEADER@"
// Below are all the includes used throughout the library. // Below are all the includes used throughout the library.
/* options for text editors /* options for text editors
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
*/ */

View File

@ -1 +1 @@
source src/cpplib/build.lib source src/@NAME@/build.lib

View File

@ -1 +1 @@
source src/cpplib/build.install-lib source src/@NAME@/build.install-lib

View File

@ -7,8 +7,8 @@ build_dir_tree "${INCLUDEDIR}" || return 1
# install library # install library
echo "Installing libraries into '${LIBDIR}'" echo "Installing libraries into '${LIBDIR}'"
install_file ${LIBCPP} ${LIBDIR} 0755 || return 1 install_file ${@NAME@} ${LIBDIR} 0755 || return 1
BASE="${LIBCPP_BASE}.so" BASE="${@NAME@_BASE}.so"
MAJOR="${BASE}.${SOMAJOR}" MAJOR="${BASE}.${SOMAJOR}"
MINOR="${MAJOR}.${SOMINOR}" MINOR="${MAJOR}.${SOMINOR}"
MICRO="${MINOR}.${SOMICRO}" MICRO="${MINOR}.${SOMICRO}"
@ -17,8 +17,8 @@ install_symlink "${MAJOR}" "${MINOR}" "${LIBDIR}"
install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}" install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}"
# install header # install header
echo "Installing header file '${LIBCPP_HEADER}' into ${INCLUDEDIR}" echo "Installing header file '${@NAME@_HEADER}' into ${INCLUDEDIR}"
install_header ${LIBCPP_HEADER} ${INCLUDEDIR} 0644 || return 1 install_header ${@NAME@_HEADER} ${INCLUDEDIR} 0644 || return 1
# install pkgconfig file # install pkgconfig file
echo "Installing package config file into ${PKGCONFDIR}" echo "Installing package config file into ${PKGCONFDIR}"
@ -28,7 +28,9 @@ do_cmd_redir ${PKGCONFFILE} sed \
-e "s,@VERSION@,${VERSION}," \ -e "s,@VERSION@,${VERSION}," \
-e "s,@LIBDIR@,${FINALLIBDIR}," \ -e "s,@LIBDIR@,${FINALLIBDIR}," \
-e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \ -e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \
src/cpplib/pkgconf.in src/@NAME@/pkgconf.in
do_cmd chmod 0644 ${PKGCONFFILE} do_cmd chmod 0644 ${PKGCONFFILE}
print_success "Done" print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,24 +1,25 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# LIBCPP # @NAME@
# LIBCPP_BUILT # @NAME@_BUILT
# LIBCPP_HEADER # @NAME@_HEADER
# LIBCPP_BASE # @NAME@_BASE
if [ -z ${LIBCPP_BUILT} ] if [ -z ${@NAME@_BUILT} ]
then then
@NAME@_BASE=@NAME@
source src/@NAME@/soversion
LIB_BASE="@P@" @NAME@="obj/${@NAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}"
LIB="obj/${LIB_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}" SO_EXTRA="-lstdc++ -lc" # @TODO@ libs, cflags
SO_LIBS="-lstdc++ -lc"
echo "Building library ${LIB}..." echo "Building library ${@NAME@}..."
source src/cpplib/build.monolithic source src/@NAME@/build.monolithic
MODIFIED=0 MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${HDR} ${SRC} for test in ${MONOLITHIC_TESTS} ${HDR} ${SRC}
do do
if [ ${test} -nt ${LIB} ] if [ ${test} -nt ${@NAME@} ]
then then
MODIFIED=1 MODIFIED=1
break break
@ -29,10 +30,10 @@ then
then then
echo " Compiling" echo " Compiling"
SONAME="${LIB_BASE}.so.${SOMAJOR}.${SOMINOR}" SONAME="${@NAME@_BASE}.so.${SOMAJOR}.${SOMINOR}"
do_cmd ${CXX} ${CFLAGS} -shared -fpic -o "${LIB}" \ do_cmd ${CXX} ${CFLAGS} -shared -fpic -o "${@NAME@}" \
-Wl,-soname,${SONAME} \ -Wl,-soname,${SONAME} \
${SRC} ${SO_LIBS} || return 1 ${SRC} ${SO_EXTRA} || return 1
# make tests work # make tests work
do_cmd ln -sf $(basename ${LIB}) obj/${SONAME} || return 1 do_cmd ln -sf $(basename ${LIB}) obj/${SONAME} || return 1
@ -42,9 +43,9 @@ then
print_success "Library up to date" print_success "Library up to date"
fi fi
LIBCPP=${LIB} @NAME@_BUILT=1
LIBCPP_BUILT=1 @NAME@_HEADER=${HDR}
LIBCPP_HEADER=${HDR}
LIBCPP_BASE=${LIB_BASE}
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,18 +1,20 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# LIBCPP_MONOLITHIC # @NAME@_MONOLITHIC
if [ -z "${LIBCPP_MONOLITHIC}" ] if [ -z "${@NAME@_MONOLITHIC}" ]
then then
SRC="obj/lib.cpp" SRC="obj/lib.cpp"
HDR="obj/@HEADER_NAME@" HDR="obj/@HEADER_NAME@"
MONOLITHIC_TESTS="src/cpplib/build.lib src/cpplib/build.monolithic" MONOLITHIC_TESTS="src/@NAME@/build.lib src/@NAME@/build.monolithic"
MONOLITHIC_SOURCE="$(echo src/cpplib/{TopHeader,BottomHeader}.h)" MONOLITHIC_SOURCE="$(echo src/@NAME@/{TopHeader,BottomHeader}.h)"
make_monolithic ${HDR} C || return 1 make_monolithic ${HDR} C || return 1
MONOLITHIC_SOURCE="$(echo src/cpplib/TopSource.cpp)" MONOLITHIC_SOURCE="$(echo src/@NAME@/TopSource.cpp)"
make_monolithic ${SRC} C || return 1 make_monolithic ${SRC} C || return 1
LIBCPP_MONOLITHIC=1 @NAME@_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}" MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}"
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,44 @@
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."
echo "HEADER_NAME is the name of the header file."
exit 1
fi
CNAME=$1
shift
HEADER_NAME=$1
shift
if [ -e src/${NAME} ]
then
print_failure "src/${NAME} already exists."
exit 1
fi
if [ "$(echo ${NAME} | cut -b1-3)" -ne "lib" ]
then
echo "Warning: your module name does not begin with 'lib'. You will"
echo "have to fix up your pkgconfig file manually, etc."
NAMEMINUSL="@TODO@"
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_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."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,4 +1,4 @@
# @P@/src/lib/cpplib/pkgconf.in # @P@/src/lib/@NAME@/pkgconf.in
# #
# Metadata file for pkg-config # Metadata file for pkg-config
# ( http://www.freedesktop.org/software/pkgconfig/ ) # ( http://www.freedesktop.org/software/pkgconfig/ )
@ -16,5 +16,5 @@ Version: @VERSION@
Requires: Requires:
# Compilation information # Compilation information
Libs: -L@LIBDIR@ @PMINUSL@ Libs: -L@LIBDIR@ @NAMEMINUSL@
Cflags: -I@INCLUDEDIR@ Cflags: -I@INCLUDEDIR@

View File

@ -1 +1,3 @@
source src/tests/build.tests source src/@NAME@/build.tests
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,20 +1,26 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# TESTS_BUILT # @NAME@_BUILT
# #
build_target lib build_target @LIBS@
LIBS="${LIBCPP}"
if [ -z ${TESTS_BUILT} ] if [ -z ${@NAME@_BUILT} ]
then then
echo "Building test programs..." LIBS=""
do_cmd mkdir -p obj/tests || return 1 for lib in @LIBS@
for SRC in src/tests/*.cpp
do do
TEST="obj/tests/$(basename ${SRC} | sed -e 's,.cpp$,,')" LIBS="${LIBS} ${!${lib}}"
done
EXTRAS="" # @TODO@ libs, cflags
echo "Building test programs..."
do_cmd mkdir -p obj/@NAME@ || return 1
for SRC in src/@NAME@/*.cpp
do
TEST="obj/@NAME@/$(basename ${SRC} | sed -e 's,.cpp$,,')"
MODIFIED=0 MODIFIED=0
for file in ${LIBCPP} ${SRC} for file in ${LIBS} ${SRC} src/@NAME@/build.tests
do do
if [ ${file} -nt ${TEST} ] if [ ${file} -nt ${TEST} ]
then then
@ -25,7 +31,7 @@ then
if [ ${MODIFIED} -ne 0 ] if [ ${MODIFIED} -ne 0 ]
then then
do_cmd ${CXX} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} || return 1 do_cmd ${CXX} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} || return 1
print_success "Built ${TEST}" print_success "Built ${TEST}"
else else
print_success "${TEST} is up to date" print_success "${TEST} is up to date"
@ -34,6 +40,8 @@ then
print_success "All tests built" print_success "All tests built"
TESTS_BUILT=1 @NAME@_BUILT=1
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,38 @@
if [ $# -lt 1 ]
then
print_failure "Not enough arguments after module; need LIBS."
echo "LIBS are the library module names for these test programs."
exit 1
fi
LIBS="$@"
for lib in ${LIBS}
do
if [ ! -e src/${lib} ]
then
print_failure "src/${lib} does not exist"
exit 1
fi
done
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 find . -type f -exec sed -e "s,@LIBS@,${LIBS},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;
# vim: expandtab:ts=4:sw=4

View File

@ -1,10 +1,10 @@
/* @P@/src/tests/???.cpp /* @P@/src/@NAME@/???.cpp
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
*/ */
#include "@HEADER_NAME@" @TODO@ includes
#include <iostream> #include <iostream>
@ -39,4 +39,5 @@ int main(int argc, char* argv[])
/* options for text editors /* options for text editors
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
*/ */

View File

@ -8,4 +8,5 @@
/* options for text editors /* options for text editors
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
*/ */

View File

@ -8,4 +8,5 @@
/* options for text editors /* options for text editors
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
*/ */

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
# APPC # @NAME@
# APPC_BUILT # @NAME@_BUILT
# #
if [ -z ${APPC_BUILT} ] if [ -z ${@NAME@_BUILT} ]
then then
APP="obj/@P@" @NAME@="obj/@NAME@"
LIBS="" EXTRAS="@TODO@" # cflags, libs
echo "Building application ${APP}..." echo "Building application ${@NAME@}..."
source src/capp/build.monolithic source src/@NAME@/build.monolithic
MODIFIED=0 MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC} for test in ${MONOLITHIC_TESTS} ${SRC}
do do
if [ ${test} -nt ${APP} ] if [ ${test} -nt ${@NAME@} ]
then then
MODIFIED=1 MODIFIED=1
break break
@ -24,17 +24,18 @@ then
if [ ${MODIFIED} -ne 0 ] if [ ${MODIFIED} -ne 0 ]
then then
echo " Compiling" echo " Compiling..."
do_cmd ${CC} ${CFLAGS} -o "${APP}" \ do_cmd ${CC} ${CFLAGS} -o "${@NAME@}" ${SRC} ${EXTRAS} || return 1
${SRC} ${LIBS} || return 1
print_success "Application built" print_success "Application built"
else else
print_success "Application up to date" print_success "Application up to date"
fi fi
APPC=${APP} @NAME@_BUILT=1
APPC_BUILT=1
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1 +1 @@
source src/capp/build.app source src/@NAME@/build.app

View File

@ -1 +1 @@
source src/capp/build.install-app source src/@NAME@/build.install-app

View File

@ -5,5 +5,8 @@ build_dir_tree "${BINDIR}" || return 1
# install binary # install binary
echo "Installing binaries into '${BINDIR}'" echo "Installing binaries into '${BINDIR}'"
install_file "${APPC}" "${BINDIR}" 0755 || return 1 install_file "${@NAME@}" "${BINDIR}" 0755 || return 1
print_success "Done" print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,15 +1,18 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# APPC_MONOLITHIC # @NAME@_MONOLITHIC
# #
if [ -z "${APPC_MONOLITHIC}" ] if [ -z "${@NAME@_MONOLITHIC}" ]
then then
SRC="obj/app.c" SRC="obj/@NAME@.c"
MONOLITHIC_TESTS="src/capp/build.app src/capp/build.monolithic" MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic"
MONOLITHIC_SOURCE="$(echo src/capp/TopHeader.h) $(echo src/capp/TopSource.c)" MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.c)"
make_monolithic ${SRC} C || return 1 make_monolithic ${SRC} C || return 1
APPC_MONOLITHIC=1 @NAME@_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}" MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,25 @@
if [ $# -ne 0 ]
then
print_failure "Too many arguments. None required for this module."
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."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1 +1,3 @@
source src/clib/build.lib source src/clib/build.lib
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1 +1,3 @@
source src/clib/build.install-lib source src/clib/build.install-lib
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -32,3 +32,5 @@ do_cmd_redir ${PKGCONFFILE} sed \
do_cmd chmod 0644 ${PKGCONFFILE} do_cmd chmod 0644 ${PKGCONFFILE}
print_success "Done" print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -48,3 +48,5 @@ then
LIBC_BASE=${LIB_BASE} LIBC_BASE=${LIB_BASE}
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -16,3 +16,5 @@ then
LIBC_MONOLITHIC=1 LIBC_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}" MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}"
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,44 @@
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."
echo "HEADER_NAME is the name of the header file."
exit 1
fi
CNAME=$1
shift
HEADER_NAME=$1
shift
if [ -e src/${NAME} ]
then
print_failure "src/${NAME} already exists."
exit 1
fi
if [ "$(echo ${NAME} | cut -b1-3)" -ne "lib" ]
then
echo "Warning: your module name does not begin with 'lib'. You will"
echo "have to fix up your pkgconfig file manually, etc."
NAMEMINUSL="@TODO@"
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_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."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1 +1,3 @@
source src/tests/build.tests source src/@NAME@/build.tests
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,20 +1,26 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# TESTS_BUILT # @NAME@_BUILT
# #
build_target lib build_target @LIBS@
LIBS="${LIBCPP}"
if [ -z ${TESTS_BUILT} ] if [ -z ${@NAME@_BUILT} ]
then then
echo "Building test programs..." LIBS=""
do_cmd mkdir -p obj/tests || return 1 for lib in @LIBS@
for SRC in src/tests/*.cpp
do do
TEST="obj/tests/$(basename ${SRC} | sed -e 's,.cpp$,,')" LIBS="${LIBS} ${!${lib}}"
done
EXTRAS="" # @TODO@ libs, cflags
echo "Building test programs..."
do_cmd mkdir -p obj/@NAME@ || return 1
for SRC in src/@NAME@/*.c
do
TEST="obj/@NAME@/$(basename ${SRC} | sed -e 's,.c$,,')"
MODIFIED=0 MODIFIED=0
for file in ${LIBCPP} ${SRC} for file in ${LIBS} ${SRC} src/@NAME@/build.tests
do do
if [ ${file} -nt ${TEST} ] if [ ${file} -nt ${TEST} ]
then then
@ -25,7 +31,7 @@ then
if [ ${MODIFIED} -ne 0 ] if [ ${MODIFIED} -ne 0 ]
then then
do_cmd ${CXX} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} || return 1 do_cmd ${CC} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} || return 1
print_success "Built ${TEST}" print_success "Built ${TEST}"
else else
print_success "${TEST} is up to date" print_success "${TEST} is up to date"
@ -34,6 +40,8 @@ then
print_success "All tests built" print_success "All tests built"
TESTS_BUILT=1 @NAME@_BUILT=1
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,38 @@
if [ $# -lt 1 ]
then
print_failure "Not enough arguments after module; need LIBS."
echo "LIBS are the library module names for these test programs."
exit 1
fi
LIBS="$@"
for lib in ${LIBS}
do
if [ ! -e src/${lib} ]
then
print_failure "src/${lib} does not exist"
exit 1
fi
done
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 find . -type f -exec sed -e "s,@LIBS@,${LIBS},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;
# vim: expandtab:ts=4:sw=4

View File

@ -1,19 +1,19 @@
/* @P@/src/tests/???.cpp /* @P@/src/@NAME@/???.c
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
*/ */
#include "@HEADER_NAME@" @TODO@ includes
#include <iostream> #include "stdio.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if(argc == 2 && !strcmp(argv[1], "--print-summary")) { if(argc == 2 && !strcmp(argv[1], "--print-summary")) {
std::cout << "One line summary.\n"; printf("One line summary.\n");
return 0; return 0;
} }
@ -22,21 +22,12 @@ int main(int argc, char* argv[])
} }
int ret = 0; int ret = 0;
try { // TODO
// TODO
}
catch(std::exception& e) {
std::cerr << e.what() << std::endl;
ret = 1;
}
catch(...) {
std::cerr << "Unknown exception caught." << std::endl;
ret = 1;
}
return ret; return ret;
} }
/* options for text editors /* options for text editors
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
*/ */

View File

@ -1,4 +1,4 @@
# @P@/src/docs/Doxyfile.in # @P@/src/@NAME@/Doxyfile.in
# #
# (c)2006, Laurence Withers. Released under the GNU GPL. See file # (c)2006, Laurence Withers. Released under the GNU GPL. See file
# COPYING for more information / terms of license. # COPYING for more information / terms of license.

View File

@ -1,4 +1,4 @@
/* @P@/src/docs/MainPage.dox /* @P@/src/@NAME@/MainPage.dox
* *
* (c)2006, Laurence Withers. Released under the GNU GPL. See file * (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license. * COPYING for more information / terms of license.
@ -10,4 +10,5 @@
/* options for text editors /* options for text editors
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
*/ */

View File

@ -1 +1 @@
source src/docs/build.docs source src/@NAME@/build.docs

View File

@ -1,15 +1,15 @@
# These are external variables, and shouldn't clash with anything else # These are external variables, and shouldn't clash with anything else
# DOCS_BUILT # @NAME@_BUILT
# #
MONOLITHIC_DOC="${MONOLITHIC_DOC} $(echo src/docs/*.dox)" MONOLITHIC_@NAME@="${MONOLITHIC_DOC} $(echo src/@NAME@/*.dox)"
build_target monolithic build_target monolithic
if [ -z ${DOCS_BUILT} ] if [ -z ${@NAME@_BUILT} ]
then then
echo "Building documentation with Doxygen..." echo "Building documentation with Doxygen..."
DOXYFILE=obj/Doxyfile DOXYFILE=obj/Doxyfile.@NAME@
if [ ! -e ${DOXYFILE} ] if [ ! -e ${DOXYFILE} ]
then then
@ -19,7 +19,7 @@ then
fi fi
MODIFIED=0 MODIFIED=0
for file in ${MONOLITHIC_DOC} for file in ${MONOLITHIC_@NAME@}
do do
if [ ${file} -nt html/index.html ] if [ ${file} -nt html/index.html ]
then then
@ -36,6 +36,8 @@ then
print_success "Documentation is up to date" print_success "Documentation is up to date"
fi fi
DOCS_BUILT=1 @NAME@_BUILT=1
fi fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1 +1 @@
source src/docs/build.install-docs source src/@NAME@/build.install-docs

View File

@ -17,3 +17,5 @@ do
done done
print_success "Documentation installed" print_success "Documentation installed"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,25 @@
if [ $# -ne 0 ]
then
print_failure "Too many arguments. None required for this module."
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."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,12 @@
/* @P@/src/capp/TopHeader.h
*
* (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license.
*/
// standard includes, or includes needed for type declarations
/* options for text editors
kate: replace-trailing-space-save true; space-indent true; tab-width 4;
vim: expandtab:ts=4:sw=4
*/

View File

@ -0,0 +1,12 @@
/* @P@/src/capp/TopSource.c
*
* (c)2006, Laurence Withers. Released under the GNU GPL. See file
* COPYING for more information / terms of license.
*/
// Below are all the includes used throughout the application.
/* options for text editors
kate: replace-trailing-space-save true; space-indent true; tab-width 4;
vim: expandtab:ts=4:sw=4
*/

View File

@ -0,0 +1 @@
source src/@NAME@/build.firmware

View File

@ -0,0 +1,45 @@
# These are external variables, and shouldn't clash with anything else
# @NAME@
# @NAME@_BUILT
#
# HACK -- this should probably be in the top-level makefile
[ -z "${SDCC}" ] && SDCC=sdcc
[ -z "${SDCCFLAGS}" ] && SDCCFLAGS="@TODO@"
if [ -z ${@NAME@_BUILT} ]
then
@NAME@="obj/@NAME@.hex"
EXTRAS="@TODO@" # cflags, libs
echo "Building firmware ${@NAME@}..."
source src/@NAME@/build.monolithic
MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC}
do
if [ ${test} -nt ${@NAME@} ]
then
MODIFIED=1
break
fi
done
if [ ${MODIFIED} -ne 0 ]
then
echo " Compiling..."
do_cmd ${SDCC} ${SDCCFLAGS} -o "${@NAME@}" ${SRC} ${EXTRAS} || return 1
print_success "Firmware built"
else
print_success "Firmware up to date"
fi
@NAME@_BUILT=1
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1 @@
source src/@NAME@/build.install-firmware

View File

@ -0,0 +1,12 @@
build_target app
# make paths (this is for Gentoo in particular)
build_dir_tree "${HEXDIR}" || return 1
# install binary
echo "Installing firmware into '${HEXDIR}'"
install_file "${@NAME@}" "${HEXDIR}" 0755 || return 1
print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,18 @@
# These are external variables, and shouldn't clash with anything else
# @NAME@_MONOLITHIC
#
if [ -z "${@NAME@_MONOLITHIC}" ]
then
SRC="obj/@NAME@.c"
MONOLITHIC_TESTS="src/@NAME@/build.app src/@NAME@/build.monolithic"
MONOLITHIC_SOURCE="$(echo src/@NAME@/TopHeader.h) $(echo src/@NAME@/TopSource.c)"
make_monolithic ${SRC} C || return 1
@NAME@_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -0,0 +1,25 @@
if [ $# -ne 0 ]
then
print_failure "Too many arguments. None required for this module."
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."
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4