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',
61 'main/depthstencil.c',
73 'main/ff_fragment_shader.cpp',
74 'main/ffvertex_prog.c',
78 'main/format_unpack.c',
98 'main/pixeltransfer.c',
101 'main/querymatrix.c',
106 'main/renderbuffer.c',
111 'main/shader_query.cpp',
116 'main/texcompress.c',
117 'main/texcompress_rgtc.c',
118 'main/texcompress_s3tc.c',
119 'main/texcompress_fxt1.c',
120 'main/texcompress_etc.c',
124 'main/texgetimage.c',
132 'main/texturebarrier.c',
133 'main/transformfeedback.c',
134 'main/uniform_query.cpp',
143 'math/m_debug_clip.c',
144 'math/m_debug_norm.c',
145 'math/m_debug_xform.c',
148 'math/m_translate.c',
155 'swrast/s_aatriangle.c',
158 'swrast/s_atifragshader.c',
163 'swrast/s_copypix.c',
164 'swrast/s_context.c',
166 'swrast/s_drawpix.c',
167 'swrast/s_feedback.c',
169 'swrast/s_fragprog.c',
172 'swrast/s_masking.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_accum.c',
245 'state_tracker/st_cb_bitmap.c',
246 'state_tracker/st_cb_blit.c',
247 'state_tracker/st_cb_bufferobjects.c',
248 'state_tracker/st_cb_clear.c',
249 'state_tracker/st_cb_condrender.c',
250 'state_tracker/st_cb_flush.c',
251 'state_tracker/st_cb_drawpixels.c',
252 'state_tracker/st_cb_drawtex.c',
253 'state_tracker/st_cb_eglimage.c',
254 'state_tracker/st_cb_fbo.c',
255 'state_tracker/st_cb_feedback.c',
256 'state_tracker/st_cb_program.c',
257 'state_tracker/st_cb_queryobj.c',
258 'state_tracker/st_cb_rasterpos.c',
259 'state_tracker/st_cb_readpixels.c',
260 'state_tracker/st_cb_syncobj.c',
261 'state_tracker/st_cb_strings.c',
262 'state_tracker/st_cb_texture.c',
263 'state_tracker/st_cb_texturebarrier.c',
264 'state_tracker/st_cb_viewport.c',
265 'state_tracker/st_cb_xformfb.c',
266 'state_tracker/st_context.c',
267 'state_tracker/st_debug.c',
268 'state_tracker/st_draw.c',
269 'state_tracker/st_draw_feedback.c',
270 'state_tracker/st_extensions.c',
271 'state_tracker/st_format.c',
272 'state_tracker/st_glsl_to_tgsi.cpp',
273 'state_tracker/st_gen_mipmap.c',
274 'state_tracker/st_manager.c',
275 'state_tracker/st_mesa_to_tgsi.c',
276 'state_tracker/st_program.c',
277 'state_tracker/st_texture.c',
280 env.Append(YACCFLAGS = '-d')
281 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
282 program_parse = env.CFile('program/program_parse.tab.c',
283 'program/program_parse.y')
285 # Make program/program_parse.tab.h reacheable from the include path
286 env.Append(CPPPATH = [Dir('.').abspath])
289 'program/arbprogparse.c',
290 'program/hash_table.c',
291 'program/ir_to_mesa.cpp',
292 'program/nvfragparse.c',
293 'program/nvvertparse.c',
295 'program/program_parse_extra.c',
296 'program/prog_cache.c',
297 'program/prog_execute.c',
298 'program/prog_instruction.c',
299 'program/prog_noise.c',
300 'program/prog_optimize.c',
301 'program/prog_opt_constant_fold.c',
302 'program/prog_parameter.c',
303 'program/prog_parameter_layout.c',
304 'program/prog_print.c',
305 'program/prog_statevars.c',
306 'program/programopt.c',
307 'program/sampler.cpp',
308 'program/symbol_table.c',
309 'program/string_to_uint_map.cpp',
314 common_driver_sources = [
315 'drivers/common/driverfuncs.c',
316 'drivers/common/meta.c',
326 swrast_setup_sources +
327 common_driver_sources +
332 from sys import executable as python_cmd
334 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
336 # generate GLES sources
338 gles_sources += env.CodeGenerate(
339 target = 'main/api_exec_es1.c',
340 script = 'main/es_generator.py',
341 source = 'main/APIspec.xml',
342 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
344 gles_sources += env.CodeGenerate(
345 target = 'main/api_exec_es2.c',
346 script = 'main/es_generator.py',
347 source = 'main/APIspec.xml',
348 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
351 # generate GLES headers
352 GLAPI = '#src/mapi/glapi/'
354 gles_headers += env.CodeGenerate(
355 target = 'main/api_exec_es1_dispatch.h',
356 script = GLAPI + 'gen/gl_table.py',
357 source = GLAPI + 'gen/gl_and_es_API.xml',
358 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
360 gles_headers += env.CodeGenerate(
361 target = 'main/api_exec_es1_remap_helper.h',
362 script = GLAPI + 'gen/remap_helper.py',
363 source = GLAPI + 'gen/gl_and_es_API.xml',
364 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
366 gles_headers += env.CodeGenerate(
367 target = 'main/api_exec_es2_dispatch.h',
368 script = GLAPI + 'gen/gl_table.py',
369 source = GLAPI + 'gen/gl_and_es_API.xml',
370 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
372 gles_headers += env.CodeGenerate(
373 target = 'main/api_exec_es2_remap_helper.h',
374 script = GLAPI + 'gen/remap_helper.py',
375 source = GLAPI + 'gen/gl_and_es_API.xml',
376 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
379 env.Depends(gles_sources, gles_headers)
381 # gles_sources #include gles_headers with full path
382 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
384 mesa_sources += gles_sources
389 if env['gcc'] and env['platform'] != 'windows':
390 if env['machine'] == 'x86':
391 env.Append(CPPDEFINES = [
402 'x86/common_x86_asm.S',
406 'x86/x86_cliptest.S',
408 'x86/3dnow_xform1.S',
409 'x86/3dnow_xform2.S',
410 'x86/3dnow_xform3.S',
411 'x86/3dnow_xform4.S',
412 'x86/3dnow_normal.S',
418 'x86/read_rgba_span_x86.S',
420 elif env['machine'] == 'x86_64':
421 env.Append(CPPDEFINES = [
428 elif env['machine'] == 'ppc':
429 env.Append(CPPDEFINES = [
436 elif env['machine'] == 'sparc':
447 if env['machine'] in ('x86', 'x86_64'):
448 # See http://www.scons.org/wiki/UsingCodeGenerators
449 gen_matypes = env.Program(
450 target = 'gen_matypes',
451 source = 'x86/gen_matypes.c',
453 matypes = env.Command(
456 gen_matypes[0].abspath + ' > $TARGET',
458 # Add the dir containing the generated header (somewhere inside the
459 # build dir) to the include path
460 env.Append(CPPPATH = [matypes[0].dir])
465 def write_git_sha1_h_file(filename):
466 """Mesa looks for a git_sha1.h file at compile time in order to display
467 the current git hash id in the GL_VERSION string. This function tries
468 to retrieve the git hashid and write the header file. An empty file
469 will be created if anything goes wrong."""
471 args = [ 'git', 'log', '-n', '1', '--oneline' ]
473 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
475 # git log command didn't work
476 if not os.path.exists(filename):
477 # create an empty file if none already exists
478 f = open(filename, "w")
482 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
483 tempfile = "git_sha1.h.tmp"
484 f = open(tempfile, "w")
487 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
488 # The filename does not exist or it's different from the new file,
489 # so replace old file with new.
490 if os.path.exists(filename):
492 os.rename(tempfile, filename)
496 # Create the git_sha1.h header file
497 write_git_sha1_h_file("main/git_sha1.h")
498 # and update CPPPATH so the git_sha1.h header can be found
499 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
506 mesa = env.ConvenienceLibrary(
508 source = mesa_sources,
511 env.Alias('mesa', mesa)
515 SConscript('drivers/SConscript')