2006-07-25 19:00:04 +01:00
|
|
|
#!/bin/bash
|
2006-07-25 19:19:59 +01:00
|
|
|
# lw-build-system/scripts/module-create.sh
|
2006-07-25 19:00:04 +01:00
|
|
|
#
|
2006-07-25 19:19:59 +01:00
|
|
|
# (c)2006, Laurence Withers, <l@lwithers.me.uk>.
|
2006-07-25 19:00:04 +01:00
|
|
|
# Released under the GNU GPLv2. See file COPYING or
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html for details.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Creates a new source module.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the directory of the repository (needed to include functions file)
|
|
|
|
cd $(dirname $0)
|
|
|
|
cd $(dirname $(pwd))
|
|
|
|
[ -z "${VERBOSE}" ] && VERBOSE="0"
|
|
|
|
source scripts/functions.sh || exit 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get arguments.
|
|
|
|
if [ $# -lt 3 ]
|
|
|
|
then
|
|
|
|
echo "Usage: scripts/module-create.sh <lang> <type> <name> [args]"
|
|
|
|
echo " available modules:"
|
|
|
|
for i in scripts/build.*
|
|
|
|
do
|
|
|
|
echo $i | sed "s,scripts/build\.\([^.]*\)\.\(.*\), lang: \1 type: \2,"
|
|
|
|
done
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
LANG=$1
|
|
|
|
shift
|
|
|
|
TYPE=$1
|
|
|
|
shift
|
|
|
|
NAME=$1
|
|
|
|
shift
|
|
|
|
TEMPLATE=scripts/build.${LANG}.${TYPE}
|
|
|
|
|
|
|
|
if [ ! -e ${TEMPLATE}/instantiate ]
|
|
|
|
then
|
|
|
|
echo "No such module type."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-07-25 19:28:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-25 19:00:04 +01:00
|
|
|
source ${TEMPLATE}/instantiate
|
|
|
|
|
|
|
|
|
|
|
|
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
|
|
|
|
# vim: expandtab:ts=4:sw=4
|