-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
SConscript
177 lines (135 loc) · 6.09 KB
/
SConscript
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# vi: syntax=python:et:ts=4
import os
from subprocess import Popen, PIPE
from glob import glob
Import("*")
#
# load list of sources from the file in source_lists/
#
def GetSources(filename):
sources = []
with open(File("#/source_lists/" + filename).rfile().abspath) as file:
for line in file.readlines():
sources.append(line.strip())
return sources
#
# setup the FIFODIR, WESNOTH_PATH
#
for environ in [test_env, client_env, env]:
# controls displaying git revision next to the version on the title screen
if environ.get("have_autorevision"):
environ.Append(CPPDEFINES = 'LOAD_REVISION')
# if not windows, then set FIFODIR and WESNOTH_PATH defines, and configure the locale and preferences locations
if environ["PLATFORM"] != "win32":
environ.Append(CPPDEFINES = "FIFODIR='\"$fifodir\"'")
environ.Append(CPPDEFINES = "WESNOTH_PATH='\"$datadir\"'")
if env['localedirname']:
environ.Append(CPPDEFINES = "LOCALEDIR='\"$localedirname\"'")
if not os.path.isabs(env['localedirname']):
environ.Append(CPPDEFINES = "HAS_RELATIVE_LOCALEDIR")
if env['version_suffix'] and not env['prefsdir']:
environ['prefsdir'] = ".wesnoth$version_suffix"
if environ['prefsdir']:
environ.Append(CPPDEFINES = "PREFERENCES_DIR=\\\"$prefsdir\\\"")
else:
environ["fifodir"] = ""
# if a default preference file exists, configure its location
if env['default_prefs_file']:
environ['default_prefs_file'] = env['default_prefs_file']
environ.Append(CPPDEFINES = "DEFAULT_PREFS_PATH='\"$default_prefs_file\"'")
if not os.path.isabs(env['default_prefs_file']):
environ.Append(CPPDEFINES = "HAS_RELATIVE_DEFPREF")
# Inject boost::bind patch everywhere
for environ in [test_env, client_env, env]:
environ.Append(CCFLAGS = Split("-include boost-patched/bind/arg.hpp"))
for environ in [test_env, client_env, env]:
environ.Append(CPPDEFINES = "$EXTRA_DEFINE")
#---libwesnoth_core---
#color_range.cpp should be removed, but game_config depends on it.
#game_config has very few things that are needed elsewhere, it should be
#removed. Requires moving path and version at least to other files.
libwesnoth_core_sources = GetSources("libwesnoth_core")
if env["PLATFORM"] == "win32":
libwesnoth_core_sources.append("log_windows.cpp")
libwesnoth_core = [env.Library("wesnoth_core", libwesnoth_core_sources)]
#---libwesnoth---
libwesnoth_sources = GetSources("libwesnoth")
libwesnoth = client_env.Library("wesnoth", libwesnoth_sources)
#---libwesnoth_sdl---
libwesnoth_sdl_sources = GetSources("libwesnoth_sdl")
if env["png"]:
libwesnoth_sdl_sources.append("SDL_SavePNG/savepng.c")
libwesnoth_sdl = client_env.Library("wesnoth_sdl", libwesnoth_sdl_sources)
#---wesnoth---
# Used by both 'wesnoth' and 'boost_unit_tests' targets
wesnoth_sources = GetSources("wesnoth")
if env["PLATFORM"] == "win32":
wesnoth_sources.append("desktop/windows_tray_notification.cpp")
if env["PLATFORM"] == 'darwin':
wesnoth_sources.append("desktop/apple_notification.mm")
if env["notifications"]:
wesnoth_sources.append("desktop/dbus_notification.cpp")
libwesnoth_extras = client_env.Library("wesnoth_extras", wesnoth_sources)
#---lua---
lua_sources = GetSources("lua")
env_lua = env.Clone(
# Silence some Clang-specific warnings due to extra parentheses in if statements when comparing.
CCFLAGS = ["$CCFLAGS", "clang" in env["CXX"] and Split("-Wno-parentheses-equality -Wno-pointer-bool-conversion") or [], "strict" in env and Split("-Wno-old-style-cast -Wno-useless-cast") or []],
CCCOM = env["CXXCOM"],
CPPPATH = ["$CPPPATH", Dir(".").srcnode()],
CPPDEFINES = ["$CPPDEFINES", env["PLATFORM"] != "win32" and "LUA_USE_POSIX" or []])
if env_lua["enable_lto"] == True:
env_lua["AR"] = 'gcc-ar'
env_lua["RANLIB"] = 'gcc-ranlib'
env_lua["wesnoth_lua_config"] = File("#/src/wesnoth_lua_config.h").rfile()
env_lua.Append(CCFLAGS = Split("-include $wesnoth_lua_config -Wno-deprecated-declarations"))
objs_lua = env_lua.Object(lua_sources)
for obj in objs_lua:
env_lua.Depends(obj, env_lua["wesnoth_lua_config"])
libwesnoth_extras.extend(env_lua.Library("lua", objs_lua))
#
# Target declarations
#
def error_action(target, source, env):
from SCons.Errors import UserError
raise UserError("Target disabled because its prerequisites are not met")
def WesnothProgram(env, target, source, can_build, **kw):
if env["enable_lto"] == True:
env["AR"] = 'gcc-ar'
env["RANLIB"] = 'gcc-ranlib'
if can_build:
if env["use_srcdir"] == True:
bin = env.Program(target + build_suffix, source, **kw)
else:
bin = env.Program("#/" + target + build_suffix, source, **kw)
env.Alias(target, bin)
else:
bin = env.Alias(target, [], error_action)
AlwaysBuild(bin)
locals()[target] = bin
Export(target)
for env in [test_env, client_env, env]:
env.AddMethod(WesnothProgram)
#---wesnoth---
libwesnoth_objects = libwesnoth_extras + libwesnoth_core + libwesnoth + libwesnoth_sdl + libwesnoth_extras
if env["PLATFORM"] == 'darwin':
client_env.WesnothProgram("wesnoth", ["wesnoth.cpp"] + libwesnoth_objects + ["macosx/SDLMain.mm"], have_client_prereqs)
else:
client_env.WesnothProgram("wesnoth", ["wesnoth.cpp"] + libwesnoth_objects, have_client_prereqs)
#---wesnothd---
wesnothd_sources = GetSources("wesnothd")
env.WesnothProgram("wesnothd", wesnothd_sources + libwesnoth_core, have_server_prereqs)
#---campaignd---
campaignd_sources = GetSources("campaignd")
env.WesnothProgram("campaignd", campaignd_sources + libwesnoth_core, have_server_prereqs, OBJPREFIX = "campaignd_")
#---boost_unit_tests---
test_sources = GetSources("boost_unit_tests")
boost_unit_tests = test_env.WesnothProgram("boost_unit_tests", test_sources + libwesnoth_objects, have_test_prereqs)
#---end of getting sources---
sources = []
if "TAGS" in COMMAND_LINE_TARGETS:
sources = [ Glob(os.path.join(dir, pattern)) for dir in ["", "*", "*/*"] for pattern in ["*.cpp", "*.hpp"] ]
Export("sources")
# Local variables:
# mode: python
# end: