scons: Add uniform_query.cpp to SConscript.
[mesa.git] / src / mesa / SConscript
1 #######################################################################
2 # SConscript for Mesa
3
4
5 Import('*')
6 import filecmp
7 import os
8 import subprocess
9
10 env = env.Clone()
11
12 env.Append(CPPPATH = [
13 '#/src/mapi',
14 '#/src/glsl',
15 '#/src/mesa',
16 ])
17
18 env.Append(CPPDEFINES = [
19 'FEATURE_GL=1',
20 ])
21
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
26 ])
27 if not env['gles']:
28 # prevent _glapi_* from being declared __declspec(dllimport)
29 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
30 else:
31 env.Append(CPPDEFINES = [
32 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
33 ])
34
35 #
36 # Source files
37 #
38
39 main_sources = [
40 'main/api_arrayelt.c',
41 'main/api_exec.c',
42 'main/api_loopback.c',
43 'main/api_noop.c',
44 'main/api_validate.c',
45 'main/accum.c',
46 'main/arbprogram.c',
47 'main/atifragshader.c',
48 'main/attrib.c',
49 'main/arrayobj.c',
50 'main/blend.c',
51 'main/bufferobj.c',
52 'main/buffers.c',
53 'main/clear.c',
54 'main/clip.c',
55 'main/colortab.c',
56 'main/condrender.c',
57 'main/context.c',
58 'main/convolve.c',
59 'main/cpuinfo.c',
60 'main/debug.c',
61 'main/depth.c',
62 'main/depthstencil.c',
63 'main/dlist.c',
64 'main/dlopen.c',
65 'main/drawpix.c',
66 'main/drawtex.c',
67 'main/enable.c',
68 'main/enums.c',
69 'main/eval.c',
70 'main/execmem.c',
71 'main/extensions.c',
72 'main/fbobject.c',
73 'main/feedback.c',
74 'main/ff_fragment_shader.cpp',
75 'main/ffvertex_prog.c',
76 'main/fog.c',
77 'main/formats.c',
78 'main/format_unpack.c',
79 'main/framebuffer.c',
80 'main/get.c',
81 'main/getstring.c',
82 'main/hash.c',
83 'main/hint.c',
84 'main/histogram.c',
85 'main/image.c',
86 'main/imports.c',
87 'main/light.c',
88 'main/lines.c',
89 'main/matrix.c',
90 'main/mipmap.c',
91 'main/mm.c',
92 'main/multisample.c',
93 'main/nvprogram.c',
94 'main/pack.c',
95 'main/pbo.c',
96 'main/pixel.c',
97 'main/pixelstore.c',
98 'main/pixeltransfer.c',
99 'main/points.c',
100 'main/polygon.c',
101 'main/querymatrix.c',
102 'main/queryobj.c',
103 'main/rastpos.c',
104 'main/readpix.c',
105 'main/remap.c',
106 'main/renderbuffer.c',
107 'main/samplerobj.c',
108 'main/scissor.c',
109 'main/shaderapi.c',
110 'main/shaderobj.c',
111 'main/shader_query.cpp',
112 'main/shared.c',
113 'main/state.c',
114 'main/stencil.c',
115 'main/syncobj.c',
116 'main/texcompress.c',
117 'main/texcompress_rgtc.c',
118 'main/texcompress_s3tc.c',
119 'main/texcompress_fxt1.c',
120 'main/texenv.c',
121 'main/texformat.c',
122 'main/texgen.c',
123 'main/texgetimage.c',
124 'main/teximage.c',
125 'main/texobj.c',
126 'main/texpal.c',
127 'main/texparam.c',
128 'main/texstate.c',
129 'main/texstore.c',
130 'main/texturebarrier.c',
131 'main/transformfeedback.c',
132 'main/uniform_query.cpp',
133 'main/uniforms.c',
134 'main/varray.c',
135 'main/version.c',
136 'main/viewport.c',
137 'main/vtxfmt.c',
138 ]
139
140 math_sources = [
141 'math/m_debug_clip.c',
142 'math/m_debug_norm.c',
143 'math/m_debug_xform.c',
144 'math/m_eval.c',
145 'math/m_matrix.c',
146 'math/m_translate.c',
147 'math/m_vector.c',
148 'math/m_xform.c',
149 ]
150
151 math_xform_sources = [
152 'math/m_xform.c'
153 ]
154
155 swrast_sources = [
156 'swrast/s_aaline.c',
157 'swrast/s_aatriangle.c',
158 'swrast/s_accum.c',
159 'swrast/s_alpha.c',
160 'swrast/s_atifragshader.c',
161 'swrast/s_bitmap.c',
162 'swrast/s_blend.c',
163 'swrast/s_blit.c',
164 'swrast/s_clear.c',
165 'swrast/s_copypix.c',
166 'swrast/s_context.c',
167 'swrast/s_depth.c',
168 'swrast/s_drawpix.c',
169 'swrast/s_feedback.c',
170 'swrast/s_fog.c',
171 'swrast/s_fragprog.c',
172 'swrast/s_lines.c',
173 'swrast/s_logic.c',
174 'swrast/s_masking.c',
175 'swrast/s_points.c',
176 'swrast/s_readpix.c',
177 'swrast/s_span.c',
178 'swrast/s_stencil.c',
179 'swrast/s_texcombine.c',
180 'swrast/s_texfetch.c',
181 'swrast/s_texfilter.c',
182 'swrast/s_texrender.c',
183 'swrast/s_texture.c',
184 'swrast/s_triangle.c',
185 'swrast/s_zoom.c',
186 ]
187
188 swrast_setup_sources = [
189 'swrast_setup/ss_context.c',
190 'swrast_setup/ss_triangle.c',
191 ]
192
193 tnl_sources = [
194 'tnl/t_context.c',
195 'tnl/t_pipeline.c',
196 'tnl/t_draw.c',
197 'tnl/t_rasterpos.c',
198 'tnl/t_vb_program.c',
199 'tnl/t_vb_render.c',
200 'tnl/t_vb_texgen.c',
201 'tnl/t_vb_texmat.c',
202 'tnl/t_vb_vertex.c',
203 'tnl/t_vb_fog.c',
204 'tnl/t_vb_light.c',
205 'tnl/t_vb_normals.c',
206 'tnl/t_vb_points.c',
207 'tnl/t_vp_build.c',
208 'tnl/t_vertex.c',
209 'tnl/t_vertex_sse.c',
210 'tnl/t_vertex_generic.c',
211 ]
212
213 vbo_sources = [
214 'vbo/vbo_context.c',
215 'vbo/vbo_exec.c',
216 'vbo/vbo_exec_api.c',
217 'vbo/vbo_exec_array.c',
218 'vbo/vbo_exec_draw.c',
219 'vbo/vbo_exec_eval.c',
220 'vbo/vbo_rebase.c',
221 'vbo/vbo_split.c',
222 'vbo/vbo_split_copy.c',
223 'vbo/vbo_split_inplace.c',
224 'vbo/vbo_save.c',
225 'vbo/vbo_save_api.c',
226 'vbo/vbo_save_draw.c',
227 'vbo/vbo_save_loopback.c',
228 ]
229
230 statetracker_sources = [
231 'state_tracker/st_atom.c',
232 'state_tracker/st_atom_blend.c',
233 'state_tracker/st_atom_clip.c',
234 'state_tracker/st_atom_constbuf.c',
235 'state_tracker/st_atom_depth.c',
236 'state_tracker/st_atom_framebuffer.c',
237 'state_tracker/st_atom_msaa.c',
238 'state_tracker/st_atom_pixeltransfer.c',
239 'state_tracker/st_atom_sampler.c',
240 'state_tracker/st_atom_scissor.c',
241 'state_tracker/st_atom_shader.c',
242 'state_tracker/st_atom_rasterizer.c',
243 'state_tracker/st_atom_stipple.c',
244 'state_tracker/st_atom_texture.c',
245 'state_tracker/st_atom_viewport.c',
246 'state_tracker/st_cb_accum.c',
247 'state_tracker/st_cb_bitmap.c',
248 'state_tracker/st_cb_blit.c',
249 'state_tracker/st_cb_bufferobjects.c',
250 'state_tracker/st_cb_clear.c',
251 'state_tracker/st_cb_condrender.c',
252 'state_tracker/st_cb_flush.c',
253 'state_tracker/st_cb_drawpixels.c',
254 'state_tracker/st_cb_drawtex.c',
255 'state_tracker/st_cb_eglimage.c',
256 'state_tracker/st_cb_fbo.c',
257 'state_tracker/st_cb_feedback.c',
258 'state_tracker/st_cb_program.c',
259 'state_tracker/st_cb_queryobj.c',
260 'state_tracker/st_cb_rasterpos.c',
261 'state_tracker/st_cb_readpixels.c',
262 'state_tracker/st_cb_syncobj.c',
263 'state_tracker/st_cb_strings.c',
264 'state_tracker/st_cb_texture.c',
265 'state_tracker/st_cb_texturebarrier.c',
266 'state_tracker/st_cb_viewport.c',
267 'state_tracker/st_cb_xformfb.c',
268 'state_tracker/st_context.c',
269 'state_tracker/st_debug.c',
270 'state_tracker/st_draw.c',
271 'state_tracker/st_draw_feedback.c',
272 'state_tracker/st_extensions.c',
273 'state_tracker/st_format.c',
274 'state_tracker/st_glsl_to_tgsi.cpp',
275 'state_tracker/st_gen_mipmap.c',
276 'state_tracker/st_manager.c',
277 'state_tracker/st_mesa_to_tgsi.c',
278 'state_tracker/st_program.c',
279 'state_tracker/st_texture.c',
280 ]
281
282 env.Append(YACCFLAGS = '-d')
283 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
284 program_parse = env.CFile('program/program_parse.tab.c',
285 'program/program_parse.y')
286
287 # Make program/program_parse.tab.h reacheable from the include path
288 env.Append(CPPPATH = [Dir('.').abspath])
289
290 program_sources = [
291 'program/arbprogparse.c',
292 'program/hash_table.c',
293 'program/ir_to_mesa.cpp',
294 'program/nvfragparse.c',
295 'program/nvvertparse.c',
296 'program/program.c',
297 'program/program_parse_extra.c',
298 'program/prog_cache.c',
299 'program/prog_execute.c',
300 'program/prog_instruction.c',
301 'program/prog_noise.c',
302 'program/prog_optimize.c',
303 'program/prog_opt_constant_fold.c',
304 'program/prog_parameter.c',
305 'program/prog_parameter_layout.c',
306 'program/prog_print.c',
307 'program/prog_statevars.c',
308 'program/prog_uniform.c',
309 'program/programopt.c',
310 'program/sampler.cpp',
311 'program/symbol_table.c',
312 'program/string_to_uint_map.cpp',
313 program_lex,
314 program_parse[0],
315 ]
316
317 common_driver_sources = [
318 'drivers/common/driverfuncs.c',
319 'drivers/common/meta.c',
320 ]
321
322 mesa_sources = (
323 main_sources +
324 math_sources +
325 math_xform_sources +
326 program_sources +
327 vbo_sources +
328 tnl_sources +
329 swrast_sources +
330 swrast_setup_sources +
331 common_driver_sources +
332 statetracker_sources
333 )
334
335 if env['gles']:
336 from sys import executable as python_cmd
337
338 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
339
340 # generate GLES sources
341 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'
347 )
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'
353 )
354
355 # generate GLES headers
356 GLAPI = '#src/mapi/glapi/'
357 gles_headers = []
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',
363 )
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',
369 )
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',
375 )
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',
381 )
382
383 env.Depends(gles_sources, gles_headers)
384
385 # gles_sources #include gles_headers with full path
386 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
387
388 mesa_sources += gles_sources
389
390 #
391 # Assembly sources
392 #
393 if env['gcc'] and env['platform'] != 'windows':
394 if env['machine'] == 'x86':
395 env.Append(CPPDEFINES = [
396 'USE_X86_ASM',
397 'USE_MMX_ASM',
398 'USE_3DNOW_ASM',
399 'USE_SSE_ASM',
400 ])
401 mesa_sources += [
402 'x86/common_x86.c',
403 'x86/x86_xform.c',
404 'x86/3dnow.c',
405 'x86/sse.c',
406 'x86/common_x86_asm.S',
407 'x86/x86_xform2.S',
408 'x86/x86_xform3.S',
409 'x86/x86_xform4.S',
410 'x86/x86_cliptest.S',
411 'x86/mmx_blend.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',
417 'x86/sse_xform1.S',
418 'x86/sse_xform2.S',
419 'x86/sse_xform3.S',
420 'x86/sse_xform4.S',
421 'x86/sse_normal.S',
422 'x86/read_rgba_span_x86.S',
423 ]
424 elif env['machine'] == 'x86_64':
425 env.Append(CPPDEFINES = [
426 'USE_X86_64_ASM',
427 ])
428 mesa_sources += [
429 'x86-64/x86-64.c',
430 'x86-64/xform4.S',
431 ]
432 elif env['machine'] == 'ppc':
433 env.Append(CPPDEFINES = [
434 'USE_PPC_ASM',
435 'USE_VMX_ASM',
436 ])
437 mesa_sources += [
438 'ppc/common_ppc.c',
439 ]
440 elif env['machine'] == 'sparc':
441 mesa_sources += [
442 'sparc/sparc.c',
443 'sparc/clip.S',
444 'sparc/norm.S',
445 'sparc/xform.S',
446 ]
447 else:
448 pass
449
450 # Generate matypes.h
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',
456 )
457 matypes = env.Command(
458 'matypes.h',
459 gen_matypes,
460 gen_matypes[0].abspath + ' > $TARGET',
461 )
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])
465
466
467
468
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."""
474
475 args = [ 'git', 'log', '-n', '1', '--oneline' ]
476 try:
477 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
478 except:
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")
483 f.close()
484 return
485
486 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
487 tempfile = "git_sha1.h.tmp"
488 f = open(tempfile, "w")
489 f.write(commit)
490 f.close()
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):
495 os.remove(filename)
496 os.rename(tempfile, filename)
497 return
498
499
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"])
504
505
506 #
507 # Libraries
508 #
509
510 mesa = env.ConvenienceLibrary(
511 target = 'mesa',
512 source = mesa_sources,
513 )
514
515 env.Alias('mesa', mesa)
516
517 Export('mesa')
518
519 SConscript('drivers/SConscript')