forked from ExtinctionHD/SteelEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.py
57 lines (45 loc) · 1.8 KB
/
Setup.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
import sys
import os
import platform
if platform.system() == "Windows":
import _winapi
is_windows = True
def log(msg):
formatted_msg = msg.replace("\\", '/')
print("-- {0}".format(formatted_msg))
def suitable_python_version():
major = sys.version_info[0]
minor = sys.version_info[1]
return major > 3 or major == 3 and minor >= 5
def create_link(src, link, is_dir):
src_abs = os.path.abspath(src)
link_abs = os.path.abspath(link)
if os.path.exists(src_abs):
if not os.path.exists(link_abs):
if is_dir:
if is_windows:
_winapi.CreateJunction(src_abs, link_abs)
else:
os.symlink(src_abs, link_abs, True)
else:
os.link(src_abs, link_abs)
log("Link created: {0} => {1}".format(src_abs, link_abs))
else:
log("Link already exists".format(link_abs))
else:
log("Invalid link source: {0}".format(src_abs))
def setup(project_path, build_path, is_msvc):
create_link(os.path.join(project_path, "Source/Shaders/"), os.path.join(build_path, "Shaders/"), True)
create_link(os.path.join(project_path, "Assets/"), os.path.join(build_path, "Assets/"), True)
create_link(os.path.join(project_path, "Config/imgui.ini"), os.path.join(build_path, "imgui.ini"), False)
if is_msvc:
create_link(os.path.join(project_path, "Config/SteelEngine.sln.DotSettings"),
os.path.join(build_path, "SteelEngine.sln.DotSettings"), False)
# Entry point
if suitable_python_version():
if len(sys.argv) > 3:
setup(project_path=sys.argv[1], build_path=sys.argv[2], is_msvc=sys.argv[3])
else:
log("Invalid arguments list: {0}".format(sys.argv))
else:
log("Minimum required python version is 3.5")