1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-15 02:05:37 +00:00
Grid/extras/Hadrons/add_module_template.sh

23 lines
756 B
Bash
Raw Normal View History

2016-12-05 08:26:17 +00:00
#!/usr/bin/env bash
2018-04-24 17:55:08 +01:00
if (( $# != 2)); then
echo "usage: `basename $0` <module name> <namespace>" 1>&2
2016-12-05 08:26:17 +00:00
exit 1
fi
NAME=$1
NS=$2
2018-04-24 17:55:08 +01:00
mkdir -p Modules/${NS}
if [ -e "Modules/${NS}/${NAME}.cc" ] || [ -e "Modules/${NS}/${NAME}.hpp" ]; then
echo "error: files Modules/${NS}/${NAME}.* already exists" 1>&2
exit 1
2016-12-05 08:26:17 +00:00
fi
2018-04-24 17:55:08 +01:00
TMPCC=".${NS}.${NAME}.tmp.cc"
TMPHPP=".${NS}.${NAME}.tmp.hpp"
sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_tmp_in_NS.cc.template > ${TMPCC}
sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_tmp_in_NS.hpp.template > ${TMPHPP}
sed "s/___NAMESPACE___/${NS}/g" ${TMPCC} > Modules/${NS}/${NAME}.cc
sed "s/___NAMESPACE___/${NS}/g" ${TMPHPP} > Modules/${NS}/${NAME}.hpp
rm -f ${TMPCC} ${TMPHPP}
2016-12-05 08:26:17 +00:00
./make_module_list.sh