コード例 #1
0
ファイル: conf.py プロジェクト: dagss/Bento
def _create_compile_conf_taskgen(conf, name, body, headers,
        extension=".c"):
    if headers:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, extension)]

    task_gen = CompiledTaskGen("conf", conf, sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    apply_cpppath(task_gen)

    tasks = task_gen.process()
    conf.last_task = tasks[-1]

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        run_tasks(conf, tasks)
        succeed = True
    except TaskRunFailure, e:
        explanation = unicode(e).encode("utf-8")
コード例 #2
0
ファイル: __init__.py プロジェクト: B-Rich/Bento
def try_task_maker(conf, task_maker, name, body, headers, env=None):
    if headers:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, ".c")]

    task_gen = CompiledTaskGen("conf", conf, sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    task_gen.env = _merge_env(task_gen.env, env)
    task_gen.env.prepend("LIBDIR", conf.path.declare(".").abspath())

    tasks = task_maker(task_gen, name)
    conf.last_task = tasks[-1]

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        try:
            run_tasks(conf, tasks)
            succeed = True
        except TaskRunFailure:
            e = get_exception()
            explanation = str(e)
            #raise
    finally:
        write_log(conf, conf.log, tasks, code, succeed, explanation)
    return succeed
コード例 #3
0
ファイル: pyext.py プロジェクト: bluemoon/yaku
def create_pyext(bld, env, name, sources):
    base = name.replace(".", os.sep)

    tasks = []

    task_gen = CompiledTaskGen("pyext", sources, name)
    old_hook = set_extension_hook(".c", pycc_hook)

    task_gen.env = env
    apply_cpppath(task_gen)
    apply_libpath(task_gen)
    apply_libs(task_gen)

    tasks = create_tasks(task_gen, sources)

    ltask = pylink_task(task_gen, base)
    tasks.extend(ltask)
    for t in tasks:
        t.env = task_gen.env

    set_extension_hook(".c", old_hook)
    bld.tasks.extend(tasks)

    outputs = []
    for t in ltask:
        outputs.extend(t.outputs)
    return outputs
コード例 #4
0
ファイル: conf.py プロジェクト: dagss/Bento
def _create_binary_conf_taskgen(conf, name, body, builder, headers=None,
        extension=".c"):
    if headers is not None:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, extension)]

    task_gen = CompiledTaskGen("conf", conf, sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    task_gen.env["INCPATH"] = ""
    apply_libs(task_gen)
    apply_libdir(task_gen)

    tasks = task_gen.process()
    tasks.extend(builder(task_gen, name))

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        run_tasks(conf, tasks)
        succeed = True
    except TaskRunFailure, e:
        msg = str(e)
        explanation = unicode(msg).encode("utf-8")
コード例 #5
0
ファイル: conf.py プロジェクト: bluemoon/yaku
def create_compile_conf_taskgen(conf, name, body, headers,
        msg, extension=".c"):
    if headers:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, extension)]

    task_gen = CompiledTaskGen("conf", sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    task_gen.env["INCPATH"] = ""

    tasks = create_tasks(task_gen, sources)
    for t in tasks:
        t.disable_output = True
    sys.stderr.write(msg + "... ")

    succeed = False
    explanation = None
    try:
        run_tasks(conf, tasks)
        succeed = True
        sys.stderr.write("yes\n")
    except TaskRunFailure, e:
        sys.stderr.write("no\n")
        explanation = str(e)
コード例 #6
0
def try_task_maker(conf, task_maker, name, body, headers, env=None):
    if headers:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, ".c")]

    task_gen = CompiledTaskGen("conf", conf, sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    task_gen.env = _merge_env(task_gen.env, env)
    task_gen.env.prepend("LIBDIR", conf.path.declare(".").abspath())

    tasks = task_maker(task_gen, name)
    conf.last_task = tasks[-1]

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        try:
            run_tasks(conf, tasks)
            succeed = True
        except TaskRunFailure:
            e = get_exception()
            explanation = str(e)
            #raise
    finally:
        write_log(conf, conf.log, tasks, code, succeed, explanation)
    return succeed
コード例 #7
0
ファイル: __init__.py プロジェクト: dagss/yaku
def try_task_maker(conf, task_maker, name, body, headers, env=None):
    if headers:
        head = "\n".join(["#include <%s>" % h for h in headers])
    else:
        head = ""
    code = "\n".join([c for c in [head, body]])
    sources = [create_file(conf, code, name, ".c")]

    task_gen = CompiledTaskGen("conf", conf, sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))
    task_gen.env = _merge_env(task_gen.env, env)
    task_gen.env.prepend("LIBDIR", os.curdir)

    tasks = task_maker(task_gen, name)
    conf.last_task = tasks[-1]

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        run_tasks(conf, tasks)
        succeed = True
    except TaskRunFailure, e:
        explanation = str(e)
コード例 #8
0
ファイル: fconftests.py プロジェクト: dagss/Bento
def _create_fbinary_conf_taskgen(conf, name, body, builder):
    # FIXME: refactor commonalities between configuration taskgens
    code = body
    sources = [create_file(conf, code, name, ".f")]

    task_gen = CompiledTaskGen("conf", conf,
                               sources, name)
    task_gen.env.update(copy.deepcopy(conf.env))

    tasks = task_gen.process()
    link_task = builder(task_gen, name)

    t = link_task[0]
    exec_command = t.exec_command
    if sys.version_info >= (3,):
        t.exec_command = types.MethodType(logged_exec, t)
    else:
        t.exec_command = types.MethodType(logged_exec, t, t.__class__)
    tasks.extend(link_task)
    conf.last_task = tasks[-1]

    for t in tasks:
        t.disable_output = True
        t.log = conf.log

    succeed = False
    explanation = None
    try:
        run_tasks(conf, tasks)
        succeed = True
    except TaskRunFailure, e:
        explanation = str(e)
コード例 #9
0
ファイル: ctasks.py プロジェクト: B-Rich/Bento
    def static_library(self, name, sources, env=None):
        sources = self.to_nodes(sources)
        task_gen = CompiledTaskGen("ccstaticlib", self.ctx, sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)

        tasks = self._static_library(task_gen, name)
        self.ctx.tasks.extend(tasks)
        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        return outputs
コード例 #10
0
ファイル: ctasks.py プロジェクト: dagss/yaku
    def shared_library(self, name, sources, env=None):
        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("ccsharedlib", self.ctx, sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)

        tasks = self._shared_library(task_gen, name)
        self.ctx.tasks.extend(tasks)
        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        return outputs
コード例 #11
0
    def program(self, name, sources, env=None):
        sources = self.to_nodes(sources)
        task_gen = CompiledTaskGen("ccprogram", self.ctx, sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)
        tasks = self._program(task_gen, name)

        self.ctx.tasks.extend(tasks)
        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        return outputs
コード例 #12
0
ファイル: ctasks.py プロジェクト: dagss/yaku
    def compile(self, name, sources, env=None):
        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("cccompile", self.ctx, sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)
        tasks = self._compile(task_gen, name)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #13
0
ファイル: ctasks.py プロジェクト: B-Rich/Bento
    def compile(self, name, sources, env=None):
        sources = self.to_nodes(sources)
        task_gen = CompiledTaskGen("cccompile", self.ctx, sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)
        tasks = self._compile(task_gen, name)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #14
0
ファイル: pyext.py プロジェクト: Web5design/Bento
    def extension(self, name, sources, env=None):
        sources = self.to_nodes(sources)
        task_gen = CompiledTaskGen("pyext", self.ctx, sources, name)
        task_gen.bld = self.ctx
        task_gen.env = yaku.tools._merge_env(self.env, env)
        tasks = self._extension(task_gen, name)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        task_gen.outputs = outputs
        return tasks
コード例 #15
0
    def extension(self, name, sources, env=None):
        sources = self.to_nodes(sources)
        task_gen = CompiledTaskGen("pyext", self.ctx, sources, name)
        task_gen.bld = self.ctx
        task_gen.env = yaku.tools._merge_env(self.env, env)
        tasks = self._extension(task_gen, name)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        task_gen.outputs = outputs
        return tasks
コード例 #16
0
    def compile(self, name, sources, env=None):
        _env = copy.deepcopy(self.env)
        if env is not None:
            _env.update(env)

        task_gen = CompiledTaskGen("fcompile", self.ctx, sources, name)
        task_gen.env = _env
        tasks = self._compile(name, sources)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #17
0
ファイル: ctasks.py プロジェクト: dagss/Bento
    def ccompile(self, name, sources, env=None):
        task_gen = CompiledTaskGen("cccompile", self.ctx,
                                   sources, name)
        task_gen.env = _merge_env(self.env, env)
        apply_cpppath(task_gen)

        tasks = task_gen.process()
        for t in tasks:
            t.env = task_gen.env
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #18
0
ファイル: fortran.py プロジェクト: dagss/yaku
    def compile(self, name, sources, env=None):
        _env = copy.deepcopy(self.env)
        if env is not None:
            _env.update(env)

        task_gen = CompiledTaskGen("fcompile", self.ctx,
                                   sources, name)
        task_gen.env = _env
        tasks = self._compile(name, sources)
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #19
0
    def ccompile(self, name, sources, env=None):
        task_gen = CompiledTaskGen("cxccompile", self.ctx,
                                   sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)
        apply_define(task_gen)
        apply_cpppath(task_gen)

        tasks = task_gen.process()
        for t in tasks:
            t.env = task_gen.env
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #20
0
    def _try_task_maker(self, task_maker, name, body):
        conf = self.ctx
        code = body
        sources = [create_file(conf, code, name, ".f")]

        task_gen = CompiledTaskGen("conf", conf, sources, name)
        task_gen.env.update(copy.deepcopy(conf.env))

        tasks = task_maker(task_gen, name)
        self.ctx.last_task = tasks[-1]

        for t in tasks:
            t.disable_output = True
            t.log = conf.log

        succeed = False
        explanation = None
        try:
            run_tasks(conf, tasks)
            succeed = True
        except TaskRunFailure:
            e = get_exception()
            explanation = str(e)

        write_log(conf, conf.log, tasks, code, succeed, explanation)
        return succeed
コード例 #21
0
    def program(self, name, sources, env=None):
        _env = copy.deepcopy(self.env)
        if env is not None:
            _env.update(env)

        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("fprogram", self.ctx, sources, name)
        task_gen.env = _env
        tasks = self._program(task_gen, name)

        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        return outputs
コード例 #22
0
ファイル: fortran.py プロジェクト: dagss/yaku
    def program(self, name, sources, env=None):
        _env = copy.deepcopy(self.env)
        if env is not None:
            _env.update(env)

        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("fprogram", self.ctx,
                                   sources, name)
        task_gen.env = _env
        tasks = self._program(task_gen, name)

        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in task_gen.link_task:
            outputs.extend(t.outputs)
        return outputs
コード例 #23
0
ファイル: fortran.py プロジェクト: dagss/Bento
    def ccompile(self, name, sources, env=None):
        _env = copy.deepcopy(self.env)
        if env is not None:
            _env.update(env)

        task_gen = CompiledTaskGen("cccompile", self.ctx,
                                   sources, name)
        task_gen.env = _env
        apply_cpppath(task_gen)

        tasks = task_gen.process()
        for t in tasks:
            t.env = task_gen.env
        self.ctx.tasks.extend(tasks)

        outputs = []
        for t in tasks:
            outputs.extend(t.outputs)
        return outputs
コード例 #24
0
ファイル: ctasks.py プロジェクト: dagss/Bento
    def static_library(self, name, sources, env=None):
        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("ccstaticlib", self.ctx, sources, name)
        task_gen.env = _merge_env(self.env, env)
        apply_cpppath(task_gen)
        apply_libdir(task_gen)
        apply_libs(task_gen)

        tasks = task_gen.process()
        ltask = static_link_task(task_gen, name)
        tasks.extend(ltask)
        for t in tasks:
            t.env = task_gen.env
        self.ctx.tasks.extend(tasks)
        self.link_task = ltask

        outputs = []
        for t in ltask:
            outputs.extend(t.outputs)
        return outputs
コード例 #25
0
    def program(self, name, sources, env=None):
        sources = [self.ctx.src_root.find_resource(s) for s in sources]
        task_gen = CompiledTaskGen("cxxprogram", self.ctx,
                                   sources, name)
        task_gen.env = yaku.tools._merge_env(self.env, env)
        apply_define(task_gen)
        apply_cpppath(task_gen)
        apply_libdir(task_gen)
        apply_libs(task_gen)

        tasks = task_gen.process()
        ltask = cxxprogram_task(task_gen, name)
        tasks.extend(ltask)
        for t in tasks:
            t.env = task_gen.env
        self.ctx.tasks.extend(tasks)
        self.link_task = ltask

        outputs = []
        for t in ltask:
            outputs.extend(t.outputs)
        return outputs
コード例 #26
0
ファイル: pyext.py プロジェクト: dagss/Bento
def create_pyext(bld, name, sources, env):
    base = name.replace(".", os.sep)

    tasks = []

    task_gen = CompiledTaskGen("pyext", bld, sources, name)
    task_gen.bld = bld
    old_hook = set_extension_hook(".c", pycc_hook)
    old_hook_cxx = set_extension_hook(".cxx", pycxx_hook)

    task_gen.env = env
    apply_cpppath(task_gen)
    apply_libpath(task_gen)
    apply_libs(task_gen)
    apply_frameworks(task_gen)

    tasks = task_gen.process()

    ltask = pylink_task(task_gen, base)
    if task_gen.has_cxx:
        task_gen.link_task.func = pycxxlink
        task_gen.link_task.env_vars = pycxxlink_vars

    tasks.extend(ltask)
    for t in tasks:
        t.env = task_gen.env

    set_extension_hook(".c", old_hook)
    set_extension_hook(".cxx", old_hook_cxx)
    bld.tasks.extend(tasks)

    outputs = []
    for t in ltask:
        outputs.extend(t.outputs)
    task_gen.outputs = outputs
    return tasks