-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm.py
75 lines (66 loc) · 2.04 KB
/
llvm.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
import subprocess
import os
import sys
import argparse
def install_llvm(cwd, install_dir=None, release="Debug"):
# install build dependencies
subprocess.run(["sudo", "apt", "update"])
subprocess.run(["sudo", "apt", "install", "-y", "cmake", "python3-yaml", "ninja-build"], check=True)
# clone the git project
subprocess.run(["git", "clone", "--depth=1", "--branch", "main", "https://github.com/llvm/llvm-project.git"], check=True)
# setup and configure
os.chdir("./llvm-project")
subprocess.run(["ls", "-al"])
if install_dir == None:
subprocess.run(
[
"cmake",
"-G",
"Ninja",
"-S",
"llvm",
"-B",
"build",
f"-DCMAKE_BUILD_TYPE={release.capitalize()}",
]
)
else:
subprocess.run(
[
"cmake",
"-G",
"Ninja",
"-S",
"llvm",
"-B",
"build",
f"-DCMAKE_INSTALL_PREFIX={install_dir}",
"-DCMAKE_BUILD_TYPE=Debug"
],
check=True,
)
# build
# os.chdir("build")
# subprocess.run(["make", "-j8"])
# subprocess.run(["make", "install"])
# Build using Ninja (automatically uses all available cores)
subprocess.run(["ninja", "-C", "build"], check=True)
# Install
subprocess.run(["ninja", "-C", "build", "install"], check=True)
# resetting the path
os.chdir(cwd)
if __name__ == "__main__":
parser = argparse.ArgumentParser("llvm.py", "llvm build script")
parser.add_argument(
"-o", "--outpath", type=str, help="the install path", default=None
)
parser.add_argument(
"-t",
"--type",
type=str,
help="the type of release mode by default it is RELEASE [DEBUG, RELEASE options]",
default="RELEASE",
)
args = parser.parse_args()
cwd = os.getcwd()
install_llvm(cwd, args.outpath, args.type)