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