blob: e03d6a6a3afc1586183e19128f0f0cb46dc817da [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
Brian Pauldff36e92012-05-30 10:08:11 -06009from sys import executable as python_cmd
José Fonsecac42e6252008-01-31 13:14:35 +090010
José Fonseca601498a2010-11-01 13:30:22 +000011env = env.Clone()
José Fonsecab9da3792008-02-19 15:07:53 +090012
José Fonseca601498a2010-11-01 13:30:22 +000013env.Append(CPPPATH = [
14 '#/src/mapi',
15 '#/src/glsl',
16 '#/src/mesa',
17])
José Fonseca2105b612009-01-06 16:20:12 +000018
Imre Deak66781252012-09-12 19:46:05 +030019enabled_apis = []
20enabled_apis += ['GL']
Chia-I Wubb770af2011-01-14 17:50:29 +080021
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)
Tapani Pälli91214602012-08-28 14:01:51 +030033 ('HAVE_DLOPEN', '1'),
Chia-I Wubb045d32010-11-20 17:47:11 -080034 ])
José Fonseca5c9c6b02008-06-04 23:56:57 +090035
José Fonseca601498a2010-11-01 13:30:22 +000036#
37# Source files
38#
Michal Krol3371f7e2009-11-25 14:52:21 +010039
José Fonseca601498a2010-11-01 13:30:22 +000040main_sources = [
41 'main/api_arrayelt.c',
42 'main/api_exec.c',
43 'main/api_loopback.c',
José Fonseca601498a2010-11-01 13:30:22 +000044 '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',
José Fonseca601498a2010-11-01 13:30:22 +000062 'main/dlist.c',
José Fonseca601498a2010-11-01 13:30:22 +000063 'main/drawpix.c',
64 'main/drawtex.c',
65 'main/enable.c',
66 'main/enums.c',
nobled5ab088c2011-05-01 12:47:31 +000067 'main/errors.c',
Vinson Lee5cbc0f02012-11-06 23:16:29 -080068 'main/es1_conversion.c',
José Fonseca601498a2010-11-01 13:30:22 +000069 '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',
Brian Pauldfcd7652013-01-16 08:18:33 -070077 'main/formatquery.c',
José Fonseca601498a2010-11-01 13:30:22 +000078 'main/formats.c',
Brian Paulaa6cb952011-12-03 10:04:18 -070079 'main/format_pack.c',
Brian Paul730952a2011-09-08 20:16:18 -060080 'main/format_unpack.c',
José Fonseca601498a2010-11-01 13:30:22 +000081 'main/framebuffer.c',
José Fonseca601498a2010-11-01 13:30:22 +000082 'main/getstring.c',
Jordan Justen9ad8f432012-06-25 10:52:39 -070083 'main/glformats.c',
José Fonseca601498a2010-11-01 13:30:22 +000084 'main/hash.c',
Eric Anholt35fd61b2012-11-06 23:18:41 -080085 'main/hash_table.c',
José Fonseca601498a2010-11-01 13:30:22 +000086 'main/hint.c',
87 'main/histogram.c',
88 'main/image.c',
89 'main/imports.c',
90 'main/light.c',
91 'main/lines.c',
92 'main/matrix.c',
93 'main/mipmap.c',
94 'main/mm.c',
95 'main/multisample.c',
José Fonseca601498a2010-11-01 13:30:22 +000096 'main/pack.c',
Brian Paulb70610b2011-02-28 18:24:35 -070097 'main/pbo.c',
José Fonseca601498a2010-11-01 13:30:22 +000098 'main/pixel.c',
99 'main/pixelstore.c',
100 'main/pixeltransfer.c',
101 'main/points.c',
102 'main/polygon.c',
103 'main/querymatrix.c',
104 'main/queryobj.c',
105 'main/rastpos.c',
106 'main/readpix.c',
107 'main/remap.c',
108 'main/renderbuffer.c',
Brian Paul34a5d3b2011-04-10 12:48:28 -0600109 'main/samplerobj.c',
José Fonseca601498a2010-11-01 13:30:22 +0000110 'main/scissor.c',
Eric Anholt82c9d982012-12-04 01:03:57 -0800111 'main/set.c',
José Fonseca601498a2010-11-01 13:30:22 +0000112 'main/shaderapi.c',
113 'main/shaderobj.c',
Brian Paul6399b7d2011-10-04 15:59:09 -0600114 'main/shader_query.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000115 'main/shared.c',
116 'main/state.c',
117 'main/stencil.c',
118 'main/syncobj.c',
119 'main/texcompress.c',
Brian Paulc1a9e602012-08-21 20:22:27 -0600120 'main/texcompress_cpal.c',
Vinson Lee93893132011-02-27 23:17:49 -0800121 'main/texcompress_rgtc.c',
José Fonseca601498a2010-11-01 13:30:22 +0000122 'main/texcompress_s3tc.c',
123 'main/texcompress_fxt1.c',
Chia-I Wu51f4d272011-11-28 23:55:31 +0800124 'main/texcompress_etc.c',
José Fonseca601498a2010-11-01 13:30:22 +0000125 'main/texenv.c',
José Fonseca601498a2010-11-01 13:30:22 +0000126 'main/texformat.c',
127 'main/texgen.c',
128 'main/texgetimage.c',
129 'main/teximage.c',
130 'main/texobj.c',
José Fonseca601498a2010-11-01 13:30:22 +0000131 'main/texparam.c',
José Fonseca601498a2010-11-01 13:30:22 +0000132 'main/texstate.c',
Brian Paul29eb2e82011-10-31 10:52:56 -0600133 'main/texstorage.c',
José Fonseca601498a2010-11-01 13:30:22 +0000134 'main/texstore.c',
Marek Olšákd0e805e2011-03-15 16:25:16 +0100135 'main/texturebarrier.c',
José Fonseca601498a2010-11-01 13:30:22 +0000136 'main/transformfeedback.c',
Vinson Lee116b7bb2011-10-18 18:39:11 -0700137 'main/uniform_query.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000138 'main/uniforms.c',
139 'main/varray.c',
140 'main/version.c',
141 'main/viewport.c',
142 'main/vtxfmt.c',
143]
José Fonseca5c9c6b02008-06-04 23:56:57 +0900144
Imre Deak98f880e2012-09-10 08:46:13 +0300145glget_sources = [
146 'main/get.c',
147]
148
José Fonseca601498a2010-11-01 13:30:22 +0000149math_sources = [
150 'math/m_debug_clip.c',
151 'math/m_debug_norm.c',
152 'math/m_debug_xform.c',
153 'math/m_eval.c',
154 'math/m_matrix.c',
155 'math/m_translate.c',
156 'math/m_vector.c',
157 'math/m_xform.c',
158]
159
José Fonseca8e8a56e2011-04-23 12:22:59 +0100160swrast_sources = [
161 'swrast/s_aaline.c',
162 'swrast/s_aatriangle.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100163 'swrast/s_alpha.c',
164 'swrast/s_atifragshader.c',
165 'swrast/s_bitmap.c',
166 'swrast/s_blend.c',
167 'swrast/s_blit.c',
168 'swrast/s_clear.c',
169 'swrast/s_copypix.c',
170 'swrast/s_context.c',
171 'swrast/s_depth.c',
172 'swrast/s_drawpix.c',
173 'swrast/s_feedback.c',
174 'swrast/s_fog.c',
175 'swrast/s_fragprog.c',
176 'swrast/s_lines.c',
177 'swrast/s_logic.c',
178 'swrast/s_masking.c',
179 'swrast/s_points.c',
Brian Paulb85284f2011-12-05 20:40:48 -0700180 'swrast/s_renderbuffer.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100181 'swrast/s_span.c',
182 'swrast/s_stencil.c',
183 'swrast/s_texcombine.c',
Brian Paulbaeefef2011-09-17 14:50:48 -0600184 'swrast/s_texfetch.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100185 'swrast/s_texfilter.c',
Brian Paul755f2e22011-06-13 13:44:35 -0600186 'swrast/s_texrender.c',
Brian Paul6f1846e2011-08-29 11:37:13 -0600187 'swrast/s_texture.c',
José Fonseca8e8a56e2011-04-23 12:22:59 +0100188 'swrast/s_triangle.c',
189 'swrast/s_zoom.c',
190]
191
192swrast_setup_sources = [
193 'swrast_setup/ss_context.c',
194 'swrast_setup/ss_triangle.c',
195]
196
197tnl_sources = [
198 'tnl/t_context.c',
199 'tnl/t_pipeline.c',
200 'tnl/t_draw.c',
201 'tnl/t_rasterpos.c',
202 'tnl/t_vb_program.c',
203 'tnl/t_vb_render.c',
204 'tnl/t_vb_texgen.c',
205 'tnl/t_vb_texmat.c',
206 'tnl/t_vb_vertex.c',
207 'tnl/t_vb_fog.c',
208 'tnl/t_vb_light.c',
209 'tnl/t_vb_normals.c',
210 'tnl/t_vb_points.c',
211 'tnl/t_vp_build.c',
212 'tnl/t_vertex.c',
213 'tnl/t_vertex_sse.c',
214 'tnl/t_vertex_generic.c',
215]
216
José Fonseca601498a2010-11-01 13:30:22 +0000217vbo_sources = [
218 'vbo/vbo_context.c',
219 'vbo/vbo_exec.c',
220 'vbo/vbo_exec_api.c',
221 'vbo/vbo_exec_array.c',
222 'vbo/vbo_exec_draw.c',
223 'vbo/vbo_exec_eval.c',
Brian Paule6c41592011-11-09 17:22:47 -0700224 'vbo/vbo_noop.c',
Jordan Justenbc8e0f52012-05-07 15:50:21 -0700225 'vbo/vbo_primitive_restart.c',
José Fonseca601498a2010-11-01 13:30:22 +0000226 'vbo/vbo_rebase.c',
227 'vbo/vbo_split.c',
228 'vbo/vbo_split_copy.c',
229 'vbo/vbo_split_inplace.c',
230 'vbo/vbo_save.c',
231 'vbo/vbo_save_api.c',
232 'vbo/vbo_save_draw.c',
233 'vbo/vbo_save_loopback.c',
234]
235
José Fonseca601498a2010-11-01 13:30:22 +0000236statetracker_sources = [
237 'state_tracker/st_atom.c',
Brian Paul4d9f2632012-06-15 09:31:15 -0600238 'state_tracker/st_atom_array.c',
José Fonseca601498a2010-11-01 13:30:22 +0000239 'state_tracker/st_atom_blend.c',
240 'state_tracker/st_atom_clip.c',
241 'state_tracker/st_atom_constbuf.c',
242 'state_tracker/st_atom_depth.c',
243 'state_tracker/st_atom_framebuffer.c',
244 'state_tracker/st_atom_msaa.c',
245 'state_tracker/st_atom_pixeltransfer.c',
246 'state_tracker/st_atom_sampler.c',
247 'state_tracker/st_atom_scissor.c',
248 'state_tracker/st_atom_shader.c',
249 'state_tracker/st_atom_rasterizer.c',
250 'state_tracker/st_atom_stipple.c',
251 'state_tracker/st_atom_texture.c',
252 'state_tracker/st_atom_viewport.c',
José Fonseca601498a2010-11-01 13:30:22 +0000253 'state_tracker/st_cb_bitmap.c',
254 'state_tracker/st_cb_blit.c',
255 'state_tracker/st_cb_bufferobjects.c',
256 'state_tracker/st_cb_clear.c',
257 'state_tracker/st_cb_condrender.c',
258 'state_tracker/st_cb_flush.c',
259 'state_tracker/st_cb_drawpixels.c',
260 'state_tracker/st_cb_drawtex.c',
261 'state_tracker/st_cb_eglimage.c',
262 'state_tracker/st_cb_fbo.c',
263 'state_tracker/st_cb_feedback.c',
264 'state_tracker/st_cb_program.c',
265 'state_tracker/st_cb_queryobj.c',
266 'state_tracker/st_cb_rasterpos.c',
267 'state_tracker/st_cb_readpixels.c',
Marek Olšák5257a6d2011-03-05 20:32:28 +0100268 'state_tracker/st_cb_syncobj.c',
José Fonseca601498a2010-11-01 13:30:22 +0000269 'state_tracker/st_cb_strings.c',
270 'state_tracker/st_cb_texture.c',
Marek Olšákaea4ed42011-03-08 11:32:35 +0100271 'state_tracker/st_cb_texturebarrier.c',
José Fonseca601498a2010-11-01 13:30:22 +0000272 'state_tracker/st_cb_viewport.c',
273 'state_tracker/st_cb_xformfb.c',
274 'state_tracker/st_context.c',
275 'state_tracker/st_debug.c',
276 'state_tracker/st_draw.c',
277 'state_tracker/st_draw_feedback.c',
278 'state_tracker/st_extensions.c',
279 'state_tracker/st_format.c',
Brian Pauld7f2e382011-08-04 15:55:13 -0600280 'state_tracker/st_glsl_to_tgsi.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000281 'state_tracker/st_gen_mipmap.c',
282 'state_tracker/st_manager.c',
283 'state_tracker/st_mesa_to_tgsi.c',
284 'state_tracker/st_program.c',
285 'state_tracker/st_texture.c',
286]
287
Brian Paule78ebbc2012-09-15 09:01:02 -0600288env.Append(YACCFLAGS = '-d -p "_mesa_program_"')
Kenneth Graunke8be58df2011-03-01 15:04:04 -0800289program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
290program_parse = env.CFile('program/program_parse.tab.c',
291 'program/program_parse.y')
José Fonsecadbfbb8c2011-03-03 15:43:18 +0000292
293# Make program/program_parse.tab.h reacheable from the include path
José Fonseca5d0e8be2011-03-03 16:57:38 +0000294env.Append(CPPPATH = [Dir('.').abspath])
José Fonsecadbfbb8c2011-03-03 15:43:18 +0000295
José Fonseca601498a2010-11-01 13:30:22 +0000296program_sources = [
297 'program/arbprogparse.c',
Jordan Justen59284bc2012-11-30 16:32:11 -0800298 'program/prog_hash_table.c',
José Fonseca601498a2010-11-01 13:30:22 +0000299 'program/ir_to_mesa.cpp',
José Fonseca601498a2010-11-01 13:30:22 +0000300 'program/program.c',
José Fonseca601498a2010-11-01 13:30:22 +0000301 'program/program_parse_extra.c',
302 'program/prog_cache.c',
303 'program/prog_execute.c',
304 'program/prog_instruction.c',
305 'program/prog_noise.c',
306 'program/prog_optimize.c',
Ian Romanick54c48a92011-02-10 15:48:27 -0800307 'program/prog_opt_constant_fold.c',
José Fonseca601498a2010-11-01 13:30:22 +0000308 'program/prog_parameter.c',
309 'program/prog_parameter_layout.c',
310 'program/prog_print.c',
311 'program/prog_statevars.c',
José Fonseca601498a2010-11-01 13:30:22 +0000312 'program/programopt.c',
313 'program/sampler.cpp',
314 'program/symbol_table.c',
Brian Paul6399b7d2011-10-04 15:59:09 -0600315 'program/string_to_uint_map.cpp',
Kenneth Graunke8be58df2011-03-01 15:04:04 -0800316 program_lex,
317 program_parse[0],
José Fonseca601498a2010-11-01 13:30:22 +0000318]
319
José Fonseca8e8a56e2011-04-23 12:22:59 +0100320common_driver_sources = [
321 'drivers/common/driverfuncs.c',
322 'drivers/common/meta.c',
323]
324
José Fonseca601498a2010-11-01 13:30:22 +0000325mesa_sources = (
326 main_sources +
Imre Deak98f880e2012-09-10 08:46:13 +0300327 glget_sources +
José Fonseca601498a2010-11-01 13:30:22 +0000328 math_sources +
329 program_sources +
330 vbo_sources +
José Fonseca8e8a56e2011-04-23 12:22:59 +0100331 tnl_sources +
332 swrast_sources +
333 swrast_setup_sources +
334 common_driver_sources +
José Fonseca601498a2010-11-01 13:30:22 +0000335 statetracker_sources
336)
337
Brian Pauldff36e92012-05-30 10:08:11 -0600338GLAPI = '#src/mapi/glapi/'
339
Chia-I Wubb770af2011-01-14 17:50:29 +0800340if env['gles']:
Chia-I Wubb770af2011-01-14 17:50:29 +0800341
Imre Deak66781252012-09-12 19:46:05 +0300342 enabled_apis += ['ES1', 'ES2']
Chia-I Wubb770af2011-01-14 17:50:29 +0800343
344 # generate GLES sources
Vinson Lee5cbc0f02012-11-06 23:16:29 -0800345 gles_sources = []
Chia-I Wubb770af2011-01-14 17:50:29 +0800346
347 # generate GLES headers
Chia-I Wubb770af2011-01-14 17:50:29 +0800348 gles_headers = []
Chia-I Wubb770af2011-01-14 17:50:29 +0800349
350 env.Depends(gles_sources, gles_headers)
351
352 # gles_sources #include gles_headers with full path
353 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
354
355 mesa_sources += gles_sources
356
Imre Deak66781252012-09-12 19:46:05 +0300357env.Append(CPPDEFINES = ["FEATURE_%s=1" % api for api in enabled_apis])
358
Imre Deak98f880e2012-09-10 08:46:13 +0300359get_hash_gen_opts = ' '.join(["-a %s" % api for api in enabled_apis])
360
361get_hash_header = env.CodeGenerate(
362 target = 'main/get_hash.h',
363 script = 'main/get_hash_generator.py',
364 source = GLAPI + 'gen/gl_and_es_API.xml',
365 command = python_cmd + ' $SCRIPT ' + get_hash_gen_opts +
366 ' -f $SOURCE > $TARGET'
367)
368
369env.Depends(glget_sources, get_hash_header)
370
José Fonseca601498a2010-11-01 13:30:22 +0000371#
372# Assembly sources
373#
Alexander von Gluck IVb9227b32013-01-06 16:06:37 -0600374if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
José Fonsecaf9156eb2010-11-01 13:56:16 +0000375 if env['machine'] == 'x86':
376 env.Append(CPPDEFINES = [
377 'USE_X86_ASM',
378 'USE_MMX_ASM',
379 'USE_3DNOW_ASM',
380 'USE_SSE_ASM',
381 ])
382 mesa_sources += [
383 'x86/common_x86.c',
384 'x86/x86_xform.c',
385 'x86/3dnow.c',
386 'x86/sse.c',
387 'x86/common_x86_asm.S',
388 'x86/x86_xform2.S',
389 'x86/x86_xform3.S',
390 'x86/x86_xform4.S',
391 'x86/x86_cliptest.S',
392 'x86/mmx_blend.S',
393 'x86/3dnow_xform1.S',
394 'x86/3dnow_xform2.S',
395 'x86/3dnow_xform3.S',
396 'x86/3dnow_xform4.S',
397 'x86/3dnow_normal.S',
398 'x86/sse_xform1.S',
399 'x86/sse_xform2.S',
400 'x86/sse_xform3.S',
401 'x86/sse_xform4.S',
402 'x86/sse_normal.S',
403 'x86/read_rgba_span_x86.S',
404 ]
405 elif env['machine'] == 'x86_64':
406 env.Append(CPPDEFINES = [
407 'USE_X86_64_ASM',
408 ])
409 mesa_sources += [
410 'x86-64/x86-64.c',
411 'x86-64/xform4.S',
412 ]
José Fonsecaf9156eb2010-11-01 13:56:16 +0000413 elif env['machine'] == 'sparc':
414 mesa_sources += [
415 'sparc/sparc.c',
Jon TURNEY86768902012-07-07 00:53:31 +0100416 'sparc/sparc_clip.S',
José Fonsecaf9156eb2010-11-01 13:56:16 +0000417 'sparc/norm.S',
418 'sparc/xform.S',
419 ]
420 else:
421 pass
José Fonseca601498a2010-11-01 13:30:22 +0000422
José Fonsecaf9156eb2010-11-01 13:56:16 +0000423 # Generate matypes.h
424 if env['machine'] in ('x86', 'x86_64'):
425 # See http://www.scons.org/wiki/UsingCodeGenerators
426 gen_matypes = env.Program(
427 target = 'gen_matypes',
428 source = 'x86/gen_matypes.c',
429 )
430 matypes = env.Command(
431 'matypes.h',
432 gen_matypes,
433 gen_matypes[0].abspath + ' > $TARGET',
434 )
435 # Add the dir containing the generated header (somewhere inside the
436 # build dir) to the include path
437 env.Append(CPPPATH = [matypes[0].dir])
José Fonseca601498a2010-11-01 13:30:22 +0000438
Brian Paul0c245502011-04-05 14:07:41 -0600439
Brian Pauldff36e92012-05-30 10:08:11 -0600440# The enums.c file is generated from the GL/ES API.xml file
441env.CodeGenerate(
442 target = 'main/enums.c',
443 script = GLAPI + 'gen/gl_enums.py',
444 source = GLAPI + 'gen/gl_and_es_API.xml',
445 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
446 )
447
Paul Berry98874ec2012-10-31 10:42:08 -0700448# The api_exec.c file is generated from the GL/ES API.xml file
449env.CodeGenerate(
450 target = 'main/api_exec.c',
451 script = GLAPI + 'gen/gl_genexec.py',
452 source = GLAPI + 'gen/gl_and_es_API.xml',
453 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
454 )
455
Brian Pauldff36e92012-05-30 10:08:11 -0600456# We also depend on the auto-generated GL API headers
457env.Depends(mesa_sources, glapi_headers)
Brian Paulf83af362011-09-28 08:15:22 -0600458
459
460def write_git_sha1_h_file(filename):
461 """Mesa looks for a git_sha1.h file at compile time in order to display
462 the current git hash id in the GL_VERSION string. This function tries
463 to retrieve the git hashid and write the header file. An empty file
464 will be created if anything goes wrong."""
465
466 args = [ 'git', 'log', '-n', '1', '--oneline' ]
467 try:
468 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
469 except:
470 # git log command didn't work
471 if not os.path.exists(filename):
472 # create an empty file if none already exists
473 f = open(filename, "w")
474 f.close()
475 return
476
Brian Pauld487cc22011-09-28 09:51:36 -0600477 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
Brian Paulf83af362011-09-28 08:15:22 -0600478 tempfile = "git_sha1.h.tmp"
479 f = open(tempfile, "w")
480 f.write(commit)
Vinson Lee622ee082011-04-05 15:32:39 -0700481 f.close()
Brian Paulf83af362011-09-28 08:15:22 -0600482 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
483 # The filename does not exist or it's different from the new file,
484 # so replace old file with new.
Brian Paule1122872011-09-28 09:04:03 -0600485 if os.path.exists(filename):
486 os.remove(filename)
Brian Paulf83af362011-09-28 08:15:22 -0600487 os.rename(tempfile, filename)
488 return
489
490
491# Create the git_sha1.h header file
492write_git_sha1_h_file("main/git_sha1.h")
Vinson Lee622ee082011-04-05 15:32:39 -0700493# and update CPPPATH so the git_sha1.h header can be found
494env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
Brian Paul0c245502011-04-05 14:07:41 -0600495
496
José Fonseca601498a2010-11-01 13:30:22 +0000497#
498# Libraries
499#
500
501mesa = env.ConvenienceLibrary(
502 target = 'mesa',
503 source = mesa_sources,
504)
505
506env.Alias('mesa', mesa)
507
508Export('mesa')
José Fonseca8e8a56e2011-04-23 12:22:59 +0100509
510SConscript('drivers/SConscript')