1 #######################################################################
12 env.Append(CPPPATH = [
18 env.Append(CPPDEFINES = [
22 if env['platform'] == 'windows':
23 env.Append(CPPDEFINES = [
24 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
25 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
28 # prevent _glapi_* from being declared __declspec(dllimport)
29 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
31 env.Append(CPPDEFINES = [
32 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
40 'main/api_arrayelt.c',
42 'main/api_loopback.c',
43 'main/api_validate.c',
46 'main/atifragshader.c',
72 'main/ff_fragment_shader.cpp',
73 'main/ffvertex_prog.c',
77 'main/format_unpack.c',
97 'main/pixeltransfer.c',
100 'main/querymatrix.c',
105 'main/renderbuffer.c',
110 'main/shader_query.cpp',
115 'main/texcompress.c',
116 'main/texcompress_rgtc.c',
117 'main/texcompress_s3tc.c',
118 'main/texcompress_fxt1.c',
119 'main/texcompress_etc.c',
123 'main/texgetimage.c',
131 'main/texturebarrier.c',
132 'main/transformfeedback.c',
133 'main/uniform_query.cpp',
142 'math/m_debug_clip.c',
143 'math/m_debug_norm.c',
144 'math/m_debug_xform.c',
147 'math/m_translate.c',
154 'swrast/s_aatriangle.c',
156 'swrast/s_atifragshader.c',
161 'swrast/s_copypix.c',
162 'swrast/s_context.c',
164 'swrast/s_depthstencil.c',
165 'swrast/s_drawpix.c',
166 'swrast/s_feedback.c',
168 'swrast/s_fragprog.c',
171 'swrast/s_masking.c',
173 'swrast/s_renderbuffer.c',
175 'swrast/s_stencil.c',
176 'swrast/s_texcombine.c',
177 'swrast/s_texfetch.c',
178 'swrast/s_texfilter.c',
179 'swrast/s_texrender.c',
180 'swrast/s_texture.c',
181 'swrast/s_triangle.c',
185 swrast_setup_sources = [
186 'swrast_setup/ss_context.c',
187 'swrast_setup/ss_triangle.c',
195 'tnl/t_vb_program.c',
202 'tnl/t_vb_normals.c',
206 'tnl/t_vertex_sse.c',
207 'tnl/t_vertex_generic.c',
213 'vbo/vbo_exec_api.c',
214 'vbo/vbo_exec_array.c',
215 'vbo/vbo_exec_draw.c',
216 'vbo/vbo_exec_eval.c',
220 'vbo/vbo_split_copy.c',
221 'vbo/vbo_split_inplace.c',
223 'vbo/vbo_save_api.c',
224 'vbo/vbo_save_draw.c',
225 'vbo/vbo_save_loopback.c',
228 statetracker_sources = [
229 'state_tracker/st_atom.c',
230 'state_tracker/st_atom_blend.c',
231 'state_tracker/st_atom_clip.c',
232 'state_tracker/st_atom_constbuf.c',
233 'state_tracker/st_atom_depth.c',
234 'state_tracker/st_atom_framebuffer.c',
235 'state_tracker/st_atom_msaa.c',
236 'state_tracker/st_atom_pixeltransfer.c',
237 'state_tracker/st_atom_sampler.c',
238 'state_tracker/st_atom_scissor.c',
239 'state_tracker/st_atom_shader.c',
240 'state_tracker/st_atom_rasterizer.c',
241 'state_tracker/st_atom_stipple.c',
242 'state_tracker/st_atom_texture.c',
243 'state_tracker/st_atom_viewport.c',
244 'state_tracker/st_cb_bitmap.c',
245 'state_tracker/st_cb_blit.c',
246 'state_tracker/st_cb_bufferobjects.c',
247 'state_tracker/st_cb_clear.c',
248 'state_tracker/st_cb_condrender.c',
249 'state_tracker/st_cb_flush.c',
250 'state_tracker/st_cb_drawpixels.c',
251 'state_tracker/st_cb_drawtex.c',
252 'state_tracker/st_cb_eglimage.c',
253 'state_tracker/st_cb_fbo.c',
254 'state_tracker/st_cb_feedback.c',
255 'state_tracker/st_cb_program.c',
256 'state_tracker/st_cb_queryobj.c',
257 'state_tracker/st_cb_rasterpos.c',
258 'state_tracker/st_cb_readpixels.c',
259 'state_tracker/st_cb_syncobj.c',
260 'state_tracker/st_cb_strings.c',
261 'state_tracker/st_cb_texture.c',
262 'state_tracker/st_cb_texturebarrier.c',
263 'state_tracker/st_cb_viewport.c',
264 'state_tracker/st_cb_xformfb.c',
265 'state_tracker/st_context.c',
266 'state_tracker/st_debug.c',
267 'state_tracker/st_draw.c',
268 'state_tracker/st_draw_feedback.c',
269 'state_tracker/st_extensions.c',
270 'state_tracker/st_format.c',
271 'state_tracker/st_glsl_to_tgsi.cpp',
272 'state_tracker/st_gen_mipmap.c',
273 'state_tracker/st_manager.c',
274 'state_tracker/st_mesa_to_tgsi.c',
275 'state_tracker/st_program.c',
276 'state_tracker/st_texture.c',
279 env.Append(YACCFLAGS = '-d')
280 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
281 program_parse = env.CFile('program/program_parse.tab.c',
282 'program/program_parse.y')
284 # Make program/program_parse.tab.h reacheable from the include path
285 env.Append(CPPPATH = [Dir('.').abspath])
288 'program/arbprogparse.c',
289 'program/hash_table.c',
290 'program/ir_to_mesa.cpp',
291 'program/nvfragparse.c',
292 'program/nvvertparse.c',
294 'program/program_parse_extra.c',
295 'program/prog_cache.c',
296 'program/prog_execute.c',
297 'program/prog_instruction.c',
298 'program/prog_noise.c',
299 'program/prog_optimize.c',
300 'program/prog_opt_constant_fold.c',
301 'program/prog_parameter.c',
302 'program/prog_parameter_layout.c',
303 'program/prog_print.c',
304 'program/prog_statevars.c',
305 'program/programopt.c',
306 'program/sampler.cpp',
307 'program/symbol_table.c',
308 'program/string_to_uint_map.cpp',
313 common_driver_sources = [
314 'drivers/common/driverfuncs.c',
315 'drivers/common/meta.c',
325 swrast_setup_sources +
326 common_driver_sources +
331 from sys import executable as python_cmd
333 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
335 # generate GLES sources
337 gles_sources += env.CodeGenerate(
338 target = 'main/api_exec_es1.c',
339 script = 'main/es_generator.py',
340 source = 'main/APIspec.xml',
341 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
343 gles_sources += env.CodeGenerate(
344 target = 'main/api_exec_es2.c',
345 script = 'main/es_generator.py',
346 source = 'main/APIspec.xml',
347 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
350 # generate GLES headers
351 GLAPI = '#src/mapi/glapi/'
353 gles_headers += env.CodeGenerate(
354 target = 'main/api_exec_es1_dispatch.h',
355 script = GLAPI + 'gen/gl_table.py',
356 source = GLAPI + 'gen/gl_and_es_API.xml',
357 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
359 gles_headers += env.CodeGenerate(
360 target = 'main/api_exec_es1_remap_helper.h',
361 script = GLAPI + 'gen/remap_helper.py',
362 source = GLAPI + 'gen/gl_and_es_API.xml',
363 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
365 gles_headers += env.CodeGenerate(
366 target = 'main/api_exec_es2_dispatch.h',
367 script = GLAPI + 'gen/gl_table.py',
368 source = GLAPI + 'gen/gl_and_es_API.xml',
369 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
371 gles_headers += env.CodeGenerate(
372 target = 'main/api_exec_es2_remap_helper.h',
373 script = GLAPI + 'gen/remap_helper.py',
374 source = GLAPI + 'gen/gl_and_es_API.xml',
375 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
378 env.Depends(gles_sources, gles_headers)
380 # gles_sources #include gles_headers with full path
381 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
383 mesa_sources += gles_sources
388 if env['gcc'] and env['platform'] != 'windows':
389 if env['machine'] == 'x86':
390 env.Append(CPPDEFINES = [
401 'x86/common_x86_asm.S',
405 'x86/x86_cliptest.S',
407 'x86/3dnow_xform1.S',
408 'x86/3dnow_xform2.S',
409 'x86/3dnow_xform3.S',
410 'x86/3dnow_xform4.S',
411 'x86/3dnow_normal.S',
417 'x86/read_rgba_span_x86.S',
419 elif env['machine'] == 'x86_64':
420 env.Append(CPPDEFINES = [
427 elif env['machine'] == 'ppc':
428 env.Append(CPPDEFINES = [
435 elif env['machine'] == 'sparc':
446 if env['machine'] in ('x86', 'x86_64'):
447 # See http://www.scons.org/wiki/UsingCodeGenerators
448 gen_matypes = env.Program(
449 target = 'gen_matypes',
450 source = 'x86/gen_matypes.c',
452 matypes = env.Command(
455 gen_matypes[0].abspath + ' > $TARGET',
457 # Add the dir containing the generated header (somewhere inside the
458 # build dir) to the include path
459 env.Append(CPPPATH = [matypes[0].dir])
464 def write_git_sha1_h_file(filename):
465 """Mesa looks for a git_sha1.h file at compile time in order to display
466 the current git hash id in the GL_VERSION string. This function tries
467 to retrieve the git hashid and write the header file. An empty file
468 will be created if anything goes wrong."""
470 args = [ 'git', 'log', '-n', '1', '--oneline' ]
472 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
474 # git log command didn't work
475 if not os.path.exists(filename):
476 # create an empty file if none already exists
477 f = open(filename, "w")
481 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
482 tempfile = "git_sha1.h.tmp"
483 f = open(tempfile, "w")
486 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
487 # The filename does not exist or it's different from the new file,
488 # so replace old file with new.
489 if os.path.exists(filename):
491 os.rename(tempfile, filename)
495 # Create the git_sha1.h header file
496 write_git_sha1_h_file("main/git_sha1.h")
497 # and update CPPPATH so the git_sha1.h header can be found
498 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
505 mesa = env.ConvenienceLibrary(
507 source = mesa_sources,
510 env.Alias('mesa', mesa)
514 SConscript('drivers/SConscript')