-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
94 lines (77 loc) · 2.05 KB
/
tasks.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os
from invoke import task
@task
def config(context, build_type="Release"):
print(f"Configuring project with CMake (build_type: {build_type})...")
if os.name == "nt":
build_dir = f"build/{build_type}"
os.makedirs(build_dir, exist_ok=True)
cmd = [
"cmake",
f"-DCMAKE_BUILD_TYPE={build_type}",
"-S",
".",
"-B",
build_dir,
'-G "MinGW Makefiles"'
]
else:
build_dir = f"build/{build_type}"
os.makedirs(build_dir, exist_ok=True)
cmd = [
"cmake",
f"-DCMAKE_BUILD_TYPE={build_type}",
"-S",
".",
"-B",
build_dir
]
print(" ".join(cmd))
context.run(" ".join(cmd))
if os.path.islink("compile_commands.json"):
os.remove("compile_commands.json")
os.symlink(f"{build_dir}/compile_commands.json", "compile_commands.json")
@task
def build(context, build_type="Release"):
print("Building project with CMake...")
if os.name == "nt":
build_dir = f"build/{build_type}"
cmd = [
"cmake",
"--build",
build_dir,
f"--config={build_type}",
"-j"
]
else:
build_dir = f"build/{build_type}"
cmd = [
"cmake",
"--build",
build_dir,
"-j"
]
print(" ".join(cmd))
context.run(" ".join(cmd))
@task
def run(context, build_type="Release"):
print("Running project...")
if os.name == "nt":
cmd = [
f".\\build\\{build_type}\\GLX\\GLX.exe"
]
else:
cmd = [
f"./build/{build_type}/GLX/GLX"
]
print(" ".join(cmd))
context.run(" ".join(cmd))
@task
def clean(context):
if os.path.exists("build"):
if os.name == "nt":
context.run("rmdir /S /Q build")
else:
context.run("rm -rf build")
if os.path.islink("compile_commands.json"):
os.remove("compile_commands.json")