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',
44 'main/api_validate.c',
47 'main/atifragshader.c',
62 'main/depthstencil.c',
74 'main/ff_fragment_shader.cpp',
75 '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',
123 'main/texgetimage.c',
130 'main/texturebarrier.c',
131 'main/transformfeedback.c',
140 'math/m_debug_clip.c',
141 'math/m_debug_norm.c',
142 'math/m_debug_xform.c',
145 'math/m_translate.c',
150 math_xform_sources = [
156 'swrast/s_aatriangle.c',
159 'swrast/s_atifragshader.c',
164 'swrast/s_copypix.c',
165 'swrast/s_context.c',
167 'swrast/s_drawpix.c',
168 'swrast/s_feedback.c',
170 'swrast/s_fragprog.c',
173 'swrast/s_masking.c',
175 'swrast/s_readpix.c',
177 'swrast/s_stencil.c',
178 'swrast/s_texcombine.c',
179 'swrast/s_texfetch.c',
180 'swrast/s_texfilter.c',
181 'swrast/s_texrender.c',
182 'swrast/s_texture.c',
183 'swrast/s_triangle.c',
187 swrast_setup_sources = [
188 'swrast_setup/ss_context.c',
189 'swrast_setup/ss_triangle.c',
197 'tnl/t_vb_program.c',
204 'tnl/t_vb_normals.c',
208 'tnl/t_vertex_sse.c',
209 'tnl/t_vertex_generic.c',
215 'vbo/vbo_exec_api.c',
216 'vbo/vbo_exec_array.c',
217 'vbo/vbo_exec_draw.c',
218 'vbo/vbo_exec_eval.c',
221 'vbo/vbo_split_copy.c',
222 'vbo/vbo_split_inplace.c',
224 'vbo/vbo_save_api.c',
225 'vbo/vbo_save_draw.c',
226 'vbo/vbo_save_loopback.c',
229 statetracker_sources = [
230 'state_tracker/st_atom.c',
231 'state_tracker/st_atom_blend.c',
232 'state_tracker/st_atom_clip.c',
233 'state_tracker/st_atom_constbuf.c',
234 'state_tracker/st_atom_depth.c',
235 'state_tracker/st_atom_framebuffer.c',
236 'state_tracker/st_atom_msaa.c',
237 'state_tracker/st_atom_pixeltransfer.c',
238 'state_tracker/st_atom_sampler.c',
239 'state_tracker/st_atom_scissor.c',
240 'state_tracker/st_atom_shader.c',
241 'state_tracker/st_atom_rasterizer.c',
242 'state_tracker/st_atom_stipple.c',
243 'state_tracker/st_atom_texture.c',
244 'state_tracker/st_atom_viewport.c',
245 'state_tracker/st_cb_accum.c',
246 'state_tracker/st_cb_bitmap.c',
247 'state_tracker/st_cb_blit.c',
248 'state_tracker/st_cb_bufferobjects.c',
249 'state_tracker/st_cb_clear.c',
250 'state_tracker/st_cb_condrender.c',
251 'state_tracker/st_cb_flush.c',
252 'state_tracker/st_cb_drawpixels.c',
253 'state_tracker/st_cb_drawtex.c',
254 'state_tracker/st_cb_eglimage.c',
255 'state_tracker/st_cb_fbo.c',
256 'state_tracker/st_cb_feedback.c',
257 'state_tracker/st_cb_program.c',
258 'state_tracker/st_cb_queryobj.c',
259 'state_tracker/st_cb_rasterpos.c',
260 'state_tracker/st_cb_readpixels.c',
261 'state_tracker/st_cb_syncobj.c',
262 'state_tracker/st_cb_strings.c',
263 'state_tracker/st_cb_texture.c',
264 'state_tracker/st_cb_texturebarrier.c',
265 'state_tracker/st_cb_viewport.c',
266 'state_tracker/st_cb_xformfb.c',
267 'state_tracker/st_context.c',
268 'state_tracker/st_debug.c',
269 'state_tracker/st_draw.c',
270 'state_tracker/st_draw_feedback.c',
271 'state_tracker/st_extensions.c',
272 'state_tracker/st_format.c',
273 'state_tracker/st_glsl_to_tgsi.cpp',
274 'state_tracker/st_gen_mipmap.c',
275 'state_tracker/st_manager.c',
276 'state_tracker/st_mesa_to_tgsi.c',
277 'state_tracker/st_program.c',
278 'state_tracker/st_texture.c',
281 env.Append(YACCFLAGS = '-d')
282 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
283 program_parse = env.CFile('program/program_parse.tab.c',
284 'program/program_parse.y')
286 # Make program/program_parse.tab.h reacheable from the include path
287 env.Append(CPPPATH = [Dir('.').abspath])
290 'program/arbprogparse.c',
291 'program/hash_table.c',
292 'program/ir_to_mesa.cpp',
293 'program/nvfragparse.c',
294 'program/nvvertparse.c',
296 'program/program_parse_extra.c',
297 'program/prog_cache.c',
298 'program/prog_execute.c',
299 'program/prog_instruction.c',
300 'program/prog_noise.c',
301 'program/prog_optimize.c',
302 'program/prog_opt_constant_fold.c',
303 'program/prog_parameter.c',
304 'program/prog_parameter_layout.c',
305 'program/prog_print.c',
306 'program/prog_statevars.c',
307 'program/prog_uniform.c',
308 'program/programopt.c',
309 'program/sampler.cpp',
310 'program/symbol_table.c',
311 'program/string_to_uint_map.cpp',
316 common_driver_sources = [
317 'drivers/common/driverfuncs.c',
318 'drivers/common/meta.c',
329 swrast_setup_sources +
330 common_driver_sources +
335 from sys import executable as python_cmd
337 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
339 # generate GLES sources
341 gles_sources += env.CodeGenerate(
342 target = 'main/api_exec_es1.c',
343 script = 'main/es_generator.py',
344 source = 'main/APIspec.xml',
345 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
347 gles_sources += env.CodeGenerate(
348 target = 'main/api_exec_es2.c',
349 script = 'main/es_generator.py',
350 source = 'main/APIspec.xml',
351 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
354 # generate GLES headers
355 GLAPI = '#src/mapi/glapi/'
357 gles_headers += env.CodeGenerate(
358 target = 'main/api_exec_es1_dispatch.h',
359 script = GLAPI + 'gen/gl_table.py',
360 source = GLAPI + 'gen/gl_and_es_API.xml',
361 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
363 gles_headers += env.CodeGenerate(
364 target = 'main/api_exec_es1_remap_helper.h',
365 script = GLAPI + 'gen/remap_helper.py',
366 source = GLAPI + 'gen/gl_and_es_API.xml',
367 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
369 gles_headers += env.CodeGenerate(
370 target = 'main/api_exec_es2_dispatch.h',
371 script = GLAPI + 'gen/gl_table.py',
372 source = GLAPI + 'gen/gl_and_es_API.xml',
373 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
375 gles_headers += env.CodeGenerate(
376 target = 'main/api_exec_es2_remap_helper.h',
377 script = GLAPI + 'gen/remap_helper.py',
378 source = GLAPI + 'gen/gl_and_es_API.xml',
379 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
382 env.Depends(gles_sources, gles_headers)
384 # gles_sources #include gles_headers with full path
385 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
387 mesa_sources += gles_sources
392 if env['gcc'] and env['platform'] != 'windows':
393 if env['machine'] == 'x86':
394 env.Append(CPPDEFINES = [
405 'x86/common_x86_asm.S',
409 'x86/x86_cliptest.S',
411 'x86/3dnow_xform1.S',
412 'x86/3dnow_xform2.S',
413 'x86/3dnow_xform3.S',
414 'x86/3dnow_xform4.S',
415 'x86/3dnow_normal.S',
421 'x86/read_rgba_span_x86.S',
423 elif env['machine'] == 'x86_64':
424 env.Append(CPPDEFINES = [
431 elif env['machine'] == 'ppc':
432 env.Append(CPPDEFINES = [
439 elif env['machine'] == 'sparc':
450 if env['machine'] in ('x86', 'x86_64'):
451 # See http://www.scons.org/wiki/UsingCodeGenerators
452 gen_matypes = env.Program(
453 target = 'gen_matypes',
454 source = 'x86/gen_matypes.c',
456 matypes = env.Command(
459 gen_matypes[0].abspath + ' > $TARGET',
461 # Add the dir containing the generated header (somewhere inside the
462 # build dir) to the include path
463 env.Append(CPPPATH = [matypes[0].dir])
468 def write_git_sha1_h_file(filename):
469 """Mesa looks for a git_sha1.h file at compile time in order to display
470 the current git hash id in the GL_VERSION string. This function tries
471 to retrieve the git hashid and write the header file. An empty file
472 will be created if anything goes wrong."""
474 args = [ 'git', 'log', '-n', '1', '--oneline' ]
476 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
478 # git log command didn't work
479 if not os.path.exists(filename):
480 # create an empty file if none already exists
481 f = open(filename, "w")
485 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
486 tempfile = "git_sha1.h.tmp"
487 f = open(tempfile, "w")
490 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
491 # The filename does not exist or it's different from the new file,
492 # so replace old file with new.
493 if os.path.exists(filename):
495 os.rename(tempfile, filename)
499 # Create the git_sha1.h header file
500 write_git_sha1_h_file("main/git_sha1.h")
501 # and update CPPPATH so the git_sha1.h header can be found
502 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
509 mesa = env.ConvenienceLibrary(
511 source = mesa_sources,
514 env.Alias('mesa', mesa)
518 SConscript('drivers/SConscript')