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',
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',
152 math_xform_sources = [
158 'swrast/s_aatriangle.c',
161 'swrast/s_atifragshader.c',
166 'swrast/s_copypix.c',
167 'swrast/s_context.c',
169 'swrast/s_drawpix.c',
170 'swrast/s_feedback.c',
172 'swrast/s_fragprog.c',
175 'swrast/s_masking.c',
177 'swrast/s_readpix.c',
179 'swrast/s_stencil.c',
180 'swrast/s_texcombine.c',
181 'swrast/s_texfetch.c',
182 'swrast/s_texfilter.c',
183 'swrast/s_texrender.c',
184 'swrast/s_texture.c',
185 'swrast/s_triangle.c',
189 swrast_setup_sources = [
190 'swrast_setup/ss_context.c',
191 'swrast_setup/ss_triangle.c',
199 'tnl/t_vb_program.c',
206 'tnl/t_vb_normals.c',
210 'tnl/t_vertex_sse.c',
211 'tnl/t_vertex_generic.c',
217 'vbo/vbo_exec_api.c',
218 'vbo/vbo_exec_array.c',
219 'vbo/vbo_exec_draw.c',
220 'vbo/vbo_exec_eval.c',
223 'vbo/vbo_split_copy.c',
224 'vbo/vbo_split_inplace.c',
226 'vbo/vbo_save_api.c',
227 'vbo/vbo_save_draw.c',
228 'vbo/vbo_save_loopback.c',
231 statetracker_sources = [
232 'state_tracker/st_atom.c',
233 'state_tracker/st_atom_blend.c',
234 'state_tracker/st_atom_clip.c',
235 'state_tracker/st_atom_constbuf.c',
236 'state_tracker/st_atom_depth.c',
237 'state_tracker/st_atom_framebuffer.c',
238 'state_tracker/st_atom_msaa.c',
239 'state_tracker/st_atom_pixeltransfer.c',
240 'state_tracker/st_atom_sampler.c',
241 'state_tracker/st_atom_scissor.c',
242 'state_tracker/st_atom_shader.c',
243 'state_tracker/st_atom_rasterizer.c',
244 'state_tracker/st_atom_stipple.c',
245 'state_tracker/st_atom_texture.c',
246 'state_tracker/st_atom_viewport.c',
247 'state_tracker/st_cb_accum.c',
248 'state_tracker/st_cb_bitmap.c',
249 'state_tracker/st_cb_blit.c',
250 'state_tracker/st_cb_bufferobjects.c',
251 'state_tracker/st_cb_clear.c',
252 'state_tracker/st_cb_condrender.c',
253 'state_tracker/st_cb_flush.c',
254 'state_tracker/st_cb_drawpixels.c',
255 'state_tracker/st_cb_drawtex.c',
256 'state_tracker/st_cb_eglimage.c',
257 'state_tracker/st_cb_fbo.c',
258 'state_tracker/st_cb_feedback.c',
259 'state_tracker/st_cb_program.c',
260 'state_tracker/st_cb_queryobj.c',
261 'state_tracker/st_cb_rasterpos.c',
262 'state_tracker/st_cb_readpixels.c',
263 'state_tracker/st_cb_syncobj.c',
264 'state_tracker/st_cb_strings.c',
265 'state_tracker/st_cb_texture.c',
266 'state_tracker/st_cb_texturebarrier.c',
267 'state_tracker/st_cb_viewport.c',
268 'state_tracker/st_cb_xformfb.c',
269 'state_tracker/st_context.c',
270 'state_tracker/st_debug.c',
271 'state_tracker/st_draw.c',
272 'state_tracker/st_draw_feedback.c',
273 'state_tracker/st_extensions.c',
274 'state_tracker/st_format.c',
275 'state_tracker/st_glsl_to_tgsi.cpp',
276 'state_tracker/st_gen_mipmap.c',
277 'state_tracker/st_manager.c',
278 'state_tracker/st_mesa_to_tgsi.c',
279 'state_tracker/st_program.c',
280 'state_tracker/st_texture.c',
283 env.Append(YACCFLAGS = '-d')
284 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
285 program_parse = env.CFile('program/program_parse.tab.c',
286 'program/program_parse.y')
288 # Make program/program_parse.tab.h reacheable from the include path
289 env.Append(CPPPATH = [Dir('.').abspath])
292 'program/arbprogparse.c',
293 'program/hash_table.c',
294 'program/ir_to_mesa.cpp',
295 'program/nvfragparse.c',
296 'program/nvvertparse.c',
298 'program/program_parse_extra.c',
299 'program/prog_cache.c',
300 'program/prog_execute.c',
301 'program/prog_instruction.c',
302 'program/prog_noise.c',
303 'program/prog_optimize.c',
304 'program/prog_opt_constant_fold.c',
305 'program/prog_parameter.c',
306 'program/prog_parameter_layout.c',
307 'program/prog_print.c',
308 'program/prog_statevars.c',
309 'program/programopt.c',
310 'program/sampler.cpp',
311 'program/symbol_table.c',
312 'program/string_to_uint_map.cpp',
317 common_driver_sources = [
318 'drivers/common/driverfuncs.c',
319 'drivers/common/meta.c',
330 swrast_setup_sources +
331 common_driver_sources +
336 from sys import executable as python_cmd
338 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
340 # generate GLES sources
342 gles_sources += env.CodeGenerate(
343 target = 'main/api_exec_es1.c',
344 script = 'main/es_generator.py',
345 source = 'main/APIspec.xml',
346 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
348 gles_sources += env.CodeGenerate(
349 target = 'main/api_exec_es2.c',
350 script = 'main/es_generator.py',
351 source = 'main/APIspec.xml',
352 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
355 # generate GLES headers
356 GLAPI = '#src/mapi/glapi/'
358 gles_headers += env.CodeGenerate(
359 target = 'main/api_exec_es1_dispatch.h',
360 script = GLAPI + 'gen/gl_table.py',
361 source = GLAPI + 'gen/gl_and_es_API.xml',
362 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
364 gles_headers += env.CodeGenerate(
365 target = 'main/api_exec_es1_remap_helper.h',
366 script = GLAPI + 'gen/remap_helper.py',
367 source = GLAPI + 'gen/gl_and_es_API.xml',
368 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
370 gles_headers += env.CodeGenerate(
371 target = 'main/api_exec_es2_dispatch.h',
372 script = GLAPI + 'gen/gl_table.py',
373 source = GLAPI + 'gen/gl_and_es_API.xml',
374 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
376 gles_headers += env.CodeGenerate(
377 target = 'main/api_exec_es2_remap_helper.h',
378 script = GLAPI + 'gen/remap_helper.py',
379 source = GLAPI + 'gen/gl_and_es_API.xml',
380 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
383 env.Depends(gles_sources, gles_headers)
385 # gles_sources #include gles_headers with full path
386 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
388 mesa_sources += gles_sources
393 if env['gcc'] and env['platform'] != 'windows':
394 if env['machine'] == 'x86':
395 env.Append(CPPDEFINES = [
406 'x86/common_x86_asm.S',
410 'x86/x86_cliptest.S',
412 'x86/3dnow_xform1.S',
413 'x86/3dnow_xform2.S',
414 'x86/3dnow_xform3.S',
415 'x86/3dnow_xform4.S',
416 'x86/3dnow_normal.S',
422 'x86/read_rgba_span_x86.S',
424 elif env['machine'] == 'x86_64':
425 env.Append(CPPDEFINES = [
432 elif env['machine'] == 'ppc':
433 env.Append(CPPDEFINES = [
440 elif env['machine'] == 'sparc':
451 if env['machine'] in ('x86', 'x86_64'):
452 # See http://www.scons.org/wiki/UsingCodeGenerators
453 gen_matypes = env.Program(
454 target = 'gen_matypes',
455 source = 'x86/gen_matypes.c',
457 matypes = env.Command(
460 gen_matypes[0].abspath + ' > $TARGET',
462 # Add the dir containing the generated header (somewhere inside the
463 # build dir) to the include path
464 env.Append(CPPPATH = [matypes[0].dir])
469 def write_git_sha1_h_file(filename):
470 """Mesa looks for a git_sha1.h file at compile time in order to display
471 the current git hash id in the GL_VERSION string. This function tries
472 to retrieve the git hashid and write the header file. An empty file
473 will be created if anything goes wrong."""
475 args = [ 'git', 'log', '-n', '1', '--oneline' ]
477 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
479 # git log command didn't work
480 if not os.path.exists(filename):
481 # create an empty file if none already exists
482 f = open(filename, "w")
486 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
487 tempfile = "git_sha1.h.tmp"
488 f = open(tempfile, "w")
491 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
492 # The filename does not exist or it's different from the new file,
493 # so replace old file with new.
494 if os.path.exists(filename):
496 os.rename(tempfile, filename)
500 # Create the git_sha1.h header file
501 write_git_sha1_h_file("main/git_sha1.h")
502 # and update CPPPATH so the git_sha1.h header can be found
503 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
510 mesa = env.ConvenienceLibrary(
512 source = mesa_sources,
515 env.Alias('mesa', mesa)
519 SConscript('drivers/SConscript')