5e1171b5246b08e53960197a3ef3aaf5e9596628
[mesa.git] / src / SConscript
1 import filecmp
2 import os
3 import subprocess
4
5 Import('*')
6
7 if env['platform'] == 'windows':
8 SConscript('getopt/SConscript')
9
10 SConscript('util/SConscript')
11 SConscript('compiler/SConscript')
12
13 if env['hostonly']:
14 # We are just compiling the things necessary on the host for cross
15 # compilation
16 Return()
17
18
19 def write_git_sha1_h_file(filename):
20 """Mesa looks for a git_sha1.h file at compile time in order to display
21 the current git hash id in the GL_VERSION string. This function tries
22 to retrieve the git hashid and write the header file. An empty file
23 will be created if anything goes wrong."""
24
25 tempfile = "git_sha1.h.tmp"
26 with open(tempfile, "w") as f:
27 args = [ 'sh', Dir('#').abspath + '/git_sha1_gen.sh' ]
28 try:
29 subprocess.Popen(args, stdout=f)
30 except:
31 print "Warning: exception in write_git_sha1_h_file()"
32 return
33
34 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
35 # The filename does not exist or it's different from the new file,
36 # so replace old file with new.
37 if os.path.exists(filename):
38 os.remove(filename)
39 os.rename(tempfile, filename)
40 return
41
42
43 # Create the git_sha1.h header file
44 write_git_sha1_h_file("git_sha1.h")
45 # and update CPPPATH so the git_sha1.h header can be found
46 env.Append(CPPPATH = ["#" + env['build_dir']])
47
48
49
50 if env['platform'] != 'windows':
51 SConscript('loader/SConscript')
52
53 # When env['gles'] is set, the targets defined in mapi/glapi/SConscript are not
54 # used. libgl-xlib and libgl-gdi adapt themselves to use the targets defined
55 # in mapi/glapi-shared/SConscript. mesa/SConscript also adapts itself to
56 # enable OpenGL ES support.
57 SConscript('mapi/glapi/gen/SConscript')
58 SConscript('mapi/glapi/SConscript')
59
60 # Haiku C++ libGL dispatch (renderers depend on libgl)
61 if env['platform'] in ['haiku']:
62 SConscript('hgl/SConscript')
63
64 SConscript('mesa/SConscript')
65
66 if not env['embedded']:
67 if env['platform'] not in ('cygwin', 'darwin', 'freebsd', 'haiku', 'windows'):
68 SConscript('glx/SConscript')
69 if env['platform'] == 'haiku':
70 SConscript('egl/SConscript')
71
72 if env['gles']:
73 SConscript('mapi/shared-glapi/SConscript')
74
75 SConscript('gallium/SConscript')
76