OSDN Git Service

graw: update graw_null after interface changes and build graw tests again
[android-x86/external-mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as 
5 #
6 #   scons debug=1 dri=0 machine=x86
7 #
8 # to set configuration variables. Or you can write those options to a file
9 # named config.py:
10 #
11 #   # config.py
12 #   debug=1
13 #   dri=0
14 #   machine='x86'
15
16 # Invoke
17 #
18 #   scons -h
19 #
20 # to get the full list of options. See scons manpage for more info.
21 #  
22
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 default_statetrackers = 'mesa'
34 default_targets = 'graw-null'
35
36 if common.default_platform in ('linux', 'freebsd', 'darwin'):
37         default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
38         default_winsys = 'xlib'
39 elif common.default_platform in ('winddk',):
40         default_drivers = 'softpipe,svga,i915,i965,trace,identity'
41         default_winsys = 'all'
42 elif common.default_platform in ('embedded',):
43         default_drivers = 'softpipe,llvmpipe'
44         default_winsys = 'xlib'
45 else:
46         default_drivers = 'all'
47         default_winsys = 'all'
48
49 opts = Variables('config.py')
50 common.AddOptions(opts)
51 opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
52                      ['mesa', 'python', 'xorg', 'egl']))
53 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
54                      ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'r600', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
55 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
56                      ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'r600', 'graw-xlib']))
57
58 opts.Add(ListVariable('targets', 'driver targets to build', default_targets,
59                       ['dri-i915',
60                        'dri-i965',
61                        'dri-nouveau',
62                        'dri-radeong',
63                        'dri-swrast',
64                        'dri-vmwgfx',
65                        'egl-i915',
66                        'egl-i965',
67                        'egl-nouveau',
68                        'egl-radeon',
69                        'egl-swrast',
70                        'egl-vmwgfx',
71                        'graw-xlib',
72                        'graw-null',
73                        'libgl-gdi',
74                        'libgl-xlib',
75                        'xorg-i915',
76                        'xorg-i965',
77                        'xorg-nouveau',
78                        'xorg-radeon',
79                        'xorg-vmwgfx']))
80
81 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
82
83 env = Environment(
84         options = opts,
85         tools = ['gallium'],
86         toolpath = ['#scons'],  
87         ENV = os.environ,
88 )
89
90 if os.environ.has_key('CC'):
91         env['CC'] = os.environ['CC']
92 if os.environ.has_key('CFLAGS'):
93         env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
94 if os.environ.has_key('CXX'):
95         env['CXX'] = os.environ['CXX']
96 if os.environ.has_key('CXXFLAGS'):
97         env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
98 if os.environ.has_key('LDFLAGS'):
99         env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
100
101 Help(opts.GenerateHelpText(env))
102
103 # replicate options values in local variables
104 debug = env['debug']
105 dri = env['dri']
106 machine = env['machine']
107 platform = env['platform']
108
109 # derived options
110 x86 = machine == 'x86'
111 ppc = machine == 'ppc'
112 gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
113 msvc = platform in ('windows', 'winddk')
114
115 Export([
116         'debug', 
117         'x86', 
118         'ppc', 
119         'dri', 
120         'platform',
121         'gcc',
122         'msvc',
123 ])
124
125
126 #######################################################################
127 # Environment setup
128
129 # Always build trace, rbug, identity, softpipe, and llvmpipe (where possible)
130 if 'trace' not in env['drivers']:
131     env['drivers'].append('trace')
132 if 'rbug' not in env['drivers']:
133     env['drivers'].append('rbug')
134 if 'identity' not in env['drivers']:
135     env['drivers'].append('identity')
136 if 'softpipe' not in env['drivers']:
137     env['drivers'].append('softpipe')
138 if env['llvm'] and 'llvmpipe' not in env['drivers']:
139     env['drivers'].append('llvmpipe')
140 if 'sw' not in env['drivers']:
141     env['drivers'].append('sw')
142
143 # Includes
144 env.Prepend(CPPPATH = [
145         '#/include',
146 ])
147 env.Append(CPPPATH = [
148         '#/src/gallium/include',
149         '#/src/gallium/auxiliary',
150         '#/src/gallium/drivers',
151         '#/src/gallium/winsys',
152 ])
153
154 if env['msvc']:
155     env.Append(CPPPATH = ['#include/c99'])
156
157 # Embedded
158 if platform == 'embedded':
159         env.Append(CPPDEFINES = [
160                 '_POSIX_SOURCE',
161                 ('_POSIX_C_SOURCE', '199309L'), 
162                 '_SVID_SOURCE',
163                 '_BSD_SOURCE', 
164                 '_GNU_SOURCE',
165                 
166                 'PTHREADS',
167         ])
168         env.Append(LIBS = [
169                 'm',
170                 'pthread',
171                 'dl',
172         ])
173
174 # Posix
175 if platform in ('posix', 'linux', 'freebsd', 'darwin'):
176         env.Append(CPPDEFINES = [
177                 '_POSIX_SOURCE',
178                 ('_POSIX_C_SOURCE', '199309L'), 
179                 '_SVID_SOURCE',
180                 '_BSD_SOURCE', 
181                 '_GNU_SOURCE',
182                 'PTHREADS',
183                 'HAVE_POSIX_MEMALIGN',
184         ])
185         if gcc:
186                 env.Append(CFLAGS = ['-fvisibility=hidden'])
187         if platform == 'darwin':
188                 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
189         env.Append(LIBS = [
190                 'm',
191                 'pthread',
192                 'dl',
193         ])
194
195 # for debugging
196 #print env.Dump()
197
198 Export('env')
199
200
201 #######################################################################
202 # Invoke SConscripts
203
204 # TODO: Build several variants at the same time?
205 # http://www.scons.org/wiki/SimultaneousVariantBuilds
206
207 if env['platform'] != common.default_platform:
208     # GLSL code has to be built twice -- one for the host OS, another for the target OS...
209
210     host_env = Environment(
211         # options are ignored
212         # default tool is used
213         tools = ['default', 'custom'],
214         toolpath = ['#scons'],  
215         ENV = os.environ,
216     )
217
218     host_env['platform'] = common.default_platform
219     host_env['machine'] = common.default_machine
220     host_env['debug'] = env['debug']
221
222     SConscript(
223         'src/glsl/SConscript',
224         variant_dir = os.path.join(env['build'], 'host'),
225         duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
226         exports={'env':host_env},
227     )
228
229 SConscript(
230         'src/SConscript',
231         variant_dir = env['build'],
232         duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
233 )
234
235 env.Default('src')
236