-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathroadrunner_deps_build.py
74 lines (59 loc) · 2.53 KB
/
roadrunner_deps_build.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
"""
Build the libroadrunner-deps roadrunner dependency package.
Usage:
python roadrunner_deps_build.py "/full/path/to/where/you/want/to/install/the/roadrunner/dependencies/" [--with-llvm] [--build-type=[Release|Debug]]
Options:
--with-llvm: turns on building llvm along with the other dependencies
--build-type=value: where value is a valid cmake build type. Defaults to Release
"""
import os, sys
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("install_prefix", help="the cmake_install_prefix variable")
parser.add_argument("--with_llvm", help="Download and build llvm-6.x (takes longer)", default=False,
action="store_true")
parser.add_argument("--build-type", type=str, help="the cmake_build_type variable", default="Release")
args = parser.parse_args()
def do_check_call(commands: list, error_message=None):
try:
cmake_found = subprocess.check_call(commands)
except subprocess.CalledProcessError as e:
print(e.output)
if error_message:
print(error_message)
exit(1)
BASE_DIRECTORY = os.getcwd()
# will error if cmake not available
do_check_call(["cmake", "--version"],
"Make sure cmake is available and your environment variables are correctly configured to allow the 'cmake' command to be run from shell")
# clone repo
libroadrunner_deps_github = r"https://github.com/sys-bio/libroadrunner-deps.git"
LIBROADRUNNER_DEPS_DIR = os.path.join(BASE_DIRECTORY, "libroadrunner-deps")
if not os.path.isdir(LIBROADRUNNER_DEPS_DIR):
do_check_call(["git", "clone", "--recurse-submodules", libroadrunner_deps_github, LIBROADRUNNER_DEPS_DIR])
if not os.path.isdir(LIBROADRUNNER_DEPS_DIR):
raise ValueError("No roadrunner-deps package has been downloaded")
# make build directory and cd
os.chdir(LIBROADRUNNER_DEPS_DIR)
LIBROADRUNNER_DEPS_BUILD_DIR = os.path.join(LIBROADRUNNER_DEPS_DIR, "build")
os.makedirs(LIBROADRUNNER_DEPS_BUILD_DIR)
os.chdir(LIBROADRUNNER_DEPS_BUILD_DIR)
# cmake command
if (args.with_llvm):
do_check_call([
"cmake",
f"-DCMAKE_INSTALL_PREFIX={args.install_prefix}",
f"CMAKE_BUILD_TYPE={args.build_type}",
"-DBUILD_LLVM=ON",
LIBROADRUNNER_DEPS_DIR
])
else:
do_check_call([
"cmake",
f"-DCMAKE_INSTALL_PREFIX={args.install_prefix}",
f"CMAKE_BUILD_TYPE={args.build_type}",
LIBROADRUNNER_DEPS_DIR
])
# build and install command
do_check_call(["cmake" "--build", f"{LIBROADRUNNER_DEPS_BUILD_DIR}", "--target", "install", "-j", 12])