From e3d423b32b2dc551b399caad61e3ff15cddb1e2b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 18 Jun 2021 15:02:23 +0200 Subject: [PATCH] Introduced ninja tidy --- scripts/compilation/qp_create_ninja | 12 ++++++++ scripts/module/module_handler.py | 45 +++++++++++++++-------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/scripts/compilation/qp_create_ninja b/scripts/compilation/qp_create_ninja index a132bc9e..c0ba8c6a 100755 --- a/scripts/compilation/qp_create_ninja +++ b/scripts/compilation/qp_create_ninja @@ -709,6 +709,11 @@ def save_subninja_file(path_module): " description = Cleaning module {0}".format(path_module.rel), ""] + l_string += ["rule make_tidy", + " command = module_handler.py tidy {0}".format(path_module.rel), + " description = Cleaning module {0}".format(path_module.rel), + ""] + l_string += ["rule executables", " command = make -C {0} executables .gitignore qp_edit.native qp_run.native".format(join("$QP_ROOT","ocaml")), " description = Updating OCaml executables", @@ -719,6 +724,7 @@ def save_subninja_file(path_module): "build local: make_local_binaries dummy_target", "", "build executables: executables local dummy_target", "", "default executables", "", "build clean: make_clean dummy_target", + "", "build tidy: make_tidy dummy_target", ""] path_ninja_cur = join(path_module.abs, "build.ninja") @@ -745,6 +751,10 @@ def create_build_ninja_global(): " command = module_handler.py clean --all", " description = Cleaning all modules", ""] + l_string += ["rule make_tidy", + " command = module_handler.py tidy --all", + " description = Cleaning all modules", ""] + l_string += ["rule make_ocaml", " command = make -C {0}/ocaml".format("$QP_ROOT"), " pool = console", @@ -759,6 +769,8 @@ def create_build_ninja_global(): "default ocaml_target", "", "build clean: make_clean dummy_target", + "", + "build tidy: make_tidy dummy_target", "", ] path_ninja_cur = join(QP_ROOT, "build.ninja") diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index a6bb6d3f..de8f2bb9 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -6,10 +6,13 @@ Module utilitary Usage: module_handler.py print_descendant [...] module_handler.py clean [ --all | ...] - module_handler.py create_git_ignore [...] + module_handler.py tidy [ --all | ...] Options: print_descendant Print the genealogy of the needed modules + clean Used for ninja clean + tidy A light version of clean, where only the intermediate + files are removed NEED The path of NEED file. by default try to open the file in the current path """ @@ -230,7 +233,7 @@ if __name__ == '__main__': for module in l_module: print(" ".join(sorted(m.l_descendant_unique([module])))) - if arguments["clean"]: + if arguments["clean"] or arguments["tidy"]: l_dir = ['IRPF90_temp', 'IRPF90_man'] l_file = ["irpf90_entities", "tags", "irpf90.make", "Makefile", @@ -242,25 +245,25 @@ if __name__ == '__main__': l_symlink = m.l_descendant_unique([module]) l_exe = get_binaries(module_abs) + for f in l_dir: + try: + shutil.rmtree(os.path.join(module_abs, f)) + except: + pass + + for symlink in l_symlink: + try: + os.unlink(os.path.join(module_abs, symlink)) + except: + pass + + for f in l_file: + try: + os.remove(os.path.join(module_abs, f)) + except: + pass + if arguments["clean"]: - for f in l_dir: - try: - shutil.rmtree(os.path.join(module_abs, f)) - except: - pass - - for symlink in l_symlink: - try: - os.unlink(os.path.join(module_abs, symlink)) - except: - pass - - for f in l_file: - try: - os.remove(os.path.join(module_abs, f)) - except: - pass - for f in l_exe: try: @@ -268,6 +271,4 @@ if __name__ == '__main__': except: pass - if arguments["create_git_ignore"]: - pass