10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-29 16:34:50 +02:00

New Working (maybe?) makefile

This commit is contained in:
Thomas Applencourt 2015-05-15 16:30:43 +02:00
parent 6e182577e3
commit 538dfff980
8 changed files with 118 additions and 100 deletions

View File

@ -5,13 +5,14 @@ Welcom the ei_handler.
We will create all the ezfio related stuff from a EZFIO.cfg file. We will create all the ezfio related stuff from a EZFIO.cfg file.
Usage: Usage:
ei_handler.py [--path] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] [--global] ei_handler.py [--recursif] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default]
ei_handler.py ocaml_global
By default all the option are executed. By default all the option are executed.
Options: Options:
-h --help -h --help
--path The path of the `EZFIO.cfg`, by default will look in the ${pwd} --recursif Folow the dependancy of the module
--irpf90 Create the `ezfio_interface.irpf90` --irpf90 Create the `ezfio_interface.irpf90`
which contains all the providers needed which contains all the providers needed
(aka all with the `interface: input` parameter) (aka all with the `interface: input` parameter)
@ -23,7 +24,7 @@ Options:
--ezfio_default Create the `${module_lower}_ezfio_interface_default` in --ezfio_default Create the `${module_lower}_ezfio_interface_default` in
`${QPACKAGE_ROOT}/data/ezfio_defaults` needed by `${QPACKAGE_ROOT}/data/ezfio_defaults` needed by
the ocaml the ocaml
--global Create all the stuff who need all the EZFIO.cfg ocaml_global Create the qp_edit
Format specification : Format specification :
[provider_name] | the name of the provider in irp.f90 [provider_name] | the name of the provider in irp.f90
@ -62,9 +63,12 @@ import ConfigParser
from collections import defaultdict from collections import defaultdict
from collections import namedtuple from collections import namedtuple
from cache import cache from cache import cache
from os import listdir
from os.path import isdir, join, exists, islink
Type = namedtuple('Type', 'fancy ocaml fortran') Type = namedtuple('Type', 'fancy ocaml fortran')
@ -632,9 +636,6 @@ def get_l_module_lower():
# L _ f o l d e r # # L _ f o l d e r #
# ~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~ #
from os import listdir
from os.path import isdir, join, exists
l_folder = [f for f in listdir(mypath) if isdir(join(mypath, f))] l_folder = [f for f in listdir(mypath) if isdir(join(mypath, f))]
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ #
@ -738,42 +739,10 @@ def save_ocaml_qp_edit(str_ocaml_qp_edit):
f.write(str_ocaml_qp_edit) f.write(str_ocaml_qp_edit)
if __name__ == "__main__": def code_generation(arguments, dict_ezfio_cfg, m):
arguments = docopt(__doc__)
# ___
# | ._ o _|_
# _|_ | | | |_
#
if not arguments["--global"]: module_lower = m.lower
if not arguments["--path"]: path_dirname = m.path.replace("/EZFIO.cfg", "")
config_file_path = "EZFIO.cfg"
if "EZFIO.cfg" not in os.listdir(os.getcwd()):
sys.exit(0)
else:
config_file_path = arguments["path"]
# Get the full path
config_file_path = os.path.expanduser(config_file_path)
config_file_path = os.path.expandvars(config_file_path)
config_file_path = os.path.abspath(config_file_path)
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
# G e t _ m o d u l e _ d i r #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
path_dirname = os.path.dirname(config_file_path)
module = [i for i in path_dirname.split("/") if i][-1]
module_lower = module.lower()
# Because we only authorise this right now!
ezfio_dir = module_lower
dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir)
# _
# / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._
# \_ (_) (_| (/_ (_| (/_ | | (/_ | (_| |_ | (_) | |
# _|
# ~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~ #
# W h a t _ t o _ d o # # W h a t _ t o _ d o #
@ -822,11 +791,61 @@ if __name__ == "__main__":
str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) str_ezfio_default = create_ezfio_default(dict_ezfio_cfg)
save_ezfio_default(module_lower, str_ezfio_default) save_ezfio_default(module_lower, str_ezfio_default)
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
# e z f i o _ d e f a u l t #
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
if do_all: if __name__ == "__main__":
arguments = docopt(__doc__)
# ___
# | ._ o _|_
# _|_ | | | |_
#
if arguments["ocaml_global"]:
str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global() str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global()
save_ocaml_input_auto(str_ocaml_input_auto) save_ocaml_input_auto(str_ocaml_input_auto)
save_ocaml_qp_edit(str_ocaml_qp_edit) save_ocaml_qp_edit(str_ocaml_qp_edit)
sys.exit(0)
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
# G e t _ m o d u l e _ d i r #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
path_dirname = os.getcwd()
root_module = [i for i in path_dirname.split("/") if i][-1]
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
# G e t _ l _ d i c t _ e z f i o _ c f g #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
if arguments["--recursif"]:
def true_link(f):
return islink(join(path_dirname, f))
l_symlink = [f for f in listdir(path_dirname) if true_link(f)]
else:
l_symlink = []
l_module = [root_module] + l_symlink
def check_ezfio(f):
return exists()
qpackage_root_src = join(os.environ['QPACKAGE_ROOT'], "src")
l_module_with_ezfio = []
Module = namedtuple('Module', 'path lower')
for f in l_module:
path = join(qpackage_root_src, f, "EZFIO.cfg")
if exists(path):
l_module_with_ezfio.append(Module(path, f.lower()))
l_dict_ezfio_cfg = [(get_dict_config_file(m.path, m.lower), m) for m in l_module_with_ezfio]
# _
# / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._
# \_ (_) (_| (/_ (_| (/_ | | (/_ | (_| |_ | (_) | |
# _|
for (dict_ezfio_cfg, m) in l_dict_ezfio_cfg:
code_generation(arguments, dict_ezfio_cfg, m)

View File

@ -9,7 +9,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-"
for dir in ${QPACKAGE_ROOT}/src/*/ for dir in ${QPACKAGE_ROOT}/src/*/
do do
cd $dir || exit -1 cd $dir || exit -1
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --ezfio_config --ezfio_default
done done
# For old-style directories. Will be removed some day... # For old-style directories. Will be removed some day...

View File

@ -18,15 +18,6 @@ do
cd ${MODULE} cd ${MODULE}
echo ${MODULE} echo ${MODULE}
# Update Makefile.depend
${QPACKAGE_ROOT}/scripts/module/check_module.sh
# Update EZFIO interface (create the irp.f90 and the ocaml)
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --irpf90 --ocaml
# Create symlink
${QPACKAGE_ROOT}/scripts/module/module_handler.py create_symlick
if [[ $# -eq 1 ]] if [[ $# -eq 1 ]]
then then
env make -j ${NPROC} all env make -j ${NPROC} all
@ -40,14 +31,6 @@ Build failed for module $MODULE
" "
fi fi
fi fi
# Create gitignore
${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh
# Create png
${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png
# Create png
${QPACKAGE_ROOT}/scripts/module/update_README.py
cd ${OLDPWD} cd ${OLDPWD}
done done

View File

@ -9,7 +9,7 @@ of a NEEDED_CHILDREN_MODULES file
Usage: Usage:
module_handler.py print_genealogy [<NEEDED_CHILDREN_MODULES>] module_handler.py print_genealogy [<NEEDED_CHILDREN_MODULES>]
module_handler.py save_makefile_depend module_handler.py save_makefile_depend
module_handler.py create_symlick [<NEEDED_CHILDREN_MODULES>] module_handler.py create_symlink [<NEEDED_CHILDREN_MODULES>]
module_handler.py create_png [<NEEDED_CHILDREN_MODULES>] module_handler.py create_png [<NEEDED_CHILDREN_MODULES>]
Options: Options:
@ -249,7 +249,7 @@ if __name__ == '__main__':
get_list_depend(l_all_needed_molule) get_list_depend(l_all_needed_molule)
if arguments['create_symlick']: if arguments['create_symlink']:
src = os.getcwd() src = os.getcwd()
for link_name in module_genealogy(path) + ["include"]: for link_name in module_genealogy(path) + ["include"]:

View File

@ -17,7 +17,7 @@ import subprocess
header = """ header = """
.. Do not edit this section. It was auto-generated from the .. Do not edit this section. It was auto-generated from the
.. NEEDED_MODULES file. .. update_README.py.
""" """
@ -74,7 +74,7 @@ def update_assumptions(data):
def update_needed(data): def update_needed(data):
"""Read the NEEDED_MODULES file, and replace the data with it. """Read the NEEDED_CHILDREN_MODULES file, and replace the data with it.
Create the links to the GitHub pages.""" Create the links to the GitHub pages."""
file = open('NEEDED_CHILDREN_MODULES', 'r') file = open('NEEDED_CHILDREN_MODULES', 'r')

View File

@ -24,11 +24,16 @@ function check_current_dir_is_src()
function check_current_dir_is_module() function check_current_dir_is_module()
{ {
if [[ "$(dirname $PWD)" == "${QPACKAGE_ROOT}/src" ]] # If the prefix ${QPACKAGE_ROOT}/src/ can be removed from $PWD, it means that
# $PWD is somewhere below ${QPACKAGE_ROOT}/src/ so it is a module.
# If the prefix ${QPACKAGE_ROOT}/src/ can not be removed from $PWD, then
# "${PWD##${QPACKAGE_ROOT}/src/}" == "$PWD".
if [[ "${PWD##${QPACKAGE_ROOT}/src/}" != "$PWD" ]]
then then
return 0 return 0
else else
echo "Current directory should be \$QPACKAGE_ROOT/src" echo "You are not in a submodule"
exit -1 exit -1
fi fi
} }

View File

@ -8,7 +8,7 @@ Needed Modules
============== ==============
.. Do not edit this section. It was auto-generated from the .. Do not edit this section. It was auto-generated from the
.. NEEDED_MODULES file. .. update_README.py.
.. image:: tree_dependancy.png .. image:: tree_dependancy.png
@ -19,7 +19,7 @@ Documentation
============= =============
.. Do not edit this section. It was auto-generated from the .. Do not edit this section. It was auto-generated from the
.. NEEDED_MODULES file. .. update_README.py.
`ao_bi_elec_integral_alpha <http://github.com/LCPQ/quantum_package/tree/master/src/Hartree_Fock/Fock_matrix.irp.f#L102>`_ `ao_bi_elec_integral_alpha <http://github.com/LCPQ/quantum_package/tree/master/src/Hartree_Fock/Fock_matrix.irp.f#L102>`_
Alpha Fock matrix in AO basis set Alpha Fock matrix in AO basis set

View File

@ -1,17 +1,5 @@
.PHONY: default silent .PHONY: default
.SECONDARY: symlink ezfio_interface
ifneq ($(IN_MAKE),1)
default:
@$(MAKE) -C $(QPACKAGE_ROOT)/src $$(basename $(PWD))
veryclean:
clean_modules.sh
clean:
IN_MAKE=1 make clean
else # Called by scripts/build_module.sh
default: all .gitignore default: all .gitignore
@ -21,9 +9,6 @@ include $(QPACKAGE_ROOT)/src/Makefile.config
# Create the NEEDED_CHILDREN_MODULES variable, needed for IRPF90 # Create the NEEDED_CHILDREN_MODULES variable, needed for IRPF90
NEEDED_CHILDREN_MODULES=$(shell module_handler.py print_genealogy) NEEDED_CHILDREN_MODULES=$(shell module_handler.py print_genealogy)
# Check and update dependencies
include Makefile.depend
# Define the Makefile common variables # Define the Makefile common variables
EZFIO_DIR=$(QPACKAGE_ROOT)/EZFIO EZFIO_DIR=$(QPACKAGE_ROOT)/EZFIO
EZFIO=$(EZFIO_DIR)/lib/libezfio_irp.a EZFIO=$(EZFIO_DIR)/lib/libezfio_irp.a
@ -36,21 +21,47 @@ LIB+=$(EZFIO) $(MKL)
IRPF90+=$(patsubst %, -I %, $(INCLUDE_DIRS)) $(IRPF90_FLAGS) IRPF90+=$(patsubst %, -I %, $(INCLUDE_DIRS)) $(IRPF90_FLAGS)
# Update Makefile.depend # Update Makefile.depend
Makefile.depend: $(wildcart */Makefile) Makefile.depend: $(wildcard */Makefile)
${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend ${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend
irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile.depend Makefile $(EZFIO) NEEDED_CHILDREN_MODULES $(wildcard *.py) # Check and update dependencies
- $(IRPF90) include Makefile.depend
- update_README.py
# Create symlink
symlink: $(wildcard $(QPACKAGE_ROOT)/src/*/NEEDED_CHILDREN_MODULES)
${QPACKAGE_ROOT}/scripts/module/module_handler.py create_symlink
# Define the EZFIO rules
$(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*/*.ezfio_config) $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg)
$(QPACKAGE_ROOT)/scripts/ezfio_interface/prepare_ezfio.sh
cd $(EZFIO_DIR);\
export FC="$(FC)" ; export FCFLAGS="$(FCFLAGS)" ; export IRPF90="$(IRPF90)" ;\
$(MAKE) ;\
$(MAKE) Python
# Update EZFIO interface (create the irp.f90 and the ocaml)
ezfio_interface: symlink $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg)
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --irpf90 --ocaml --recursif
irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard .inc.f) Makefile.depend Makefile $(EZFIO) $(wildcard *.py) symlink ezfio_interface
$(IRPF90)
include irpf90.make include irpf90.make
endif # Need NEEDED_CHILDREN_MODULES and IRPMAN
README.rst: NEEDED_CHILDREN_MODULES irpf90.make
${QPACKAGE_ROOT}/scripts/module/update_README.py
.gitignore: tree_dependancy.png: NEEDED_CHILDREN_MODULES
$(QPACKAGE_ROOT)/scripts/create/create_gitignore.sh ${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png
# Frequent typos #Need all the executable
clena: clean .gitignore: irpf90.make
veryclena: veryclean ${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh
vercylean: veryclean
#
#
# # Frequent typos
# clena: clean
# veryclena: roger
# vercylean: roger