From dff2d2f8fac9a0a13b8e73ec3408dfab3ac9734d Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 26 May 2015 16:08:52 +0200 Subject: [PATCH] Fix for travis (add Read_compilation) --- .travis.yml | 1 + ocaml/Makefile | 8 ++++- scripts/compilation/compilation.cfg | 20 +++++++++++ scripts/compilation/create_ninja_build.py | 27 +++++++++----- scripts/compilation/read_compilation_cfg.py | 39 +++++++++++++++++++++ 5 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 scripts/compilation/compilation.cfg create mode 100755 scripts/compilation/read_compilation_cfg.py diff --git a/.travis.yml b/.travis.yml index d020685c..6514df22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,5 @@ script: - cp ./src/Makefile.config.gfortran ./src/Makefile.config - ./scripts/compilation/create_ninja_build.py > build.ninja - ./ninja/ninja + - cd ocaml ; make ; - ./tests/unit_test/unit_test.py diff --git a/ocaml/Makefile b/ocaml/Makefile index 0d2ee017..ce932bfc 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -35,7 +35,7 @@ default: $(ALL_TESTS) $(ALL_EXE) .gitignore executables: $(QPACKAGE_ROOT)/data/executables $(QPACKAGE_ROOT)/data/executables: - $(QPACKAGE_ROOT)/scripts/module/create_executables_list.sh + $(QPACKAGE_ROOT)/scripts/create/create_executables_list.sh external_libs: opam install cryptokit core @@ -62,11 +62,17 @@ qp_run.native: $(MLFILES) $(MLIFILES) executables $(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS) ln -s $*.native $* +ezfio.ml: ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml + cp ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml . + qptypes_generator.byte: qptypes_generator.ml $(OCAMLBUILD) qptypes_generator.byte -use-ocamlfind Qptypes.ml: qptypes_generator.byte ./qptypes_generator.byte > Qptypes.ml +${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml: + $(MAKE) -C ${QPACKAGE_ROOT}/src ezfio + clean: rm -rf _build Qptypes.ml $(ALL_EXE) $(ALL_TESTS) diff --git a/scripts/compilation/compilation.cfg b/scripts/compilation/compilation.cfg new file mode 100644 index 00000000..2b727078 --- /dev/null +++ b/scripts/compilation/compilation.cfg @@ -0,0 +1,20 @@ +[OPTION] +OPENMP: 1 +PROFILE: 0 +DEBUG: 0 + +[COMMON] +FC: gfortran -ffree-line-length-none -march=native +FCFLAGS: -ffast-math -Ofast +MKL: -lblas -llapack + +[OPENMP] +FC: -fopenmp +IRPF90_FLAGS: --openmp + +[PROFILE] +FC: -p -g +CXX: -pg + +[DEBUG] +FCFLAGS: -fcheck=all \ No newline at end of file diff --git a/scripts/compilation/create_ninja_build.py b/scripts/compilation/create_ninja_build.py index 409474b4..c8089ae9 100755 --- a/scripts/compilation/create_ninja_build.py +++ b/scripts/compilation/create_ninja_build.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import os +import sys from os.path import join @@ -22,8 +23,10 @@ EZ_handler = namedtuple('EZ_handler', ['ez_module', 'ez_cfg', 'ez_interface', 'e try: from module_handler import module_genealogy from cache import cache + from read_compilation_cfg import get_compilation_option except ImportError: print "source .quantum_package.rc" + sys.exit(1) # _ @@ -214,8 +217,14 @@ def ninja_ezfio_config_build(l_ezfio_config): def ninja_ezfio_rule(): # Rule l_string = ["rule build_ezfio"] - l_string += [" command = cd {0}; make ; cd -".format(qpackage_root_ezfio)] - l_string += [" description = Make ezfio"] + + l_flag = [] + for flag in ["FC", "FCFLAGS", "IRPF90"]: + str_ = "export {0}='{1}'".format(flag, get_compilation_option(flag)) + l_flag.append(str_) + + l_cmd = ["cd {0}".format(qpackage_root_ezfio)] + l_flag + ["make", "make Python"] + l_string += [" command = {0}".format(" ; ".join(l_cmd))] return l_string @@ -408,7 +417,7 @@ def get_ml_file(l_util, l_qp): def ninja_ocaml_rule(): # Rule - cmd = " command = cd {0} ; make -j 1 $binary ; touch $binary; cd -" + cmd = " command = cd {0} ; make -j 1 $native ; touch $native; ln -sf $native $binary; cd -" l_string = ["rule build_ocaml"] l_string += [cmd.format(qpackage_root_ocaml)] @@ -456,15 +465,16 @@ def ninja_ocaml_build(l_bin_ml, l_ml): # Rule ezfio_ml = join(qpackage_root_ocaml, "ezfio.ml") - exc = join(qpackage_root, "data", "executables") +# exc = join(qpackage_root, "data", "executables") - str_depend = " ".join(l_ml + l_bin_ml + [ezfio_ml, exc]) + str_depend = " ".join(l_ml + l_bin_ml + [ezfio_ml]) l_string = [""] for bin_ in [i.replace(".ml", ".native") for i in l_bin_ml]: binary_name = os.path.split(bin_)[1] l_string += ["build {0}: build_ocaml {1} ".format(bin_, str_depend)] - l_string += [" binary = {0}".format(binary_name)] + l_string += [" native = {0}".format(binary_name)] + l_string += [" binary = {0}".format(binary_name.replace(".native", ""))] l_string += [""] return l_string @@ -578,8 +588,8 @@ if __name__ == "__main__": l_qp = get_qp_file() l_ml = get_ml_file(l_util, l_qp) - l_string += ninja_ml_build(l_util) - l_string += ninja_ocaml_build(l_qp, l_ml) +# l_string += ninja_ml_build(l_util) +# l_string += ninja_ocaml_build(l_qp, l_ml) # _ _ # |_) o | _| _|_ _ ._ ._ _ _ _| | _ @@ -588,6 +598,7 @@ if __name__ == "__main__": # with open(join(qpackage_root_src, "NEEDED_MODULES"), "r") as f: l_module_to_compile = f.read().split() + l_module_to_compile = ["Hartree_Fock"] d_info_module = dict_needed_modules(l_module_to_compile) diff --git a/scripts/compilation/read_compilation_cfg.py b/scripts/compilation/read_compilation_cfg.py new file mode 100755 index 00000000..e7ea1264 --- /dev/null +++ b/scripts/compilation/read_compilation_cfg.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import ConfigParser +import sys +from cache import cache + +qpackage_root = os.environ['QPACKAGE_ROOT'] + +Config = ConfigParser.ConfigParser() +pwd = os.path.join(qpackage_root, "scripts/compilation/compilation.cfg") +Config.read(pwd) + + +@cache +def get_l_option_section(): + return [o for o in ['OPENMP', 'PROFILE', 'DEBUG'] if Config.getboolean("OPTION", o)] + + +@cache +def get_compilation_option(name): + + l_option_section = get_l_option_section() + + l = [] + for section in ["COMMON"] + l_option_section: + try: + l.extend(Config.get(section, name).split()) + except ConfigParser.NoOptionError: + pass + + return " ".join(l) + +if __name__ == '__main__': + + name = sys.argv[1] + + print get_compilation_option(name)