2014-04-03 01:45:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# usage:
|
|
|
|
# create_module.sh MOs AOs Electrons
|
|
|
|
# Prepares all the files for the creation of a new module.
|
|
|
|
# The first argument is the name of the module
|
|
|
|
# All remaining aruments are dependencies.
|
|
|
|
# Thu Apr 3 01:44:58 CEST 2014
|
|
|
|
|
2015-03-25 23:03:51 +01:00
|
|
|
if [[ -z ${QPACKAGE_ROOT} ]]
|
|
|
|
then
|
|
|
|
print "The QPACKAGE_ROOT environment variable is not set."
|
|
|
|
print "Please reload the quantum_package.rc file."
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
source ${QPACKAGE_ROOT}/scripts/qp_include.sh
|
|
|
|
|
|
|
|
check_current_dir_is_src
|
|
|
|
|
|
|
|
DEBUG=0
|
2014-04-03 11:19:41 +02:00
|
|
|
|
|
|
|
# If DEBUG=1, the print debug info.
|
|
|
|
function debug()
|
|
|
|
{
|
|
|
|
if [[ $DEBUG -eq 1 ]]
|
|
|
|
then
|
|
|
|
function debug()
|
|
|
|
{
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function debug()
|
|
|
|
{
|
2014-04-03 13:59:51 +02:00
|
|
|
:
|
2014-04-03 11:19:41 +02:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
debug $@
|
|
|
|
}
|
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
function fail()
|
|
|
|
{
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "Error: $@"
|
|
|
|
cd "${QPACKAGE_ROOT}/src"
|
|
|
|
rm -rf -- "${MODULE}"
|
2014-04-03 13:59:51 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2014-04-03 11:19:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 01:45:22 +02:00
|
|
|
MODULE=$1
|
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
# Check command line
|
|
|
|
if [[ -z $MODULE ]]
|
|
|
|
then
|
|
|
|
echo "usage: $(basename $0) <NewModuleName>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
2014-04-03 11:19:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 01:45:22 +02:00
|
|
|
# Check if module already exists
|
|
|
|
if [ -d ${MODULE} ]
|
|
|
|
then
|
|
|
|
echo "Error: Module $MODULE already exists"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-04-03 11:19:41 +02:00
|
|
|
debug "Module does not already exist: OK"
|
|
|
|
|
|
|
|
|
|
|
|
# Set up dependencies
|
2015-05-04 17:26:41 +02:00
|
|
|
ALL_MODULES="$(cat NEEDED_MODULES)"
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "Select which modules you are sure you will need: (press q to quit)"
|
|
|
|
NEEDED_MODULES=""
|
|
|
|
select M in ${ALL_MODULES}
|
|
|
|
do
|
|
|
|
if [[ -z $M ]]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
NEEDED_MODULES+=" $M"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "$NEEDED_MODULES"
|
2014-04-03 13:59:51 +02:00
|
|
|
done
|
2014-04-03 11:19:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 01:45:22 +02:00
|
|
|
# Create module directory and go into it
|
2014-09-02 16:22:00 +02:00
|
|
|
mkdir "${QPACKAGE_ROOT}/src/${MODULE}"
|
2014-04-03 13:59:51 +02:00
|
|
|
if [[ $? != 0 ]]
|
2014-04-03 11:19:41 +02:00
|
|
|
then
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "Error: Unable to create module directory."
|
2014-04-03 11:19:41 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-09-02 16:22:00 +02:00
|
|
|
if [[ ! -d "${QPACKAGE_ROOT}/src/${MODULE}" ]]
|
2014-04-03 11:19:41 +02:00
|
|
|
then
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "Something strange happened: the"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "${QPACKAGE_ROOT}/src/${MODULE}"
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "directory was not created."
|
2014-04-03 11:19:41 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-09-02 16:22:00 +02:00
|
|
|
cd "${QPACKAGE_ROOT}/src/${MODULE}"
|
|
|
|
if [[ "${PWD}" != "${QPACKAGE_ROOT}/src/${MODULE}" ]]
|
2014-04-03 11:19:41 +02:00
|
|
|
then
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "Something strange happened: we should be in"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "${QPACKAGE_ROOT}/src/${MODULE}"
|
2014-04-03 13:59:51 +02:00
|
|
|
echo "but we are in"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "${PWD}"
|
2014-04-03 11:19:41 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
debug "Module directory is created."
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
# Create the Makefile
|
2015-05-04 15:54:51 +02:00
|
|
|
"${QPACKAGE_ROOT}/scripts/module/create_Makefile.sh" || fail "Unable to create Makefile"
|
2014-04-03 13:59:51 +02:00
|
|
|
if [[ ! -f Makefile ]]
|
|
|
|
then
|
|
|
|
fail "Makefile was not created"
|
|
|
|
fi
|
|
|
|
debug "Makefile created"
|
2014-04-03 11:19:41 +02:00
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
# Create the NEEDED_MODULES file
|
2015-05-04 15:54:51 +02:00
|
|
|
"${QPACKAGE_ROOT}/scripts/module/create_Needed_modules.sh" ${NEEDED_MODULES} || fail "Unable to create the NEEDED_MODULES file"
|
2015-05-04 15:36:58 +02:00
|
|
|
if [[ ! -f NEEDED_CHILDREN_MODULES ]]
|
2014-04-03 13:59:51 +02:00
|
|
|
then
|
|
|
|
fail "NEEDED_MODULES was not created"
|
|
|
|
fi
|
2014-04-03 11:19:41 +02:00
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
debug "NEEDED_MODULES created"
|
2014-04-03 11:19:41 +02:00
|
|
|
|
2014-04-03 01:45:22 +02:00
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
# Create rst templates
|
2015-05-04 15:54:51 +02:00
|
|
|
"${QPACKAGE_ROOT}/scripts/module/create_rst_templates.sh" || fail "Unable to create rst templates"
|
2014-04-03 01:45:22 +02:00
|
|
|
|
|
|
|
|
2014-04-03 11:19:41 +02:00
|
|
|
# Update module list in main NEEDED_MODULES
|
|
|
|
ALL_MODULES+=" ${MODULE}"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "${ALL_MODULES}" > "${QPACKAGE_ROOT}/src/NEEDED_MODULES"
|
2014-04-03 11:19:41 +02:00
|
|
|
debug "Updated NEEDED_MODULES"
|
|
|
|
|
2014-04-03 13:59:51 +02:00
|
|
|
|