forked from llvmpy/llvmpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm-config-win32.py
96 lines (94 loc) · 2.62 KB
/
llvm-config-win32.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import sys, os
def find_path_of(filename, envvar='PATH'):
"""Finds the path from $PATH where the file exists, returns None if not found."""
pathlist = os.getenv(envvar).split(os.pathsep)
for path in pathlist:
if os.path.exists(os.path.join(path, filename)):
return os.path.abspath(path)
return None
if sys.argv[1] == '--version':
cmd = 'llvm-tblgen --version'
# Hardcoded extraction, only tested on llvm 3.1
#result = os.popen(cmd).read().split('\n')[1].strip().split(' ')[2]
result = "99999.9999"
print result
elif sys.argv[1] == '--ldflags':
for winlib in """
imagehlp
psapi
""".split():
print('-l%s' % winlib)
# static link mingw dll content to avoid distribution
for winopt in """
-static-libgcc
-static-libstdc++
""".split():
print('%s' % winopt)
# static link mingw dll content to avoid distribution
elif sys.argv[1] == '--libs':
# NOTE: instead of actually looking at the components requested,
# we just spit out a bunch of libs
for lib in """
LLVMNVPTXCodeGen
LLVMNVPTXDesc
LLVMNVPTXInfo
LLVMNVPTXAsmPrinter
LLVMLinker
LLVMArchive
LLVMAsmParser
LLVMipo
LLVMVectorize
LLVMInstrumentation
LLVMBitWriter
LLVMBitReader
LLVMInterpreter
LLVMX86Disassembler
LLVMX86CodeGen
LLVMSelectionDAG
LLVMAsmPrinter
LLVMX86AsmParser
LLVMMCParser
LLVMX86Desc
LLVMX86AsmPrinter
LLVMX86Utils
LLVMX86Info
LLVMJIT
LLVMRuntimeDyld
LLVMCodeGen
LLVMExecutionEngine
LLVMScalarOpts
LLVMInstCombine
LLVMTransformUtils
LLVMipa
LLVMAnalysis
LLVMTarget
LLVMMC
LLVMObject
LLVMCore
LLVMSupport
""".split():
print('-l%s' % lib)
llvmbin = find_path_of('llvm-tblgen.exe')
if os.path.exists(os.path.join(llvmbin, '../lib/LLVMPTXCodeGen.lib')):
print('-lLLVMPTXAsmPrinter')
print('-lLLVMPTXCodeGen')
print('-lLLVMPTXDesc')
print('-lLLVMPTXInfo')
elif sys.argv[1] == '--includedir':
llvmbin = find_path_of('llvm-tblgen.exe')
if llvmbin is None:
raise RuntimeError('Could not find LLVM')
incdir = os.path.abspath(os.path.join(llvmbin, '../include'))
if not os.path.exists(os.path.join(incdir, 'llvm/BasicBlock.h')):
raise RuntimeError('Could not find LLVM include dir')
print incdir
elif sys.argv[1] == '--libdir':
llvmbin = find_path_of('llvm-tblgen.exe')
if llvmbin is None:
raise RuntimeError('Could not find LLVM')
libdir = os.path.abspath(os.path.join(llvmbin, '../lib'))
if not os.path.exists(os.path.join(libdir, 'libLLVMCore.a')):
raise RuntimeError('Could not find LLVM lib dir')
print libdir
else:
raise RuntimeError('Unrecognized llvm-config command %s' % sys.argv[1])