Exemple #1
0
 def try_extension(self, name, body, headers=None):
     old_hook = set_extension_hook(".c", pycc_task)
     try:
         return with_conf_blddir(self.ctx, name, body,
                                 lambda : yaku.tools.try_task_maker(self.ctx, self._extension, name, body, headers))
     finally:
         set_extension_hook(".c", old_hook)
Exemple #2
0
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
Exemple #3
0
 def try_compile(self, name, body, headers=None):
     old_hook = set_extension_hook(".c", pycc_task)
     try:
         return with_conf_blddir(
             self.ctx, name, body, lambda: yaku.tools.try_task_maker(
                 self.ctx, self._compile, name, body, headers))
     finally:
         set_extension_hook(".c", old_hook)
Exemple #4
0
def build(ctx):
    program = ctx.builders["ctasks"].program
    c_hook = wrap_extension_hook(".c", custom_c_hooker)
    try:
        program("main1", sources=["src/main.c"])
    finally:
        set_extension_hook(".c", c_hook)
    program("main2", sources=["src/main2.c"])
Exemple #5
0
def build(ctx):
    pyext = ctx.builders["pyext"]

    old_hook = get_extension_hook(".in")
    def foo(self, node):
        recursive_suffixes = [".c", ".cxx", ".pyx"]
        out = node.change_ext("")
        # XXX: is it really safe to items to a list one recurses on ?
        if out.suffix() in recursive_suffixes:
            self.sources.append(out)
        return old_hook(self, node)
    set_extension_hook(".in", foo)

    pyext.extension("hello", ["hello.pyx.in"])
Exemple #6
0
def build(ctx):
    pyext = ctx.builders["pyext"]

    old_hook = get_extension_hook(".in")
    def foo(self, node):
        recursive_suffixes = [".c", ".cxx", ".pyx"]
        out = node.change_ext("")
        # XXX: is it really safe to items to a list one recurses on ?
        if out.suffix() in recursive_suffixes:
            self.sources.append(out)
        return old_hook(self, node)
    set_extension_hook(".in", foo)

    pyext.extension("hello", ["hello.pyx.in"])
    def _shared_library(self, task_gen, name):
        old_hook = set_extension_hook(".c", shared_c_hook)

        apply_define(task_gen)
        apply_cpppath(task_gen)
        apply_libdir(task_gen)
        apply_libs(task_gen)

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

        set_extension_hook(".c", old_hook)
        return tasks
Exemple #8
0
    def _shared_library(self, task_gen, name):
        old_hook = set_extension_hook(".c", shared_c_hook)

        apply_define(task_gen)
        apply_cpppath(task_gen)
        apply_libdir(task_gen)
        apply_libs(task_gen)

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

        set_extension_hook(".c", old_hook)
        return tasks
Exemple #9
0
    def _extension(self, task_gen, name):
        bld = self.ctx
        base = name.replace(".", os.sep)

        tasks = []

        old_hook = set_extension_hook(".c", pycc_hook)
        old_hook_cxx = set_extension_hook(".cxx", pycxx_hook)

        apply_define(task_gen)
        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)
        task_gen.link_task = ltask
        if task_gen.has_cxx:
            task_gen.link_task[-1].func = pycxxlink
            task_gen.link_task[-1].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)
        return tasks
Exemple #10
0
    def _extension(self, task_gen, name):
        bld = self.ctx
        base = name.replace(".", os.sep)

        tasks = []

        old_hook = set_extension_hook(".c", pycc_hook)
        old_hook_cxx = set_extension_hook(".cxx", pycxx_hook)

        apply_define(task_gen)
        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)
        task_gen.link_task = ltask
        if task_gen.has_cxx:
            task_gen.link_task[-1].func = pycxxlink
            task_gen.link_task[-1].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)
        return tasks
Exemple #11
0
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