blob: 595f8fc8f288e252fefa07aa3d31c9f3eb9ff656 [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
José Fonseca33ceb672008-02-18 10:52:44 +00002# SConscript for Mesa
José Fonsecac42e6252008-01-31 13:14:35 +09003
4
5Import('*')
Brian Paulf83af362011-09-28 08:15:22 -06006import filecmp
7import os
8import subprocess
José Fonsecac42e6252008-01-31 13:14:35 +09009
José Fonseca601498a2010-11-01 13:30:22 +000010env = env.Clone()
José Fonsecab9da3792008-02-19 15:07:53 +090011
José Fonseca601498a2010-11-01 13:30:22 +000012env.Append(CPPPATH = [
13 '#/src/mapi',
14 '#/src/glsl',
15 '#/src/mesa',
16])
José Fonseca2105b612009-01-06 16:20:12 +000017
Chia-I Wubb770af2011-01-14 17:50:29 +080018env.Append(CPPDEFINES = [
19 'FEATURE_GL=1',
20])
21
José Fonseca601498a2010-11-01 13:30:22 +000022if 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
José Fonseca601498a2010-11-01 13:30:22 +000026 ])
Chia-I Wubb770af2011-01-14 17:50:29 +080027 if not env['gles']:
28 # prevent _glapi_* from being declared __declspec(dllimport)
29 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
Chia-I Wubb045d32010-11-20 17:47:11 -080030else:
31 env.Append(CPPDEFINES = [
32 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
33 ])
José Fonseca5c9c6b02008-06-04 23:56:57 +090034
José Fonseca601498a2010-11-01 13:30:22 +000035#
36# Source files
37#
Michal Krol3371f7e2009-11-25 14:52:21 +010038
José Fonseca601498a2010-11-01 13:30:22 +000039main_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',
Vinson Leedee6eaf2011-03-11 13:32:41 -080074 'main/ff_fragment_shader.cpp',
José Fonseca601498a2010-11-01 13:30:22 +000075 'main/ffvertex_prog.c',
76 'main/fog.c',
77 'main/formats.c',
Brian Paul730952a2011-09-08 20:16:18 -060078 'main/format_unpack.c',
José Fonseca601498a2010-11-01 13:30:22 +000079 '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',
Brian Paulb70610b2011-02-28 18:24:35 -070095 'main/pbo.c',
José Fonseca601498a2010-11-01 13:30:22 +000096 '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',
Brian Paul34a5d3b2011-04-10 12:48:28 -0600107 'main/samplerobj.c',
José Fonseca601498a2010-11-01 13:30:22 +0000108 'main/scissor.c',
109 'main/shaderapi.c',
110 'main/shaderobj.c',
111 'main/shared.c',
112 'main/state.c',
113 'main/stencil.c',
114 'main/syncobj.c',
115 'main/texcompress.c',
Vinson Lee93893132011-02-27 23:17:49 -0800116 'main/texcompress_rgtc.c',
José Fonseca601498a2010-11-01 13:30:22 +0000117 'main/texcompress_s3tc.c',
118 'main/texcompress_fxt1.c',
119 'main/texenv.c',
José Fonseca601498a2010-11-01 13:30:22 +0000120 'main/texformat.c',
121 'main/texgen.c',
122 'main/texgetimage.c',
123 'main/teximage.c',
124 'main/texobj.c',
125 'main/texpal.c',
126 'main/texparam.c',
José Fonseca601498a2010-11-01 13:30:22 +0000127 'main/texstate.c',
128 'main/texstore.c',
Marek Olšákd0e805e2011-03-15 16:25:16 +0100129 'main/texturebarrier.c',
José Fonseca601498a2010-11-01 13:30:22 +0000130 'main/transformfeedback.c',
131 'main/uniforms.c',
132 'main/varray.c',
133 'main/version.c',
134 'main/viewport.c',
135 'main/vtxfmt.c',
136]
José Fonseca5c9c6b02008-06-04 23:56:57 +0900137
José Fonseca601498a2010-11-01 13:30:22 +0000138math_sources = [
139 'math/m_debug_clip.c',
140 'math/m_debug_norm.c',
141 'math/m_debug_xform.c',
142 'math/m_eval.c',
143 'math/m_matrix.c',
144 'math/m_translate.c',
145 'math/m_vector.c',
146 'math/m_xform.c',
147]
148
José Fonseca8e8a56e2011-04-23 12:22:59 +0100149math_xform_sources = [
150 'math/m_xform.c'
151]
152
153swrast_sources = [
154 'swrast/s_aaline.c',
155 'swrast/s_aatriangle.c',
156 'swrast/s_accum.c',
157 'swrast/s_alpha.c',
158 'swrast/s_atifragshader.c',
159 'swrast/s_bitmap.c',
160 'swrast/s_blend.c',
161 'swrast/s_blit.c',
162 'swrast/s_clear.c',
163 'swrast/s_copypix.c',
164 'swrast/s_context.c',
165 'swrast/s_depth.c',
166 'swrast/s_drawpix.c',
167 'swrast/s_feedback.c',
168 'swrast/s_fog.c',
169 'swrast/s_fragprog.c',
170 'swrast/s_lines.c',
171 'swrast/s_logic.c',
172 'swrast/s_masking.c',
173 'swrast/s_points.c',
174 'swrast/s_readpix.c',
175 'swrast/s_span.c',
176 'swrast/s_stencil.c',
177 'swrast/s_texcombine.c',
Brian Paulbaeefef2011-09-17 14:50:48 -0600178 'swrast/s_texfetch.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100179 'swrast/s_texfilter.c',
Brian Paul755f2e22011-06-13 13:44:35 -0600180 'swrast/s_texrender.c',
Brian Paul6f1846e2011-08-29 11:37:13 -0600181 'swrast/s_texture.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100182 'swrast/s_triangle.c',
183 'swrast/s_zoom.c',
184]
185
186swrast_setup_sources = [
187 'swrast_setup/ss_context.c',
188 'swrast_setup/ss_triangle.c',
189]
190
191tnl_sources = [
192 'tnl/t_context.c',
193 'tnl/t_pipeline.c',
194 'tnl/t_draw.c',
195 'tnl/t_rasterpos.c',
196 'tnl/t_vb_program.c',
197 'tnl/t_vb_render.c',
198 'tnl/t_vb_texgen.c',
199 'tnl/t_vb_texmat.c',
200 'tnl/t_vb_vertex.c',
201 'tnl/t_vb_fog.c',
202 'tnl/t_vb_light.c',
203 'tnl/t_vb_normals.c',
204 'tnl/t_vb_points.c',
205 'tnl/t_vp_build.c',
206 'tnl/t_vertex.c',
207 'tnl/t_vertex_sse.c',
208 'tnl/t_vertex_generic.c',
209]
210
José Fonseca601498a2010-11-01 13:30:22 +0000211vbo_sources = [
212 'vbo/vbo_context.c',
213 'vbo/vbo_exec.c',
214 'vbo/vbo_exec_api.c',
215 'vbo/vbo_exec_array.c',
216 'vbo/vbo_exec_draw.c',
217 'vbo/vbo_exec_eval.c',
218 'vbo/vbo_rebase.c',
219 'vbo/vbo_split.c',
220 'vbo/vbo_split_copy.c',
221 'vbo/vbo_split_inplace.c',
222 'vbo/vbo_save.c',
223 'vbo/vbo_save_api.c',
224 'vbo/vbo_save_draw.c',
225 'vbo/vbo_save_loopback.c',
226]
227
José Fonseca601498a2010-11-01 13:30:22 +0000228statetracker_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',
Marek Olšák5257a6d2011-03-05 20:32:28 +0100260 'state_tracker/st_cb_syncobj.c',
José Fonseca601498a2010-11-01 13:30:22 +0000261 'state_tracker/st_cb_strings.c',
262 'state_tracker/st_cb_texture.c',
Marek Olšákaea4ed42011-03-08 11:32:35 +0100263 'state_tracker/st_cb_texturebarrier.c',
José Fonseca601498a2010-11-01 13:30:22 +0000264 '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',
Brian Pauld7f2e382011-08-04 15:55:13 -0600272 'state_tracker/st_glsl_to_tgsi.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000273 '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',
278]
279
Kenneth Graunke8be58df2011-03-01 15:04:04 -0800280env.Append(YACCFLAGS = '-d')
281program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
282program_parse = env.CFile('program/program_parse.tab.c',
283 'program/program_parse.y')
José Fonsecadbfbb8c2011-03-03 15:43:18 +0000284
285# Make program/program_parse.tab.h reacheable from the include path
José Fonseca5d0e8be2011-03-03 16:57:38 +0000286env.Append(CPPPATH = [Dir('.').abspath])
José Fonsecadbfbb8c2011-03-03 15:43:18 +0000287
José Fonseca601498a2010-11-01 13:30:22 +0000288program_sources = [
289 'program/arbprogparse.c',
290 'program/hash_table.c',
291 'program/ir_to_mesa.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000292 'program/nvfragparse.c',
293 'program/nvvertparse.c',
294 'program/program.c',
José Fonseca601498a2010-11-01 13:30:22 +0000295 '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',
Ian Romanick54c48a92011-02-10 15:48:27 -0800301 'program/prog_opt_constant_fold.c',
José Fonseca601498a2010-11-01 13:30:22 +0000302 'program/prog_parameter.c',
303 'program/prog_parameter_layout.c',
304 'program/prog_print.c',
305 'program/prog_statevars.c',
306 'program/prog_uniform.c',
307 'program/programopt.c',
308 'program/sampler.cpp',
309 'program/symbol_table.c',
Kenneth Graunke8be58df2011-03-01 15:04:04 -0800310 program_lex,
311 program_parse[0],
José Fonseca601498a2010-11-01 13:30:22 +0000312]
313
José Fonseca8e8a56e2011-04-23 12:22:59 +0100314common_driver_sources = [
315 'drivers/common/driverfuncs.c',
316 'drivers/common/meta.c',
317]
318
José Fonseca601498a2010-11-01 13:30:22 +0000319mesa_sources = (
320 main_sources +
321 math_sources +
José Fonseca8e8a56e2011-04-23 12:22:59 +0100322 math_xform_sources +
José Fonseca601498a2010-11-01 13:30:22 +0000323 program_sources +
324 vbo_sources +
José Fonseca8e8a56e2011-04-23 12:22:59 +0100325 tnl_sources +
326 swrast_sources +
327 swrast_setup_sources +
328 common_driver_sources +
José Fonseca601498a2010-11-01 13:30:22 +0000329 statetracker_sources
330)
331
Chia-I Wubb770af2011-01-14 17:50:29 +0800332if env['gles']:
333 from sys import executable as python_cmd
334
335 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
336
337 # generate GLES sources
338 gles_sources = []
339 gles_sources += env.CodeGenerate(
340 target = 'main/api_exec_es1.c',
341 script = 'main/es_generator.py',
342 source = 'main/APIspec.xml',
343 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
344 )
345 gles_sources += env.CodeGenerate(
346 target = 'main/api_exec_es2.c',
347 script = 'main/es_generator.py',
348 source = 'main/APIspec.xml',
349 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
350 )
351
352 # generate GLES headers
353 GLAPI = '#src/mapi/glapi/'
354 gles_headers = []
355 gles_headers += env.CodeGenerate(
Chia-I Wu6eff33d2011-08-11 16:41:09 +0800356 target = 'main/api_exec_es1_dispatch.h',
Chia-I Wubb770af2011-01-14 17:50:29 +0800357 script = GLAPI + 'gen/gl_table.py',
Chia-I Wu50765612011-08-08 10:14:44 +0900358 source = GLAPI + 'gen/gl_and_es_API.xml',
359 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
Chia-I Wubb770af2011-01-14 17:50:29 +0800360 )
361 gles_headers += env.CodeGenerate(
Chia-I Wu6eff33d2011-08-11 16:41:09 +0800362 target = 'main/api_exec_es1_remap_helper.h',
Chia-I Wubb770af2011-01-14 17:50:29 +0800363 script = GLAPI + 'gen/remap_helper.py',
Chia-I Wu50765612011-08-08 10:14:44 +0900364 source = GLAPI + 'gen/gl_and_es_API.xml',
365 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
Chia-I Wubb770af2011-01-14 17:50:29 +0800366 )
367 gles_headers += env.CodeGenerate(
Chia-I Wu6eff33d2011-08-11 16:41:09 +0800368 target = 'main/api_exec_es2_dispatch.h',
Chia-I Wubb770af2011-01-14 17:50:29 +0800369 script = GLAPI + 'gen/gl_table.py',
Chia-I Wu50765612011-08-08 10:14:44 +0900370 source = GLAPI + 'gen/gl_and_es_API.xml',
371 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
Chia-I Wubb770af2011-01-14 17:50:29 +0800372 )
373 gles_headers += env.CodeGenerate(
Chia-I Wu6eff33d2011-08-11 16:41:09 +0800374 target = 'main/api_exec_es2_remap_helper.h',
Chia-I Wubb770af2011-01-14 17:50:29 +0800375 script = GLAPI + 'gen/remap_helper.py',
Chia-I Wu50765612011-08-08 10:14:44 +0900376 source = GLAPI + 'gen/gl_and_es_API.xml',
377 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
Chia-I Wubb770af2011-01-14 17:50:29 +0800378 )
379
380 env.Depends(gles_sources, gles_headers)
381
382 # gles_sources #include gles_headers with full path
383 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
384
385 mesa_sources += gles_sources
386
José Fonseca601498a2010-11-01 13:30:22 +0000387#
388# Assembly sources
389#
José Fonsecaf9156eb2010-11-01 13:56:16 +0000390if env['gcc'] and env['platform'] != 'windows':
391 if env['machine'] == 'x86':
392 env.Append(CPPDEFINES = [
393 'USE_X86_ASM',
394 'USE_MMX_ASM',
395 'USE_3DNOW_ASM',
396 'USE_SSE_ASM',
397 ])
398 mesa_sources += [
399 'x86/common_x86.c',
400 'x86/x86_xform.c',
401 'x86/3dnow.c',
402 'x86/sse.c',
403 'x86/common_x86_asm.S',
404 'x86/x86_xform2.S',
405 'x86/x86_xform3.S',
406 'x86/x86_xform4.S',
407 'x86/x86_cliptest.S',
408 'x86/mmx_blend.S',
409 'x86/3dnow_xform1.S',
410 'x86/3dnow_xform2.S',
411 'x86/3dnow_xform3.S',
412 'x86/3dnow_xform4.S',
413 'x86/3dnow_normal.S',
414 'x86/sse_xform1.S',
415 'x86/sse_xform2.S',
416 'x86/sse_xform3.S',
417 'x86/sse_xform4.S',
418 'x86/sse_normal.S',
419 'x86/read_rgba_span_x86.S',
420 ]
421 elif env['machine'] == 'x86_64':
422 env.Append(CPPDEFINES = [
423 'USE_X86_64_ASM',
424 ])
425 mesa_sources += [
426 'x86-64/x86-64.c',
427 'x86-64/xform4.S',
428 ]
429 elif env['machine'] == 'ppc':
430 env.Append(CPPDEFINES = [
431 'USE_PPC_ASM',
432 'USE_VMX_ASM',
433 ])
434 mesa_sources += [
435 'ppc/common_ppc.c',
436 ]
437 elif env['machine'] == 'sparc':
438 mesa_sources += [
439 'sparc/sparc.c',
440 'sparc/clip.S',
441 'sparc/norm.S',
442 'sparc/xform.S',
443 ]
444 else:
445 pass
José Fonseca601498a2010-11-01 13:30:22 +0000446
José Fonsecaf9156eb2010-11-01 13:56:16 +0000447 # Generate matypes.h
448 if env['machine'] in ('x86', 'x86_64'):
449 # See http://www.scons.org/wiki/UsingCodeGenerators
450 gen_matypes = env.Program(
451 target = 'gen_matypes',
452 source = 'x86/gen_matypes.c',
453 )
454 matypes = env.Command(
455 'matypes.h',
456 gen_matypes,
457 gen_matypes[0].abspath + ' > $TARGET',
458 )
459 # Add the dir containing the generated header (somewhere inside the
460 # build dir) to the include path
461 env.Append(CPPPATH = [matypes[0].dir])
José Fonseca601498a2010-11-01 13:30:22 +0000462
Brian Paul0c245502011-04-05 14:07:41 -0600463
Brian Paulf83af362011-09-28 08:15:22 -0600464
465
466def write_git_sha1_h_file(filename):
467 """Mesa looks for a git_sha1.h file at compile time in order to display
468 the current git hash id in the GL_VERSION string. This function tries
469 to retrieve the git hashid and write the header file. An empty file
470 will be created if anything goes wrong."""
471
472 args = [ 'git', 'log', '-n', '1', '--oneline' ]
473 try:
474 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
475 except:
476 # git log command didn't work
477 if not os.path.exists(filename):
478 # create an empty file if none already exists
479 f = open(filename, "w")
480 f.close()
481 return
482
483 commit = '#define MESA_GIT_SHA1 "%s"\n' % commit[0:7]
484 tempfile = "git_sha1.h.tmp"
485 f = open(tempfile, "w")
486 f.write(commit)
Vinson Lee622ee082011-04-05 15:32:39 -0700487 f.close()
Brian Paulf83af362011-09-28 08:15:22 -0600488 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
489 # The filename does not exist or it's different from the new file,
490 # so replace old file with new.
491 os.rename(tempfile, filename)
492 return
493
494
495# Create the git_sha1.h header file
496write_git_sha1_h_file("main/git_sha1.h")
Vinson Lee622ee082011-04-05 15:32:39 -0700497# and update CPPPATH so the git_sha1.h header can be found
498env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
Brian Paul0c245502011-04-05 14:07:41 -0600499
500
José Fonseca601498a2010-11-01 13:30:22 +0000501#
502# Libraries
503#
504
505mesa = env.ConvenienceLibrary(
506 target = 'mesa',
507 source = mesa_sources,
508)
509
510env.Alias('mesa', mesa)
511
512Export('mesa')
José Fonseca8e8a56e2011-04-23 12:22:59 +0100513
514SConscript('drivers/SConscript')