From 1da715d8f28307bc43665ee594ace236e0294289 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 15 Dec 2020 18:40:37 +0100 Subject: [PATCH] Faster compilation --- external/irpf90 | 2 +- scripts/compilation/qp_create_ninja | 48 +++++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/external/irpf90 b/external/irpf90 index 132a4a16..1c016129 160000 --- a/external/irpf90 +++ b/external/irpf90 @@ -1 +1 @@ -Subproject commit 132a4a1661c9878d21dcbf0ac14f7fe9a3b110d0 +Subproject commit 1c016129f6347df7525ca9d686ad8a5acbaac183 diff --git a/scripts/compilation/qp_create_ninja b/scripts/compilation/qp_create_ninja index ad61d363..38f7e765 100755 --- a/scripts/compilation/qp_create_ninja +++ b/scripts/compilation/qp_create_ninja @@ -43,6 +43,7 @@ EZFIO_LIB = join("$QP_ROOT", "lib", "libezfio_irp.a") ZMQ_LIB = join("$QP_ROOT", "lib", "libf77zmq.a") + " " + join("$QP_ROOT", "lib", "libzmq.a") + " -lstdc++ -lrt -ldl" ROOT_BUILD_NINJA = join("$QP_ROOT", "config", "build.ninja") ROOT_BUILD_NINJA_EXP = join(QP_ROOT, "config", "build.ninja") +ROOT_BUILD_NINJA_EXP_tmp = join(QP_ROOT, "config", "build.ninja.tmp") header = r"""# # _______ _____ # __ __ \___ _______ _________ /____ ________ ___ @@ -149,7 +150,7 @@ def get_l_module_with_ezfio_cfg(): from os import listdir from os.path import isfile - return [real_join(QP_SRC, m) for m in listdir(QP_SRC) + return [real_join(QP_SRC, m) for m in sorted(listdir(QP_SRC)) if isfile(real_join(QP_SRC, m, "EZFIO.cfg"))] @@ -328,13 +329,13 @@ def ninja_symlink_build(path_module, l_symlink): if not l_symlink: return [] - l_folder = [s.destination for s in l_symlink] + l_folder = [s.destination for s in sorted(l_symlink,key=lambda x:x.destination)] l_string = ["build l_symlink_{0} : phony {1}".format(path_module.rel, " ".join(map(comp_path,l_folder))), ""] - for symlink in l_symlink: + for symlink in sorted(l_symlink, key=lambda x: x.source+x.destination): l_string += ["build {0}: build_symlink {1}".format(*list(map(comp_path,(symlink.destination, symlink.source)))), ""] return l_string @@ -360,7 +361,7 @@ def ninja_gitignore_build(path_module, d_binaries, l_symlink): path_gitignore = comp_path(join(path_module.abs, ".gitignore")) - l_b = list(map(comp_path,[i.abs for i in d_binaries[path_module]])) + l_b = sorted(list(map(comp_path,[i.abs for i in d_binaries[path_module]]))) root = "build {0}: build_gitignore {1}".format(path_gitignore, " ".join(l_b)) @@ -389,7 +390,7 @@ def get_l_file_for_module(path_module): l_template = [] - for f in os.listdir(path_module.abs): + for f in sorted(os.listdir(path_module.abs)): if f.lower().endswith(tuple([".template.f", ".include.f"])): l_template.append(join(path_module.abs, f)) elif f.endswith(".irp.f"): @@ -495,10 +496,10 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): # D e p e n d a n c y # # ~#~#~#~#~#~#~#~#~#~ # - l_depend = list(map(comp_path,d_irp[path_module]["l_depend"])) - l_src = list(map(comp_path,d_irp[path_module]["l_src"])) - l_obj = list(map(comp_path,d_irp[path_module]["l_obj"])) - l_template = list(map(comp_path,d_irp[path_module]["l_template"])) + l_depend = sorted(list(map(comp_path,d_irp[path_module]["l_depend"]))) + l_src = sorted(list(map(comp_path,d_irp[path_module]["l_src"]))) + l_obj = sorted(list(map(comp_path,d_irp[path_module]["l_obj"]))) + l_template = sorted(list(map(comp_path,d_irp[path_module]["l_template"]))) if l_needed_molule: l_symlink = ["l_symlink_{0}".format(path_module.rel)] @@ -511,7 +512,7 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): # N i n j a _ b u i l d # # ~#~#~#~#~#~#~#~#~#~#~ # - l_include_dir = ["-I {0}".format(m.rel) for m in l_needed_molule] + l_include_dir = ["-I {0}".format(m.rel) for m in sorted(l_needed_molule, key=lambda x:x.rel+x.abs) ] l_string = [ "build {0}: build_irpf90.ninja {1}".format(str_creation, str_depend), @@ -642,7 +643,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): # ~#~#~ # ninja_module_path = join(comp_path(path_module.abs), "IRPF90_temp/build.ninja") - l_abs_bin = list(map(comp_path,[binary.abs for binary in d_binaries[path_module]])) + l_abs_bin = sorted(list(map(comp_path,[binary.abs for binary in d_binaries[path_module]]))) # ~#~#~#~#~#~ # # s t r i n g # @@ -659,8 +660,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): def ninja_module_build(path_module, d_binaries): - l_abs_bin = list(map(comp_path,[binary.abs for binary in d_binaries[path_module]])) - + l_abs_bin = sorted(list(map(comp_path,[binary.abs for binary in d_binaries[path_module]]))) path_readme = os.path.join(comp_path(path_module.abs), "README.rst") l_string = ["build module_{0}: phony {1}".format(path_module.rel, @@ -830,14 +830,14 @@ if __name__ == "__main__": dict_root = module_instance.dict_root dict_root_path = dict_module_genelogy_path(dict_root) - l_all_module = list(d_genealogy_path.keys()) + l_all_module = sorted(list(d_genealogy_path.keys())) # ~#~#~#~#~#~#~#~#~#~#~#~#~ # # M o d u l e _ t o _ i r p # # ~#~#~#~#~#~#~#~#~#~#~#~#~ # d_binaries = get_dict_binaries(l_all_module, mode="development") - l_module = list(d_binaries.keys()) + l_module = sorted(list(d_binaries.keys()), key=lambda x: x.rel+x.abs) # ~#~#~#~#~#~#~#~#~#~#~#~ # @@ -851,7 +851,6 @@ if __name__ == "__main__": # ~#~#~#~#~#~#~#~#~#~#~#~ # for module_to_compile in l_module: - if module_to_compile.rel == "dummy": continue @@ -884,6 +883,21 @@ if __name__ == "__main__": # S a v e s # # ~#~#~#~#~ # - with open(ROOT_BUILD_NINJA_EXP, "w+") as f: + with open(ROOT_BUILD_NINJA_EXP_tmp, "w+") as f: f.write(header) f.write("\n".join(l_string)) + + with open(ROOT_BUILD_NINJA_EXP_tmp, "r") as f: + a = f.read() + + try: + with open(ROOT_BUILD_NINJA_EXP, "r") as f: + b = f.read() + except: + b = None + + if a != b: + os.rename(ROOT_BUILD_NINJA_EXP_tmp, ROOT_BUILD_NINJA_EXP) + else: + os.remove(ROOT_BUILD_NINJA_EXP_tmp) +