10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 20:34:58 +01:00

Introduced ninja tidy

This commit is contained in:
Anthony Scemama 2021-06-18 15:02:23 +02:00
parent 4ee8ec68b0
commit e3d423b32b
2 changed files with 35 additions and 22 deletions

View File

@ -709,6 +709,11 @@ def save_subninja_file(path_module):
" description = Cleaning module {0}".format(path_module.rel), " 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", l_string += ["rule executables",
" command = make -C {0} executables .gitignore qp_edit.native qp_run.native".format(join("$QP_ROOT","ocaml")), " command = make -C {0} executables .gitignore qp_edit.native qp_run.native".format(join("$QP_ROOT","ocaml")),
" description = Updating OCaml executables", " description = Updating OCaml executables",
@ -719,6 +724,7 @@ def save_subninja_file(path_module):
"build local: make_local_binaries dummy_target", "", "build local: make_local_binaries dummy_target", "",
"build executables: executables local dummy_target", "", "build executables: executables local dummy_target", "",
"default executables", "", "build clean: make_clean 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") path_ninja_cur = join(path_module.abs, "build.ninja")
@ -745,6 +751,10 @@ def create_build_ninja_global():
" command = module_handler.py clean --all", " command = module_handler.py clean --all",
" description = Cleaning all modules", ""] " description = Cleaning all modules", ""]
l_string += ["rule make_tidy",
" command = module_handler.py tidy --all",
" description = Cleaning all modules", ""]
l_string += ["rule make_ocaml", l_string += ["rule make_ocaml",
" command = make -C {0}/ocaml".format("$QP_ROOT"), " command = make -C {0}/ocaml".format("$QP_ROOT"),
" pool = console", " pool = console",
@ -759,6 +769,8 @@ def create_build_ninja_global():
"default ocaml_target", "default ocaml_target",
"", "",
"build clean: make_clean dummy_target", "build clean: make_clean dummy_target",
"",
"build tidy: make_tidy dummy_target",
"", ] "", ]
path_ninja_cur = join(QP_ROOT, "build.ninja") path_ninja_cur = join(QP_ROOT, "build.ninja")

View File

@ -6,10 +6,13 @@ Module utilitary
Usage: Usage:
module_handler.py print_descendant [<module_name>...] module_handler.py print_descendant [<module_name>...]
module_handler.py clean [ --all | <module_name>...] module_handler.py clean [ --all | <module_name>...]
module_handler.py create_git_ignore [<module_name>...] module_handler.py tidy [ --all | <module_name>...]
Options: Options:
print_descendant Print the genealogy of the needed modules 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. NEED The path of NEED file.
by default try to open the file in the current path by default try to open the file in the current path
""" """
@ -230,7 +233,7 @@ if __name__ == '__main__':
for module in l_module: for module in l_module:
print(" ".join(sorted(m.l_descendant_unique([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_dir = ['IRPF90_temp', 'IRPF90_man']
l_file = ["irpf90_entities", "tags", "irpf90.make", "Makefile", l_file = ["irpf90_entities", "tags", "irpf90.make", "Makefile",
@ -242,25 +245,25 @@ if __name__ == '__main__':
l_symlink = m.l_descendant_unique([module]) l_symlink = m.l_descendant_unique([module])
l_exe = get_binaries(module_abs) 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"]: 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: for f in l_exe:
try: try:
@ -268,6 +271,4 @@ if __name__ == '__main__':
except: except:
pass pass
if arguments["create_git_ignore"]:
pass