-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_with_conan.py
executable file
·64 lines (48 loc) · 2.24 KB
/
build_with_conan.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
#!/usr/bin/env python3
import argparse
import os
import shutil
import subprocess
def clean_build_folder(build_folder: str):
if os.path.exists(build_folder):
shutil.rmtree(build_folder)
def run_cmd(context: str, cmd: str):
print("----------------------------------")
print(cmd)
print("----------------------------------")
if subprocess.call(cmd, shell=True) != 0:
raise Exception(f"{context} command failed.")
def main(args):
cmake_options = []
conan_options = []
if args.build_with_clang_tidy:
cmake_options.append("-D BUILD_WITH_CLANG_TIDY=ON")
if args.release:
build_folder = "build/Release"
cmake_options.append("-D CMAKE_BUILD_TYPE=Release")
conan_options.append("--output-folder=build/Release/generators")
else:
build_folder = "build/Debug"
cmake_options.append("-D CMAKE_BUILD_TYPE=Debug")
# We still want to have our dependencies in Release, but the & tells conan we will build the consumer as Debug
conan_options.append("--settings '&:build_type=Debug'")
conan_options.append("--output-folder=build/Debug/generators")
if args.clean:
print("----------------------------------")
print(f"cleaning build directory {build_folder}")
print("----------------------------------")
clean_build_folder(build_folder)
os.makedirs(build_folder, exist_ok=True)
run_cmd("Conan install",
"conan install . --build=missing --profile ./conanprofile --profile:build ./conanprofile " + " ".join(
conan_options))
run_cmd("CMake", "cmake " + " ".join(cmake_options) + f" -B {build_folder}")
run_cmd("CMake build", f"cmake --build {build_folder} --parallel {args.parallel}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--clean", action="store_true", help="Clean build directory before building")
parser.add_argument("--release", action="store_true", help="Trigger RELEASE build")
parser.add_argument("--build_with_clang_tidy", action="store_true", help="Build with clang-tidy")
parser.add_argument("--parallel", type=int, default=16, help="Number of parallel jobs")
args_parsed = parser.parse_args()
main(args_parsed)