mirror of
https://github.com/LCPQ/quantum_package
synced 2024-08-07 04:50:21 +02:00
Now Makefile.depend is handlbe by ... module_handler !
This commit is contained in:
parent
9131c261f1
commit
f738d273d5
@ -12,19 +12,6 @@ source ${QPACKAGE_ROOT}/scripts/qp_include.sh
|
|||||||
|
|
||||||
check_current_dir_is_module
|
check_current_dir_is_module
|
||||||
|
|
||||||
# Check if the NEEDED_MODULES file is consistent
|
|
||||||
INCLUDE_DIRS="${NEEDED_MODULES} include"
|
|
||||||
NEEDED_MODULES_OK=$(module_handler.py check_dependencies ${NEEDED_MODULES} )
|
|
||||||
if [[ $? -ne 0 ]]
|
|
||||||
then
|
|
||||||
error "
|
|
||||||
Your NEEDED_MODULES file is inconsistent. It should be
|
|
||||||
${NEEDED_MODULES_OK}
|
|
||||||
"
|
|
||||||
else
|
|
||||||
info "NEEDED_MODULES files is consistent"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if README.rst exists
|
# Check if README.rst exists
|
||||||
if [[ ! -f README.rst ]]
|
if [[ ! -f README.rst ]]
|
||||||
then
|
then
|
||||||
@ -47,25 +34,3 @@ then
|
|||||||
else
|
else
|
||||||
info "ASSUMPTIONS.rst is present."
|
info "ASSUMPTIONS.rst is present."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Create symbolic links of other modules
|
|
||||||
if [[ $PWD != ${QPACKAGE_ROOT}/src ]]
|
|
||||||
then
|
|
||||||
for dir in ${INCLUDE_DIRS}
|
|
||||||
do
|
|
||||||
if [[ ! -h $dir ]] ;
|
|
||||||
then
|
|
||||||
ln -s ../$dir $dir
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update Makefile.depend
|
|
||||||
${QPACKAGE_ROOT}/scripts/module/create_Makefile_depend.sh
|
|
||||||
|
|
||||||
# Update EZFIO interface
|
|
||||||
${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py
|
|
||||||
|
|
||||||
# Create png
|
|
||||||
${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png
|
|
@ -781,8 +781,7 @@ if __name__ == "__main__":
|
|||||||
if any([arguments[i] for i in ["--irpf90",
|
if any([arguments[i] for i in ["--irpf90",
|
||||||
"--ezfio_config",
|
"--ezfio_config",
|
||||||
"--ocaml",
|
"--ocaml",
|
||||||
"--ezfio_default",
|
"--ezfio_default"]]):
|
||||||
"--global"]]):
|
|
||||||
# User changer somme argument, do what he want
|
# User changer somme argument, do what he want
|
||||||
do_all = False
|
do_all = False
|
||||||
else:
|
else:
|
||||||
@ -827,7 +826,7 @@ if __name__ == "__main__":
|
|||||||
# e z f i o _ d e f a u l t #
|
# e z f i o _ d e f a u l t #
|
||||||
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
|
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
|
||||||
|
|
||||||
if do_all or arguments["--global"]:
|
if do_all:
|
||||||
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)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This script should run from the directory $QPACKAGE_ROOT/src
|
# This script should run from the directory $QPACKAGE_ROOT/src
|
||||||
|
|
||||||
|
# Check is we are in `QPROOT_SRC` and all the dependancy are corect
|
||||||
${QPACKAGE_ROOT}/scripts/check_src.sh
|
${QPACKAGE_ROOT}/scripts/check_src.sh
|
||||||
|
|
||||||
NPROC=$(cat /proc/cpuinfo | grep MHz | wc -l)
|
NPROC=$(cat /proc/cpuinfo | grep MHz | wc -l)
|
||||||
@ -16,7 +17,22 @@ do
|
|||||||
fi
|
fi
|
||||||
cd ${MODULE}
|
cd ${MODULE}
|
||||||
echo ${MODULE}
|
echo ${MODULE}
|
||||||
|
|
||||||
|
# Update Makefile.depend
|
||||||
${QPACKAGE_ROOT}/scripts/check_module.sh
|
${QPACKAGE_ROOT}/scripts/check_module.sh
|
||||||
|
|
||||||
|
# Update Makefile.depend
|
||||||
|
${QPACKAGE_ROOT}/scripts/module/create_Makefile_depend.sh
|
||||||
|
${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend
|
||||||
|
|
||||||
|
# save_makefile_depend
|
||||||
|
|
||||||
|
# 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
|
||||||
@ -30,7 +46,12 @@ Build failed for module $MODULE
|
|||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# Create gitignore
|
||||||
${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh
|
${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh
|
||||||
|
|
||||||
|
# Create png
|
||||||
|
${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png
|
||||||
|
|
||||||
cd ${OLDPWD}
|
cd ${OLDPWD}
|
||||||
done
|
done
|
||||||
${QPACKAGE_ROOT}/scripts/module/create_executables_list.sh
|
${QPACKAGE_ROOT}/scripts/module/create_executables_list.sh
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# This script is automatically invoked by Makefiles and should not be invoked
|
|
||||||
# by users.
|
|
||||||
# Creates the Makefile.depend file. This file contains all the external source
|
|
||||||
# files included by including other modules.
|
|
||||||
# Thu Apr 3 01:44:09 CEST 2014
|
|
||||||
|
|
||||||
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_module
|
|
||||||
|
|
||||||
SRC=""
|
|
||||||
OBJ=""
|
|
||||||
DEPS="$NEEDED_MODULES"
|
|
||||||
|
|
||||||
for M in ${DEPS}
|
|
||||||
do
|
|
||||||
# X is the list of external source files
|
|
||||||
X=$(grep 'SRC=' "${QPACKAGE_ROOT}/src/${M}/Makefile" 2>/dev/null |cut -d '=' -f 2)
|
|
||||||
for f in ${X}
|
|
||||||
do
|
|
||||||
SRC+=" ${M}/${f}"
|
|
||||||
done
|
|
||||||
X=$(grep 'OBJ=' "${QPACKAGE_ROOT}/src/${M}/Makefile" 2>/dev/null |cut -d '=' -f 2)
|
|
||||||
for f in ${X}
|
|
||||||
do
|
|
||||||
OBJ+=" IRPF90_temp/${M}/${f/IRPF90_temp//}"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create the Makefile.depend
|
|
||||||
cat << EOF > Makefile.depend
|
|
||||||
# This file was created by the $0 script. Do not modify it by hand.
|
|
||||||
|
|
||||||
SRC+=${SRC}
|
|
||||||
OBJ+=${OBJ}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
#!/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
|
|
||||||
|
|
||||||
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_module
|
|
||||||
|
|
||||||
OUTPUT=$(module_handler.py check_dependencies $@)
|
|
||||||
|
|
||||||
if [[ $? -eq 0 ]]
|
|
||||||
then
|
|
||||||
echo $@ > NEEDED_CHILDREN_MODULES
|
|
||||||
fi
|
|
@ -7,9 +7,10 @@ Create the NEEDED_MODULE
|
|||||||
of a NEEDED_CHILDREN_MODULES file
|
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 check_dependencies [<module_name>...]
|
module_handler.py save_makefile_depend
|
||||||
module_handler.py create_png [<NEEDED_CHILDREN_MODULES>]
|
module_handler.py create_symlick [<NEEDED_CHILDREN_MODULES>]
|
||||||
|
module_handler.py create_png [<NEEDED_CHILDREN_MODULES>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
print_genealogy Print the genealogy of the NEEDED_CHILDREN_MODULES
|
print_genealogy Print the genealogy of the NEEDED_CHILDREN_MODULES
|
||||||
@ -81,7 +82,8 @@ def get_it_and_children(l_module):
|
|||||||
try:
|
try:
|
||||||
l.extend(get_it_and_children(d_ref[module]))
|
l.extend(get_it_and_children(d_ref[module]))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >> sys.stderr, "`{0}` in not a good submodule name".format(module)
|
print >> sys.stderr, "`{0}` in not a good submodule name".format(
|
||||||
|
module)
|
||||||
print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES"
|
print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -110,10 +112,64 @@ def reduce_(l_module):
|
|||||||
for i in xrange(len(d_ref)):
|
for i in xrange(len(d_ref)):
|
||||||
for c in itertools.combinations(d_ref, i):
|
for c in itertools.combinations(d_ref, i):
|
||||||
|
|
||||||
guess_genealogy = sorted(get_it_and_children(d_ref, c))
|
guess_genealogy = sorted(get_it_and_children(d_ref, c))
|
||||||
|
|
||||||
if target_genealogy == guess_genealogy:
|
if target_genealogy == guess_genealogy:
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
|
||||||
|
def get_list_depend(l_module):
|
||||||
|
"""
|
||||||
|
transform
|
||||||
|
|
||||||
|
SRC = Utils.f90 test.f90
|
||||||
|
OBJ = IRPF90_temp/map_module.o
|
||||||
|
|
||||||
|
into
|
||||||
|
|
||||||
|
['Utils/map_module.f90','test.f90']
|
||||||
|
['IRPF90_tmp/Utils/map_module.o']
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_list(sep):
|
||||||
|
# Split for sep
|
||||||
|
dump = [l.split(sep)[1] for l in data if l.startswith(sep)]
|
||||||
|
|
||||||
|
# Delete the empy one
|
||||||
|
l_unique = [k for k in map(str.strip, dump) if k]
|
||||||
|
|
||||||
|
# Return the flat one (if multi in l_unique)
|
||||||
|
l_flat = [j for i in l_unique for j in i.split()]
|
||||||
|
return l_flat
|
||||||
|
|
||||||
|
qpackage_root = os.environ['QPACKAGE_ROOT']
|
||||||
|
dir_ = os.path.join(qpackage_root, 'src')
|
||||||
|
|
||||||
|
l_src = []
|
||||||
|
l_obj = []
|
||||||
|
|
||||||
|
for module in l_module:
|
||||||
|
path = os.path.join(dir_, module, "Makefile")
|
||||||
|
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
data = f.readlines()
|
||||||
|
|
||||||
|
l_src.extend("{0}/{1}".format(module, i) for i in get_list("SRC="))
|
||||||
|
|
||||||
|
l_obj.extend(["IRPF90_temp/{0}/{1}".format(module, os.path.basename(i))
|
||||||
|
for i in get_list("OBJ=")])
|
||||||
|
|
||||||
|
return l_src, l_obj
|
||||||
|
|
||||||
|
|
||||||
|
def save_makefile_depend(l_src, l_obj):
|
||||||
|
header = "# This file was created by the module_handler.py script. Do not modify it by hand."
|
||||||
|
|
||||||
|
with open("Makefile.depend", "w") as f:
|
||||||
|
f.write(header + "\n"*2)
|
||||||
|
f.write("SRC+= {0}".format(" ".join(l_src)) + "\n")
|
||||||
|
f.write("OBJ+= {0}".format(" ".join(l_obj)) + "\n")
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
|
|
||||||
def create_png_from_path(path):
|
def create_png_from_path(path):
|
||||||
@ -141,11 +197,11 @@ def create_png(l_module):
|
|||||||
|
|
||||||
if module not in all_ready_done:
|
if module not in all_ready_done:
|
||||||
for children in l_children:
|
for children in l_children:
|
||||||
# Add Edge
|
# Add Edge
|
||||||
edge = pydot.Edge(module, children)
|
edge = pydot.Edge(module, children)
|
||||||
graph.add_edge(edge)
|
graph.add_edge(edge)
|
||||||
# Recurs
|
# Recurs
|
||||||
draw_module_edge(children, d_ref[children])
|
draw_module_edge(children, d_ref[children])
|
||||||
all_ready_done.append(module)
|
all_ready_done.append(module)
|
||||||
|
|
||||||
# Init
|
# Init
|
||||||
@ -181,12 +237,25 @@ if __name__ == '__main__':
|
|||||||
l_all_needed_molule = module_genealogy(path)
|
l_all_needed_molule = module_genealogy(path)
|
||||||
print " ".join(sorted(l_all_needed_molule))
|
print " ".join(sorted(l_all_needed_molule))
|
||||||
|
|
||||||
elif arguments["check_dependencies"]:
|
get_list_depend(l_all_needed_molule)
|
||||||
l_module = arguments['<module_name>']
|
|
||||||
if l_module:
|
|
||||||
l_all_needed_molule = get_it_and_children(l_module)
|
|
||||||
else:
|
|
||||||
l_all_needed_molule = module_genealogy(path)
|
|
||||||
|
|
||||||
elif arguments["create_png"]:
|
if arguments['create_symlick']:
|
||||||
|
src = os.getcwd()
|
||||||
|
|
||||||
|
for link_name in module_genealogy(path) + ["include"]:
|
||||||
|
|
||||||
|
source = os.path.join(
|
||||||
|
"/home/razoa/quantum_package/src/",
|
||||||
|
link_name)
|
||||||
|
try:
|
||||||
|
os.symlink(source, link_name)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if arguments['save_makefile_depend']:
|
||||||
|
l_all_needed_molule = module_genealogy(path)
|
||||||
|
l_src, l_obj = get_list_depend(l_all_needed_molule)
|
||||||
|
save_makefile_depend(l_src, l_obj)
|
||||||
|
|
||||||
|
if arguments["create_png"]:
|
||||||
create_png_from_path(path)
|
create_png_from_path(path)
|
||||||
|
@ -125,15 +125,9 @@ fi
|
|||||||
debug "Makefile created"
|
debug "Makefile created"
|
||||||
|
|
||||||
# Create the NEEDED_MODULES file
|
# Create the NEEDED_MODULES file
|
||||||
"${QPACKAGE_ROOT}/scripts/module/create_Needed_modules.sh" ${NEEDED_MODULES} || fail "Unable to create the NEEDED_MODULES file"
|
echo "$NEEDED_MODULES" > NEEDED_CHILDREN_MODULES
|
||||||
if [[ ! -f NEEDED_CHILDREN_MODULES ]]
|
|
||||||
then
|
|
||||||
fail "NEEDED_MODULES was not created"
|
|
||||||
fi
|
|
||||||
|
|
||||||
debug "NEEDED_MODULES created"
|
debug "NEEDED_MODULES created"
|
||||||
|
|
||||||
|
|
||||||
# Create rst templates
|
# Create rst templates
|
||||||
"${QPACKAGE_ROOT}/scripts/module/create_rst_templates.sh" || fail "Unable to create rst templates"
|
"${QPACKAGE_ROOT}/scripts/module/create_rst_templates.sh" || fail "Unable to create rst templates"
|
||||||
|
|
||||||
|
@ -24,23 +24,15 @@ function check_current_dir_is_src()
|
|||||||
|
|
||||||
function check_current_dir_is_module()
|
function check_current_dir_is_module()
|
||||||
{
|
{
|
||||||
cd ..
|
if [[ "$(dirname $PWD)" == "${QPACKAGE_ROOT}/src" ]]
|
||||||
if [[ "${PWD}" == "${QPACKAGE_ROOT}/src" ]]
|
|
||||||
then
|
then
|
||||||
cd $OLDPWD
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
cd $OLDPWD
|
|
||||||
echo "Current directory should be \$QPACKAGE_ROOT/src"
|
echo "Current directory should be \$QPACKAGE_ROOT/src"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -f NEEDED_CHILDREN_MODULES ]]
|
|
||||||
then
|
|
||||||
NEEDED_MODULES=$(module_handler.py print_genealogy NEEDED_CHILDREN_MODULES)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# List of executables in the current directory
|
# List of executables in the current directory
|
||||||
function ls_exe()
|
function ls_exe()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user