diff --git a/scripts/create_Makefile.sh b/scripts/create_Makefile.sh index d0e29726..20fafac6 100755 --- a/scripts/create_Makefile.sh +++ b/scripts/create_Makefile.sh @@ -2,51 +2,27 @@ # # usage: # create_Makefile.sh MOs AOs Electrons -# Creates the Makefile with the dependencies on other modules given -# in the command line. This command is supposed to be run in a module -# directory and searches the dependencies in ../ +# Creates the Makefile . This command is supposed to be run in a +# module directory. # Thu Apr 3 01:44:41 CEST 2014 -DEPS_LONG="" -for i in $@ -do - DEPS_LONG+=" $i " - DEPS_LONG+=$(cat ${QPACKAGE_ROOT}/src/${i}/NEEDED_MODULES) -done +MODULE=$(basename $PWD) -DEPS=($( -for d in $DEPS_LONG -do - echo $d -done | sort | uniq -)) +if [[ $MODULE == "src" ]] +then + echo "Error: This script should not be run in the src directory." + exit 1 +fi -# Create the NEEDED_MODULES file -cat << EOF > NEEDED_MODULES -${DEPS[@]} -EOF - -# Create the Makefile cat << EOF > Makefile default: all -NEEDED_MODULES=\$(shell cat NEEDED_MODULES) - # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ SRC= OBJ= -include Makefile.depend -include \$(QPACKAGE_ROOT)/src/Makefile.config include \$(QPACKAGE_ROOT)/src/Makefile.common -include irpf90.make - -irpf90.make: \$(filter-out IRPF90_temp/%, \$(wildcard */*.irp.f)) \$(wildcard *.irp.f) \$(wildcard *.inc.f) Makefile \$(EZFIO) NEEDED_MODULES - \$(IRPF90) - -Makefile.depend: NEEDED_MODULES - \$(QPACKAGE_ROOT)/scripts/create_Makefile_depend.sh EOF diff --git a/scripts/create_Needed_modules.sh b/scripts/create_Needed_modules.sh new file mode 100755 index 00000000..9b08b127 --- /dev/null +++ b/scripts/create_Needed_modules.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Creates the initial NEEDED_MODULES file. +# This script is supposed to run in a module directory. +# Thu Apr 3 13:38:38 CEST 2014 + +MODULE=$(basename $PWD) + +if [[ $MODULE == "src" ]] +then + echo "Error: This script should not be run in the src directory." + exit 1 +fi + +OUTPUT=$(${QPACKAGE_ROOT}/scripts/check_dependencies.sh $@) +echo ${OUTPUT} > NEEDED_MODULES + + diff --git a/scripts/create_module.sh b/scripts/create_module.sh index b8fafbb7..f1151b41 100755 --- a/scripts/create_module.sh +++ b/scripts/create_module.sh @@ -7,7 +7,7 @@ # All remaining aruments are dependencies. # Thu Apr 3 01:44:58 CEST 2014 -DEBUG=0 +DEBUG=1 # If DEBUG=1, the print debug info. function debug() @@ -21,18 +21,32 @@ function debug() else function debug() { + : } fi debug $@ } +function fail() +{ + echo "Error: " $@ + cd ${QPACKAGE_ROOT}/src + rm -rf ${MODULE} + exit 1 +} MODULE=$1 -shift -DEPS=$@ +# Check command line +if [[ -z $MODULE ]] +then + echo "usage: $(basename $0) " + exit 1 +fi + +shift @@ -48,52 +62,75 @@ debug "Module does not already exist: OK" # Set up dependencies ALL_MODULES=$(cat NEEDED_MODULES) +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" + echo $NEEDED_MODULES +done -if [[ 1 -eq 0 ]] ; then # TODO - # Create module directory and go into it -if [[ ! mkdir ${QPACKAGE_ROOT}/src/${MODULE} ]] +mkdir ${QPACKAGE_ROOT}/src/${MODULE} +if [[ $? != 0 ]] then - print "Unable to create module directory." + echo "Error: Unable to create module directory." exit 1 fi if [[ ! -d ${QPACKAGE_ROOT}/src/${MODULE} ]] then - print "Something strange happened: the" - print ${QPACKAGE_ROOT}/src/${MODULE} - print "directory was not created." + echo "Something strange happened: the" + echo ${QPACKAGE_ROOT}/src/${MODULE} + echo "directory was not created." exit 1 fi cd ${QPACKAGE_ROOT}/src/${MODULE} if [[ ${PWD} != ${QPACKAGE_ROOT}/src/${MODULE} ]] then - print "Something strange happened: we should be in" - print ${QPACKAGE_ROOT}/src/${MODULE} - print "but we are in" - print ${PWD} + echo "Something strange happened: we should be in" + echo ${QPACKAGE_ROOT}/src/${MODULE} + echo "but we are in" + echo ${PWD} exit 1 fi debug "Module directory is created." -fi # TODO - - - - # Create the Makefile -${QPACKAGE_ROOT}/create_Makefile.sh +${QPACKAGE_ROOT}/scripts/create_Makefile.sh || fail "Unable to create Makefile" +if [[ ! -f Makefile ]] +then + fail "Makefile was not created" +fi +debug "Makefile created" + +# Create the NEEDED_MODULES file +${QPACKAGE_ROOT}/scripts/create_Needed_modules.sh ${NEEDED_MODULES} || fail "Unable to create the NEEDED_MODULES file" +if [[ ! -f NEEDED_MODULES ]] +then + fail "NEEDED_MODULES was not created" +fi + +debug "NEEDED_MODULES created" + + +# Create rst templates +${QPACKAGE_ROOT}/scripts/create_rst_templates.sh || fail "Unable to create rst templates" # Update module list in main NEEDED_MODULES ALL_MODULES+=" ${MODULE}" -cd ${QPACKAGE_ROOT}/src -echo ${ALL_MODULES} > NEEDED_MODULES +echo ${ALL_MODULES} > ${QPACKAGE_ROOT}/src/NEEDED_MODULES debug "Updated NEEDED_MODULES" + diff --git a/scripts/create_rst_templates.sh b/scripts/create_rst_templates.sh new file mode 100755 index 00000000..fe403816 --- /dev/null +++ b/scripts/create_rst_templates.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Creates the rst files when creating a new module. +# Thu Apr 3 11:54:16 CEST 2014 + +MODULE=$(basename $PWD) + +if [[ $MODULE == "src" ]] +then + echo "Error: This script should not be run in the src directory." + exit 1 +fi + +function asksure() { + echo -n $@ "(Y/N) " + while read -r -n 1 -s answer; do + if [[ $answer = [YyNn] ]]; then + [[ $answer = [Yy] ]] && retval=0 + [[ $answer = [Nn] ]] && retval=1 + break + fi + done + return $retval +} + +if [[ -f README.rst ]] +then + asksure "Overwrite existing README.rst file?" || exit 1 +fi + +UNDERLINE="=======" +declare -i i=0 +while [[ i -lt ${#MODULE} ]] +do + UNDERLINE+="=" + i+=1 +done + +cat << EOF > README.rst +$UNDERLINE +$MODULE Module +$UNDERLINE + + + +Assumptions +----------- + +.. include:: ./ASSUMPTIONS.rst + + +Needed Modules +-------------- + +.. include:: ./NEEDED_MODULES + +EOF + diff --git a/src/Makefile.common b/src/Makefile.common index d69e11bd..00177fb9 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -11,7 +11,7 @@ NEEDED_MODULES_OK=$(shell X=`$(QPACKAGE_ROOT)/scripts/check_dependencies.sh $(NE ifneq ($(NEEDED_MODULES_OK),OK) $(info ---------------------) $(info Your NEEDED_MODULES file is inconsistent. It should be:) - $(info $(NEEDED_MODULES)) + $(info $(NEEDED_MODULES_OK)) $(info ---------------------) $(error ) endif @@ -21,6 +21,8 @@ ifeq ($(IRP_VERSION_OK),False) $(error 'IRPF90 version >= 1.3 is required') endif +README_RST_OK=$(shell ls README.rst || echo Failed) +ASSUMPTIONS_RST_OK=$(shell ls ASSUMPTIONS.rst || echo Failed) MAKEFILE_OK=$(shell ls $(QPACKAGE_ROOT)/src/Makefile.config 2> /dev/null && echo True || echo False) ifeq ($(MAKEFILE_OK),False) diff --git a/src/NEEDED_MODULES b/src/NEEDED_MODULES index 77c2ba5e..99f5a6ef 100644 --- a/src/NEEDED_MODULES +++ b/src/NEEDED_MODULES @@ -1 +1 @@ -AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils +AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils Mimi diff --git a/src/README.rst b/src/README.rst index 18773ac6..680f4235 100644 --- a/src/README.rst +++ b/src/README.rst @@ -26,7 +26,7 @@ ReStructured Text format to enable the automatic generation of the Sphinx documentation. When the current module depends on other modules, the list of modules should -be added in the Makefile in the ``INCLUDE_DIRS`` variable. +be added in the ``NEEDED_MODULES`` file. Creating a new module