-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
41 lines (37 loc) · 1.16 KB
/
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
# one build script to rule them all
"""
build.py
Run this script to config and build the solution using cmake.
For e.g., python build.py
Command line args:
--clean: removes/cleans build folder
--build: configs and runs the build. This is the default behaviour
"""
import subprocess
import argparse
import shutil
def setup_argparser():
"""
Setup Argparser
Sets up argument parsing routines for the script
@return: returns an argparser arg object
"""
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--clean", help="Clean build.", action="store_true")
parser.add_argument("-b", "--build", help="Build project.", action="store_true",
default="store_true")
return parser.parse_args()
def main():
"""
Main entry point for this script
"""
args = setup_argparser()
if args.clean:
shutil.rmtree("./_build/")
elif args.build:
config_cmd = ["cmake.exe", ".", "-B./build", "-GVisual Studio 16 2019", "-Ax64"]
subprocess.call(config_cmd)
build_cmd = ["cmake.exe", "--build", "build"]
subprocess.call(build_cmd)
if __name__ == "__main__":
main()