-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
124 lines (93 loc) · 4.87 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
112
113
114
115
116
117
118
119
120
121
122
123
import util, warnings
# Ignore DeprecationWarnings to keep things readable (happens with scons 1.0.1 and Python 2.6)
warnings.simplefilter('ignore', DeprecationWarning)
platform = util.get_platform()
arch = util.get_arch()
# Build variable stuff
vars = Variables('build.conf')
vars.Add('MARCH', 'Sets the -march gcc optimization flag', '')
vars.Add('PROFILING', 'If set to 1, adds profiling information to both debug/release executables',0)
vars.Add('SKIP_GTK', 'If set to 1, skips drawing framebuffer to GTK drawingarea for benchmarking'\
' purposes', 0)
vars.Add('NO_ASM', 'If set to 1, no assembly files will be built', 0)
vars.Add('VERBOSE', 'If set to 1, the full compilation commands will be shown',0)
vars.Add('WIN_GTK_PATH', 'Should be set to the path where the GTK+ headers/libs reside on Windows',
'C:\\MinGW\\gtkstuff')
vars.Add('WIN_DEVIL_PATH', 'Should be set to the path where the DevIL headers/libs reside on '\
'Windows', 'C:\\MinGW\\devil')
vars.Add('WIN_PATH', 'Semicolon-seperated paths in which scons looks for the gcc, nasm executables',
'C:\\MinGW\\bin;C:\\Program Files\\nasm')
# Set up generic environment
if platform == 'win32':
env_generic = Environment(variables = vars, tools = ['mingw', 'nasm'])
env_generic['ENV']['PATH'] = env_generic['WIN_PATH']
gtk_path = env_generic['WIN_GTK_PATH']
devil_path = env_generic['WIN_DEVIL_PATH']
env_generic.Append(CPPPATH = [devil_path + '\include',
gtk_path + '\\include\\atk-1.0',
gtk_path + '\\include\\cairo',
gtk_path + '\\include\\pango-1.0',
gtk_path + '\\include\\glib-2.0',
gtk_path + '\\lib\\glib-2.0\\include',
gtk_path + '\\include\\gtk-2.0',
gtk_path + '\\lib\\gtk-2.0\\include',
gtk_path + '\\include\\libglade-2.0'])
env_generic.Append(LIBPATH = [devil_path + '\\lib',
gtk_path + '\\lib'])
env_generic.Append(LIBS = ['devil', 'ilu', 'glade-2.0', 'glib-2.0', 'gtk-win32-2.0',
'gobject-2.0', 'gdk-win32-2.0'])
# GTK+ on Windows needs this
env_generic.Append(CCFLAGS = ['-mms-bitfields'])
if arch == 'x86':
env_generic.Append(ASFLAGS = ['-f win32'])
elif arch == 'x86_64':
env_generic.Append(ASFLAGS = ['-f win64'])
else:
# Assume gcc etc are available but print a warning if the platform is unrecognised
if platform not in ['linux', 'freebsd', 'darwin']:
print 'WARNING: Unrecognised platform (' + platform + ')'
env_generic = Environment(variables = vars, tools = ['gcc', 'gnulink', 'nasm'])
env_generic.ParseConfig("pkg-config gtk+-2.0 --libs --cflags")
env_generic.ParseConfig("pkg-config libglade-2.0 --libs --cflags")
env_generic.ParseConfig("pkg-config gthread-2.0 --libs --cflags")
# libglade needs this to connect UI callbacks
env_generic.Append(LINKFLAGS = ['-rdynamic'])
env_generic.Append(LIBS = ['IL', 'ILU', 'm'])
if arch == 'x86':
env_generic.Append(ASFLAGS = ['-f elf32'])
elif arch == 'x86_64':
env_generic.Append(ASFLAGS = ['-f elf64'])
env_generic.Append(CCFLAGS = ['-Wall', '-std=c99'])
if not util.is_defined(env_generic['VERBOSE']):
env_generic['CCCOMSTR'] = 'Compiling $SOURCE -> $TARGET'
env_generic['ASCOMSTR'] = 'Assembling $SOURCE -> $TARGET'
env_generic['LINKCOMSTR'] = 'Linking $TARGET'
if util.is_defined(env_generic['PROFILING']):
env_generic.Append(CCFLAGS = ['-pg', '-fno-inline'])
env_generic.Append(LINKFLAGS = ['-pg'])
# Skip copying image to GTK+ drawingarea (for benchmarking) if requested
if util.is_defined(env_generic['SKIP_GTK']):
env_generic.Append(CPPDEFINES = ['SKIP_GTK'])
# Force NO_ASM if arch is not supported.
if arch not in ['x86','x86_64']:
env_generic['NO_ASM'] = 1
if util.is_defined(env_generic['NO_ASM']):
env_generic.Append(CPPDEFINES = ['NO_ASM'])
Help(vars.GenerateHelpText(env_generic))
# Customize for release build
env_release = env_generic.Clone()
# Don't add omit-frame-pointer when profiling
if util.is_defined(env_generic['PROFILING']):
env_release.Append(CCFLAGS = ['-O2', '-ffast-math', '-mfpmath=387,sse'])
else:
env_release.Append(CCFLAGS = ['-O2', '-fomit-frame-pointer', '-ffast-math', '-mfpmath=387,sse'])
env_release.Append(CCFLAGS = ['-march=$MARCH'] if str(env_release['MARCH']) else [] )
# Customize for debug build
env_debug = env_generic.Clone()
env_debug.Append(CCFLAGS = ['-g'])
env_debug.Append(ASFLAGS = ['-g'])
env_debug.Append(CPPDEFINES = ['DEBUG'])
env = env_release
SConscript('src/SConscript', exports='env arch util', variant_dir='build/release', duplicate=0)
env = env_debug
SConscript('src/SConscript', exports='env arch util', variant_dir='build/debug', duplicate=0)