Exemplo n.º 1
0
def prepare_makefile(project, config, directory):
    def add_prefix(prefix, value):
        if not value.startswith(prefix):
            return prefix + value
        return value

    import ptp
    if config is None:
        config = create_makefile_config()

    if project.get_build_with_octave():
        config["include"].append(kaira_path(paths.CAOCTAVE_INCLUDE_DIR))
        config["include"].append(ptp.get_config("Octave", "INCFLAGS"))
        config["libdir"].append(ptp.get_config("Octave", "LFLAGS"))
        config["libs"].append(ptp.get_config("Octave", "LIBS"))

    makefile = base.utils.Makefile()
    makefile.set_top_comment("This file is autogenerated.\n"
                             "Do not edit directly this file.")
    makefile.set("KAIRA_PATH", paths.KAIRA_ROOT)
    makefile.set("CXX", ptp.config.get("Main", "CXX"))
    makefile.set("CFLAGS", project.get_build_option("CFLAGS"))

    makefile.set(
        "INCLUDE", "-I{0} -I{1} {2}".format(
            kaira_path(paths.CAILIE_INCLUDE_DIR),
            os.path.relpath(project.root_directory, directory),
            " ".join(add_prefix("-I", s) for s in config["include"])))

    makefile.set(
        "LIBDIR", "-L{0} {1}".format(
            kaira_path(paths.CAILIE_LIB_DIR),
            " ".join(add_prefix("-L", s) for s in config["libdir"])))
    makefile.set(
        "LIBS",
        project.get_build_option("LIBS") + " " +
        " ".join(add_prefix("-l", s)
                 for s in config["libs"]) + " -lcailie -lpthread -lrt ")

    if ptp.config.has_option("Main", "MPICXX"):
        mpicxx = ptp.config.get("Main", "MPICXX")
    else:
        mpicxx = "mpic++"
    makefile.set("MPICXX", mpicxx)

    makefile.set(
        "MPILIBS",
        project.get_build_option("LIBS") + " " +
        " ".join(add_prefix("-l", s)
                 for s in config["libs"]) + " -lcailiempi -lpthread -lrt ")

    makefile.rule(".cpp.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")
    makefile.rule(".cc.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")
    makefile.rule(".c.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")

    return makefile
Exemplo n.º 2
0
def prepare_makefile(project, config, directory):

    def add_prefix(prefix, value):
        if not value.startswith(prefix):
            return prefix + value
        return value

    import ptp
    if config is None:
        config = create_makefile_config()

    if project.get_build_with_octave():
        config["include"].append(kaira_path(paths.CAOCTAVE_INCLUDE_DIR))
        config["include"].append(ptp.get_config("Octave", "INCFLAGS"))
        config["libdir"].append(ptp.get_config("Octave", "LFLAGS"))
        config["libs"].append(ptp.get_config("Octave", "LIBS"))

    makefile = base.utils.Makefile()
    makefile.set_top_comment("This file is autogenerated.\n"
                                "Do not edit directly this file.")
    makefile.set("KAIRA_PATH", paths.KAIRA_ROOT)
    makefile.set("CXX", ptp.config.get("Main", "CXX"))
    makefile.set("CFLAGS", project.get_build_option("CFLAGS"))

    makefile.set("INCLUDE",
                 "-I{0} -I{1} {2}".format(
                     kaira_path(paths.CAILIE_INCLUDE_DIR),
                     os.path.relpath(project.root_directory, directory),
                     " ".join(add_prefix("-I", s) for s in config["include"])))

    makefile.set("LIBDIR",
                 "-L{0} {1}".format(kaira_path(paths.CAILIE_LIB_DIR),
                                    " ".join(add_prefix("-L", s) for s in config["libdir"])))
    makefile.set("LIBS",
                 project.get_build_option("LIBS") + " "
                 + " ".join(add_prefix("-l", s) for s in config["libs"])
                 + " -lcailie -lpthread -lrt -lgomp")

    if ptp.config.has_option("Main", "MPICXX"):
        mpicxx = ptp.config.get("Main", "MPICXX")
    else:
        mpicxx = "mpic++"
    makefile.set("MPICXX", mpicxx)

    makefile.set("MPILIBS",
                 project.get_build_option("LIBS") + " "
                 + " ".join(add_prefix("-l", s) for s in config["libs"])
                 + " -lcailiempi -lpthread -lrt -lgomp ")

    makefile.rule(".cpp.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")
    makefile.rule(".cc.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")
    makefile.rule(".c.o", [], "$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@")

    return makefile
Exemplo n.º 3
0
    def run(self):
        builder = build.Builder(self.project,
            os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
                        "-I", self.project.root_directory ]

        if self.project.get_build_with_octave():
            import ptp # To avoid cyclic import
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR) ]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR) ]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for check in self.checks:
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
Exemplo n.º 4
0
    def check(self):
        if self.library_octave:
            import ptp # Import here to avoid cyclyc import
            if ptp.get_config("Main", "OCTAVE") != "True":
                raise utils.PtpException("Cannot build a module for Octave, "
                                         "Kaira is not build with Octave support.\n"
                                         "Run './waf configure' in Kaira root directory")

        if self.get_build_with_octave():
            import ptp # Import here to avoid cyclyc import
            if ptp.get_config("Main", "OCTAVE") != "True":
                raise utils.PtpException("Cannot build a project with Octave C++ API, "
                                         "Kaira is not build with Octave support.\n"
                                         "Run './waf configure' in Kaira root directory")

        checker = self.target_env.get_checker(self)
        for net in self.nets:
            net.check(checker)
        checker.run()
Exemplo n.º 5
0
 def _open_welcome_tab(self):
     label = gtk.Label()
     line = "<span size='xx-large'>Kaira</span>\nv{0}\n\n" \
             "<a href='http://verif.cs.vsb.cz/kaira'>http://verif.cs.vsb.cz/kaira</a>" \
                 .format(ptp.get_config("Main", "VERSION"))
     label.set_markup(line)
     label.set_justify(gtk.JUSTIFY_CENTER)
     self.window.add_tab(Tab("Welcome",
                             label,
                             has_close_button=False,
                             mainmenu_groups=("welcome",)))
Exemplo n.º 6
0
 def _open_welcome_tab(self):
     label = gtk.Label()
     line = "<span size='xx-large'>Kaira</span>\nv{0}\n\n" \
             "<a href='http://verif.cs.vsb.cz/kaira'>http://verif.cs.vsb.cz/kaira</a>" \
                 .format(ptp.get_config("Main", "VERSION"))
     label.set_markup(line)
     label.set_justify(gtk.JUSTIFY_CENTER)
     self.window.add_tab(Tab("Welcome",
                             label,
                             has_close_button=False,
                             mainmenu_groups=("welcome",)))
Exemplo n.º 7
0
    def run(self):
        builder = build.Builder(self.project,
            os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
                        "-I", self.project.root_directory ]

        if self.project.get_build_with_octave():
            import ptp # To avoid cyclic import
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR) ]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += [ "-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR) ]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for expr, decls, return_type, source, message in self.expressions:
            check = CheckStatement(expr + ";", decls, source=source)
            if message:
                check.own_message = message
            tester.add(check)
            check = CheckStatement("return (" + expr + ");", decls, return_type, source)
            if message:
                check.own_message = message
            else:
                check.own_message = "Invalid type of expression"
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
Exemplo n.º 8
0
    def run(self):
        builder = build.Builder(self.project, os.path.join("/tmp", self.project.get_name() + ".h"))

        build.write_header_file(builder)
        builder.write_to_file()

        tester = base.tester.Tester()
        tester.prepare_writer = self.prepare_writer
        tester.args = [
            "-I",
            os.path.join(paths.KAIRA_ROOT, paths.CAILIE_INCLUDE_DIR),
            "-I",
            self.project.root_directory,
        ]

        if self.project.get_build_with_octave():
            import ptp  # To avoid cyclic import

            tester.args += ["-I", os.path.join(paths.KAIRA_ROOT, paths.CAOCTAVE_INCLUDE_DIR)]
            tester.args += ptp.get_config("Octave", "INCFLAGS").split()

        if self.project.build_target == "simrun":
            tester.args += ["-I", os.path.join(paths.KAIRA_ROOT, paths.CASIMRUN_INCLUDE_DIR)]

        tester.args += self.project.get_build_option("CFLAGS").split()
        tester.run()

        if tester.stderr:
            raise utils.PtpException(tester.stderr)

        for t in self.types.values():
            t.add_checks(tester)

        for check in self.checks:
            tester.add(check)

        check = tester.run()
        if check is not None:
            check.throw_exception()
Exemplo n.º 9
0
import clang.cindex as clang
from ptp import base
import os
import ptp

library_path = "/usr/lib/x86_64-linux-gnu"
temp_file_path = "/tmp/"
temp_file_name = "kairaclangtemp.cpp"

if os.path.exists(temp_file_path):
    if not os.path.isfile(temp_file_path + temp_file_name):
        file(temp_file_path + temp_file_name, "w+", 1)

loaded = False
if not clang.Config.loaded:
    has_clang = ptp.get_config("Main", "LIBCLANG")
    if has_clang == "True":
        path = ptp.get_config("libclang", "path")
        clang.Config.set_library_file(path)
        loaded = True

class ClangParser():

    def __init__(self, completion):
        self.view = completion.view
        self.completion = completion
        self.index = clang.Index.create()
        self.args = ["-I" + self.completion.project.get_directory()]
        self.tu = None
        self.options = (clang.TranslationUnit.PARSE_PRECOMPILED_PREAMBLE |
                       clang.TranslationUnit.PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION |
Exemplo n.º 10
0
import clang.cindex as clang
from ptp import base
import os
import ptp

temp_file_path = "/tmp/"
temp_file_name = "kairaclangtemp-{0}.cpp".format(os.getuid())

if os.path.exists(temp_file_path):
    if not os.path.isfile(temp_file_path + temp_file_name):
        file(temp_file_path + temp_file_name, "w+", 1)

loaded = False
if not clang.Config.loaded:
    has_clang = ptp.get_config("Main", "LIBCLANG")
    if has_clang == "True":
        path = ptp.get_config("libclang", "path")
        clang.Config.set_library_file(path)
        loaded = True


class ClangParser():
    def __init__(self, completion):
        self.view = completion.view
        self.completion = completion
        self.index = clang.Index.create()
        self.args = ["-I" + self.completion.project.get_directory()]
        self.tu = None
        self.options = (clang.TranslationUnit.PARSE_PRECOMPILED_PREAMBLE
                        | clang.TranslationUnit.