forked from anura-engine/anura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
111 lines (92 loc) · 3.88 KB
/
SConstruct
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
# vi: syntax=python:et:ts=4
import os.path
import subprocess
import sys
try:
subprocess.Popen("sdl2-config", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError:
print "SDL2 not found, SDL-1.2 is no longer supported"
sys.exit(1)
use_lua = subprocess.Popen(["pkg-config", "--exists", "lua5.2"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait() == 0
# Warn user of current set of build options.
if os.path.exists('.scons-option-cache'):
optfile = file('.scons-option-cache')
print "Saved options:", optfile.read().replace("\n", ", ")[:-2]
optfile.close()
opts = Variables('.scons-option-cache')
opts.AddVariables(
EnumVariable('build', 'Build variant: debug, release profile', "release", ["release", "debug", "profile"]),
PathVariable('build_dir', 'Build all intermediate files(objects, test programs, etc) under this dir', "build", PathVariable.PathAccept),
BoolVariable('ccache', "Use ccache", True),
BoolVariable('extrawarn', "Use wesnoth-level warnings", False),
BoolVariable('shaders', "Use shaders", False),
BoolVariable('strict', 'Set to strict compilation', False),
('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
('jobs', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
)
env = Environment(options = opts, CPPPATH = [".","../../include"])
if use_lua:
env.Append(CXXFLAGS=["-DUSE_LUA"])
env.ParseConfig("pkg-config --libs --cflags lua5.2")
env.ParseConfig("pkg-config --libs --cflags cairo freetype2")
env.ParseConfig("sdl2-config --libs --cflags")
env.Append(LIBS = ["SDL2_mixer", "SDL2_image", "SDL2_ttf"])
env.Append(LIBS = ["GL", "GLEW", "boost_filesystem", "boost_regex", "boost_system", "boost_iostreams", "png", "z"])
env.Append(CXXFLAGS= ["-pthread", "-DIMPLEMENT_SAVE_PNG", "-DUSE_ISOMAP", "-DUSE_BOX2D", "-DUSE_SVG"], LINKFLAGS = ["-pthread"])
if sys.platform.startswith('linux'):
env.Append(LIBS = ["X11"])
opts.Save('.scons-option-cache', env)
builds = {
"debug" : dict(CCFLAGS = Split("$DEBUG_FLAGS")),
"release" : dict(CCFLAGS = "$OPT_FLAGS"),
"profile" : dict(CCFLAGS = "-pg", LINKFLAGS = "-pg")
}
build = env["build"]
env.AppendUnique(**builds[build])
build_dir = os.path.join("$build_dir", build)
if build == "release" : build_suffix = ""
else : build_suffix = "-" + build
Export("build_suffix")
if "gcc" in env["TOOLS"]:
env.AppendUnique(CCFLAGS = Split("-Wignored-qualifiers -Wformat -Wswitch"))
if env['extrawarn']:
env.AppendUnique(CCFLAGS = Split("-W -Wall -Wno-sign-compare -Wno-parentheses"))
env.AppendUnique(CXXFLAGS = "-std=c++0x")
if env['strict']:
env.AppendUnique(CCFLAGS = Split("-Werror"))
env["OPT_FLAGS"] = "-O2"
env["DEBUG_FLAGS"] = Split("-O0 -DDEBUG -ggdb3")
env['exclude'] = []
env.Append(CXXFLAGS= ["-DUSE_SHADERS"])
if env.get('cxxtool',""):
env['CXX'] = env['cxxtool']
if 'HOME' in os.environ:
env['ENV']['HOME'] = os.environ['HOME']
if env['ccache']:
env['CCACHE'] = env.WhereIs("ccache")
env['CC'] = '%s %s' % (env['CCACHE'], env['CC'])
env['CXX'] = '%s %s' % (env['CCACHE'], env['CXX'])
for i in ['HOME',
'CCACHE_DIR',
'CCACHE_TEMPDIR',
'CCACHE_LOGFILE',
'CCACHE_PATH',
'CCACHE_CC',
'CCACHE_PREFIX',
'CCACHE_DISABLE',
'CCACHE_READONLY',
'CCACHE_CPP2',
'CCACHE_NOSTATS',
'CCACHE_NLEVELS',
'CCACHE_HARDLINK',
'CCACHE_RECACHE',
'CCACHE_UMASK',
'CCACHE_HASHDIR',
'CCACHE_UNIFY',
'CCACHE_EXTENSION']:
if os.environ.has_key(i) and not env.has_key(i):
env['ENV'][i] = os.environ[i]
if env['jobs'] > 1:
SetOption("num_jobs", env['jobs'])
Export(["env"])
env.SConscript(dirs=["src"], variant_dir = build_dir, duplicate = False)