Esempio n. 1
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
Esempio n. 2
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
    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
Esempio n. 4
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
Esempio n. 5
0
    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)

    write_log(conf, conf.log, tasks, code, succeed, explanation)
    return succeed


def _merge_env(_env, new_env):
    if new_env is not None:
        ret = copy.copy(_env)
        for k, v in new_env.items():
            if hasattr(_env[k], "extend"):
                old = copy.copy(_env[k])
                old.extend(v)
                ret[k] = old
            else:
                ret[k] = v
        return ret
    else: