aboutsummaryrefslogtreecommitdiff
path: root/scons-tools/llvm.py
blob: 2e03caa3522e41f111b87175bb4e562e262f3983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from SCons.Scanner.Prog import scan
from SCons.Builder import Builder

def exists(env):
    return True

def add_libraries(target, source, env):
    unique = []
    lib_nodes = set()
    for x in scan(None, env, tuple(map(env.Dir, env['LIBPATH']))):
        if x in lib_nodes:
            continue
        lib_nodes.add(x)
        unique.append(x)
    return (target, source + unique)

def generate(env):
    env['BUILDERS']['LLVMDis'] = Builder(
        action='${LLVM_ROOT}/llvm-dis -o=$TARGET $SOURCE')

    env['BUILDERS']['LLVMOpt'] = Builder(
        action='${LLVM_ROOT}/opt $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE')

    env['BUILDERS']['LLVMLink'] = Builder(
        action='${LLVM_ROOT}/llvm-link -o=$TARGET $SOURCES',
        emitter=add_libraries)