-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
111 lines (86 loc) · 3.56 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
import os
import sys
from os.path import join;
sys.path.append('.')
from wxconfig import *
wxFolder = None
opts = Options()
opts.Add(BoolOption('release', 'Set to 1 for release build', 0))
if ("WXWIN" in os.environ):
wxFolder = os.environ["WXWIN"];
else:
wxFolder = "C:\\wxWidgets-2.6.4";
env = None
if (ARGUMENTS.get("MSVS_VERSION", None) == None):
if sys.platform == 'win32':
env = Environment(tools = ['msvc', 'mslink'], options = opts, ENV = os.environ)
else:
env = Environment(options = opts, ENV = os.environ)
else:
env = Environment(options = opts, ENV = os.environ, MSVS_VERSION=ARGUMENTS.get("MSVS_VERSION", None))
Help(opts.GenerateHelpText(env))
### setup variables needed, mainly to support cross-compilation
env['build_platform']=env['PLATFORM']
env['target_platform']=env['PLATFORM']
env['wxconfig']='wx-config'
compiler = env['CXX']
# HACK for scons 1.2 on Windows where env['CXX'] == '$CC'
while compiler[0] == '$':
compiler = env[compiler[1:]];
# end HACK
# some helper variables
targetPlatformIsWindows = (env['target_platform'] == 'win32');
compilerIsVC = (compiler == 'cl');
compilerIsGccLike = not compilerIsVC;
if not env.GetOption('clean'):
if compilerIsVC:
print "Compiling using Visual C++...";
elif compilerIsGccLike:
print "Compiling using '%s', assuming GCC-like compiler" % env['CXX'];
debug = (env['release'] == 0)
### detect wxWidgets
conf = Configure(env, custom_tests = {'CheckWXConfig' : CheckWXConfig })
# CheckWXConfig(version, componentlist, debug)
# version: string with minimum version ('x.y')
# componentlist: list of components needed. This was introduced with
# wxWidgets 2.6 if I'm correct. You'll usually need
# ['adv', 'core', 'base'], in this order. If you use
# wxGLCanvas, prepend 'gl' like below.
if not conf.CheckWXConfig('2.6', ['adv', 'core', 'base'], debug):
print 'Error finding wxWidgets library.'
env = conf.Finish()
### target
ParseWXConfig(env)
resources = [];
psdk_libs = ["user32", "kernel32", "shell32", "shlwapi", "comctl32", "gdi32", "ole32", "wsock32", "advapi32", "userenv", "Comdlg32", "Rpcrt4", "Netapi32", "uuid", "Version", "oleaut32"]
if targetPlatformIsWindows:
env.Append(LIBS = [psdk_libs]);
resources = env.RES(["resources.rc"]);
if compilerIsVC:
if (debug):
env.Append(CXXFLAGS = ["-Zi"])
env.Append(CXXFLAGS = ["-RTCcsu", "-GS"]) # generate stack corruption checks
# Not needed because wx flags already contain one
#env.Append(CXXFLAGS = ["-MTd"]);
env.Append(LINKFLAGS = ["-debug"]);
else:
env.Append(CPPDEFINES = ["NDEBUG"])
# Not needed because wx flags already contain one
#env.Append(CXXFLAGS = ["-MT"]);
env.Append(LINKFLAGS = ["-release", "-OPT:REF", "-OPT:ICF=32"]);
elif compilerIsGccLike:
if (debug):
env.Append(CXXFLAGS = ["-g"]);
else:
env.Append(CXXFLAGS = ["-O2"]);
buildResult = env.Program("build/CookTimer", ["CookTimerFrame.cpp", "main.cpp",
resources])
# On Non-Windows platforms, place the wav file in the output directory because
# it's not embedded into the exe
if not targetPlatformIsWindows:
env.Command('build/alarm.wav', 'alarm.wav', Copy('$TARGET', '$SOURCE'))
# post actions
if compilerIsVC and int(float(env["MSVS_VERSION"][0:2])) >= 8:
# Add a post-build step to embed the manifest using mt.exe
# The number at the end of the line indicates the file type (1: EXE; 2:DLL).
env.AddPostAction(buildResult, 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1')