diff --git a/scripts/compilation/qp_create_ninja b/scripts/compilation/qp_create_ninja index 1d7462b8..c63f5a97 100755 --- a/scripts/compilation/qp_create_ninja +++ b/scripts/compilation/qp_create_ninja @@ -27,6 +27,9 @@ except ImportError: print "\n".join(["", "Error:", "source %s" % f, ""]) sys.exit(1) +# Compress path +def comp_path(path): + return path.replace(QP_ROOT,"$QP_ROOT") # __ # /__ | _ |_ _. | _. ._ o _. |_ | _ _ @@ -36,10 +39,10 @@ except ImportError: from qp_path import QP_ROOT, QP_SRC, QP_EZFIO LIB = "" # join(QP_ROOT, "lib", "rdtsc.o") -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") - +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") header = r"""# # _______ _____ # __ __ \___ _______ _________ /____ ________ ___ @@ -61,6 +64,10 @@ header = r"""# # """.format(__file__).replace(QP_ROOT,"$QP_ROOT") +header += """ +QP_ROOT = {0} + +""".format(QP_ROOT) # # |\ | _. ._ _ _ _| _|_ ._ | _ @@ -231,10 +238,10 @@ def ninja_ezfio_cfg_build(l_util): for m in l_util.itervalues(): str_ = "build {1} {2}: build_ezfio_interface {0}" - l_string += [str_.format(m.ez_cfg.abs, m.ez_interface.abs, - m.ez_config.abs)] + l_string += [str_.format(*map(comp_path,(m.ez_cfg.abs, m.ez_interface.abs, + m.ez_config.abs)))] - l_string += [" sub_module = {0}".format(m.ez_module.abs)] + l_string += [" sub_module = {0}".format(comp_path(m.ez_module.abs))] l_string += [""] return l_string @@ -250,8 +257,8 @@ def ninja_ezfio_config_build(l_ezfio_config): file_source = m.path_in_module file_create = m.path_in_ezfio - l_string += ["build {0}: build_ezfio_config {1}".format(file_create, - file_source)] + l_string += ["build {0}: build_ezfio_config {1}".format(*map(comp_path,(file_create, + file_source)))] l_string += [""] return l_string @@ -266,8 +273,8 @@ def ninja_ezfio_rule(): l_flag = ["export {0}='${0}'".format(flag) for flag in ["FC", "FCFLAGS", "IRPF90"]] - install_lib_ezfio = join(QP_EZFIO, "lib", "libezfio_irp.a") - l_cmd = ["cd {0}".format(QP_EZFIO)] + l_flag + install_lib_ezfio = comp_path(join(QP_EZFIO, "lib", "libezfio_irp.a")) + l_cmd = ["cd {0}".format(comp_path(QP_EZFIO))] + l_flag l_cmd += ["rm -f make.config ; ninja && rm -f {1} ; ln -sf {0} {1}".format(install_lib_ezfio, EZFIO_LIB)] l_string = ["rule build_ezfio", @@ -286,7 +293,7 @@ def ninja_ezfio_build(l_ezfio_config, l_util): l_ezfio_config = [i.path_in_ezfio for i in l_ezfio_config] l_ezfio_from_cfg = [i.ez_config.abs for i in l_util.itervalues()] - str_ = " ".join(l_ezfio_config + l_ezfio_from_cfg) + str_ = " ".join(map(comp_path,(l_ezfio_config + l_ezfio_from_cfg))) l_string = ["build {0}: build_ezfio {1}".format(EZFIO_LIB, str_), ""] return l_string @@ -324,12 +331,11 @@ def ninja_symlink_build(path_module, l_symlink): l_folder = [s.destination for s in l_symlink] l_string = ["build l_symlink_{0} : phony {1}".format(path_module.rel, - " ".join(l_folder)), + " ".join(map(comp_path,l_folder))), ""] for symlink in l_symlink: - l_string += ["build {0}: build_symlink {1}".format(symlink.destination, - symlink.source), ""] + l_string += ["build {0}: build_symlink {1}".format(*map(comp_path,(symlink.destination, symlink.source))), ""] return l_string @@ -352,9 +358,9 @@ def ninja_gitignore_build(path_module, d_binaries, l_symlink): """ """ - path_gitignore = join(path_module.abs, ".gitignore") + path_gitignore = comp_path(join(path_module.abs, ".gitignore")) - l_b = [i.abs for i in d_binaries[path_module]] + l_b = map(comp_path,[i.abs for i in d_binaries[path_module]]) root = "build {0}: build_gitignore {1}".format(path_gitignore, " ".join(l_b)) @@ -483,16 +489,16 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): l_creation = [join(path_module.abs, i) for i in ["irpf90_entities", "tags", "IRPF90_temp/build.ninja"]] - str_creation = " ".join(l_creation) + str_creation = " ".join(map(comp_path,l_creation)) # ~#~#~#~#~#~#~#~#~#~ # # D e p e n d a n c y # # ~#~#~#~#~#~#~#~#~#~ # - l_depend = d_irp[path_module]["l_depend"] - l_src = d_irp[path_module]["l_src"] - l_obj = d_irp[path_module]["l_obj"] - l_template = d_irp[path_module]["l_template"] + l_depend = map(comp_path,d_irp[path_module]["l_depend"]) + l_src = map(comp_path,d_irp[path_module]["l_src"]) + l_obj = map(comp_path,d_irp[path_module]["l_obj"]) + l_template = map(comp_path,d_irp[path_module]["l_template"]) if l_needed_molule: l_symlink = ["l_symlink_{0}".format(path_module.rel)] @@ -509,8 +515,8 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): l_string = [ "build {0}: build_irpf90.ninja {1}".format(str_creation, str_depend), - " module_abs = {0}".format(path_module.abs), - " module_rel = {0}".format(path_module.rel), + " module_abs = {0}".format(comp_path(path_module.abs)), + " module_rel = {0}".format(comp_path(path_module.rel)), " SRC = {0}".format(" ".join(l_src)), " OBJ = {0}".format(" ".join(l_obj)), " include_dir = {0}".format(" ".join(l_include_dir)), "" @@ -634,8 +640,8 @@ def ninja_binaries_build(path_module, l_children, d_binaries): # c m d # # ~#~#~ # - ninja_module_path = join(path_module.abs, "IRPF90_temp/build.ninja") - l_abs_bin = [binary.abs for binary in d_binaries[path_module]] + ninja_module_path = join(comp_path(path_module.abs), "IRPF90_temp/build.ninja") + l_abs_bin = map(comp_path,[binary.abs for binary in d_binaries[path_module]]) # ~#~#~#~#~#~ # # s t r i n g # @@ -644,7 +650,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): l_string = ["build {0}: build_binaries {1} {2}".format(" ".join(l_abs_bin), EZFIO_LIB, ninja_module_path), - " module_abs = {0}".format(path_module.abs), + " module_abs = {0}".format(comp_path(path_module.abs)), " module_rel = {0}".format(path_module.rel), ""] return l_string @@ -652,9 +658,9 @@ def ninja_binaries_build(path_module, l_children, d_binaries): def ninja_module_build(path_module, d_binaries): - l_abs_bin = [binary.abs for binary in d_binaries[path_module]] + l_abs_bin = map(comp_path,[binary.abs for binary in d_binaries[path_module]]) - path_readme = os.path.join(path_module.abs, "README.rst") + path_readme = os.path.join(comp_path(path_module.abs), "README.rst") l_string = ["build module_{0}: phony {1}".format(path_module.rel, " ".join(l_abs_bin)) ] @@ -692,7 +698,7 @@ def save_subninja_file(path_module): ""] 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", ""] @@ -704,7 +710,7 @@ def save_subninja_file(path_module): ""] path_ninja_cur = join(path_module.abs, "build.ninja") - + with open(path_ninja_cur, "w") as f: f.write(header) f.write("\n".join(l_string)) @@ -728,7 +734,7 @@ def create_build_ninja_global(): " description = Cleaning all modules", ""] l_string += ["rule make_ocaml", - " command = make -C {0}/ocaml".format(QP_ROOT), + " command = make -C {0}/ocaml".format("$QP_ROOT"), " pool = console", " description = Compiling OCaml tools", ""] @@ -892,6 +898,6 @@ if __name__ == "__main__": # S a v e s # # ~#~#~#~#~ # - with open(ROOT_BUILD_NINJA, "w+") as f: + with open(ROOT_BUILD_NINJA_EXP, "w+") as f: f.write(header) f.write("\n".join(l_string))