-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
executable file
·58 lines (42 loc) · 1.7 KB
/
install.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
#!/usr/bin/env python
import tempfile, os, subprocess, multiprocessing, sys
def execute(cwd, cmd):
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE,
universal_newlines=True, shell=True, cwd=cwd)
for stdout_line in iter(popen.stdout.readline, ""):
yield stdout_line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
def execute2(cwd, cmd):
for line in execute(cwd, cmd):
sys.stdout.write(line)
def big_print(message):
print('\n\t{}\n'.format(message))
def install():
tempdir = tempfile.gettempdir()
big_print('Working in temporary folder "{}"'.format(tempdir))
builddir = os.path.join(tempdir, 'llvm-build')
llvmsourcedir = os.path.join(tempdir, 'llvm')
llvmtoolsdir = os.path.join(llvmsourcedir, 'tools')
clangtoolsdir = os.path.join(llvmtoolsdir, 'clang', 'tools')
big_print('Cloning LLVM sources...')
execute2(tempdir, 'svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm')
big_print('Cloning Clang sources...')
execute2(llvmtoolsdir, 'svn co http://llvm.org/svn/llvm-project/llvm/trunk clang')
big_print('Cloning Clara sources...')
execute2(clangtoolsdir, 'git clone --recursive https://github.com/rwols/Clara.git')
big_print('Configuring with CMake in "{}"'.format(builddir))
execute2(tempdir, 'cmake -Hllvm -Bllvm-build -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON -DCLANG_RESOURCE_DIR=. -DCMAKE_BUILD_TYPE=Release')
cpu_count = str(multiprocessing.cpu_count())
big_print('Building with {} jobs'.format(cpu_count))
execute2(builddir, 'make ClaraInstall -j{}'.format(cpu_count))
big_print('Clara is installed!')
def main():
try:
install()
except Exception as e:
print(e)
if __name__ == '__main__':
main()