-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSConstruct
More file actions
94 lines (82 loc) · 2.42 KB
/
SConstruct
File metadata and controls
94 lines (82 loc) · 2.42 KB
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
import sys
from shutil import copytree, rmtree
# Cross compile optional args
MINGW = "/usr/bin/x86_64-w64-mingw32-g++"
AddOption("--cross", help="Cross compile to Windows", metavar="0")
env = DefaultEnvironment(CROSS = GetOption("cross"))
# Determine compiler
CROSS = env["CROSS"]
if CROSS == "1":
env["CXX"] = MINGW
print("--- Using compiler: {}".format(env["CXX"]))
# Link libraries
LINUX_LIBS = ["stdc++", "tgui", "sfml-audio", "sfml-graphics", "sfml-window", "sfml-system", "sfml-network", "lua5.3"]
WIN_LIBS = ["tgui", "sfml-audio", "sfml-graphics", "sfml-window", "sfml-system", "sfml-network", "lua53"]
MINGW_LIBS = ["tgui", "sfml-graphics", "sfml-window", "sfml-system", "sfml-network", "lua53"]
# Compiler/Linker flags
LINUX_CXXFLAGS = "-Isrc/ -I/usr/include/ -Iinclude/"
LINUX_LINKFLAGS = "-Wl,-rpath,.'$ORIGIN'/lib"
WIN_CXXFLAGS = "/Isrc/ /std:c++17 /O2 /FS /ZI /W2 /EHsc"
MINGW_CXXFLAGS = "-Isrc/ -Iinclude/ -static-libgcc -static-libstdc++"
MINGW_LINKFLAGS = "-Llib/"
# Common data
FILENAME = "bin/multicaster"
WIN_FILENAME = FILENAME + ".exe"
SOURCES = Glob("src/*.cpp")
SOURCES.extend(Glob("src/**/*.cpp"))
BIN_PATH = "./bin"
def pre_build():
platform = sys.platform
print("--- Building for " + platform)
try:
os.mkdir(BIN_PATH)
except Exception:
pass
if CROSS == "1":
build_cross()
elif platform.startswith("win"):
build_windows()
elif platform.startswith("linux"):
build_linux()
else:
print("--- No builds for your current OS: " + platform)
sys.exit(-1)
def build_linux():
Program(
FILENAME,
SOURCES,
CXXFLAGS = LINUX_CXXFLAGS,
LINKFLAGS = LINUX_LINKFLAGS,
LIBS = LINUX_LIBS,
)
def build_windows():
Program(
FILENAME,
SOURCES,
CXXFLAGS = WIN_CXXFLAGS,
LIBS = WIN_LIBS,
CPPPATH = "./include",
LIBPATH = "./lib",
)
# Cross compile using x86_64-w64-mingw32-g++
def build_cross():
Program(
WIN_FILENAME,
SOURCES,
CXXFLAGS = MINGW_CXXFLAGS,
LINKFLAGS = MINGW_LINKFLAGS,
LIBS = MINGW_LIBS,
CPPPATH = "./include",
LIBPATH = "./lib",
)
def post_build():
# Make the resource folder acessible by the generated binary
try:
rmtree("bin/resources")
except OSError as e:
print(e)
finally:
copytree("resources", "bin/resources")
pre_build()
post_build()