5 from subprocess
import call
, check_call
, CalledProcessError
7 from typing
import List
, Tuple
11 settings
, rest
= parse_arguments()
12 cmake_opts
= ["-D" + cmd
for cmd
in settings
.D
]
15 if settings
.build_llvm
or settings
.build_llvm_only
:
16 build_llvm(cmake_opts
)
17 if settings
.build_llvm_only
:
23 # It is an easy on CPU way of keeping the docker container running
24 # while the user has a terminal session in that container.
29 def parse_arguments() -> Tuple
[argparse
.Namespace
, List
[str]]:
30 parser
= argparse
.ArgumentParser()
31 parser
.add_argument("--wait", action
="store_true")
32 parser
.add_argument("--build-llvm", action
="store_true")
33 parser
.add_argument("--build-llvm-only", action
="store_true")
34 parser
.add_argument("-D", action
="append", default
=[])
35 return parser
.parse_known_args()
38 def build_llvm(cmake_options
):
44 except CalledProcessError
:
45 print("Build failed!")
49 def is_cmake_needed():
50 return "build.ninja" not in os
.listdir()
54 "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "
55 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 "
56 '-DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_BUILD_RUNTIME=OFF '
57 "-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF "
58 "-DCLANG_ENABLE_STATIC_ANALYZER=ON"
62 def cmake(cmake_options
):
64 CMAKE_COMMAND
+ " ".join(cmake_options
) + " /llvm-project/llvm", shell
=True
69 check_call("ninja install", shell
=True)
72 def test(args
: List
[str]) -> int:
74 return call("/scripts/SATest.py " + " ".join(args
), shell
=True)
77 if __name__
== "__main__":