blob: d861af8e4d719248b8f89dbb57f5656a6b2d7438 [file] [log] [blame]
Brian Paulace31242016-06-15 10:42:34 -06001import filecmp
2import os
3import subprocess
José Fonseca33ceb672008-02-18 10:52:44 +00004
Brian Paulace31242016-06-15 10:42:34 -06005Import('*')
José Fonseca982609f2011-02-11 17:38:54 +00006
José Fonseca601498a2010-11-01 13:30:22 +00007if env['platform'] == 'windows':
José Fonseca6d670f62011-01-12 15:32:17 +00008 SConscript('getopt/SConscript')
Chia-I Wu1e6c10f2010-05-31 11:47:58 +08009
Kenneth Graunke1e0da622014-02-24 23:39:14 -080010SConscript('util/SConscript')
Emil Velikov1a882fd2016-01-18 10:47:13 +020011SConscript('compiler/SConscript')
José Fonseca982609f2011-02-11 17:38:54 +000012
13if env['hostonly']:
14 # We are just compiling the things necessary on the host for cross
15 # compilation
16 Return()
17
Brian Paulace31242016-06-15 10:42:34 -060018
19def 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 args = [ 'git', 'rev-parse', '--short=10', 'HEAD' ]
26 try:
27 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
28 except:
29 print "Warning: exception in write_git_sha1_h_file()"
30 # git log command didn't work
31 if not os.path.exists(filename):
32 dirname = os.path.dirname(filename)
33 if dirname and not os.path.exists(dirname):
34 os.makedirs(dirname)
35 # create an empty file if none already exists
36 f = open(filename, "w")
37 f.close()
38 return
39
40 # note that commit[:-1] removes the trailing newline character
41 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[:-1]
42 tempfile = "git_sha1.h.tmp"
43 f = open(tempfile, "w")
44 f.write(commit)
45 f.close()
46 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
47 # The filename does not exist or it's different from the new file,
48 # so replace old file with new.
49 if os.path.exists(filename):
50 os.remove(filename)
51 os.rename(tempfile, filename)
52 return
53
54
55# Create the git_sha1.h header file
56write_git_sha1_h_file("git_sha1.h")
57# and update CPPPATH so the git_sha1.h header can be found
58env.Append(CPPPATH = ["#" + env['build_dir']])
59
60
61
Jose Fonseca47870d62015-03-24 20:26:21 +000062if env['platform'] != 'windows':
63 SConscript('loader/SConscript')
José Fonseca982609f2011-02-11 17:38:54 +000064
Chia-I Wubb770af2011-01-14 17:50:29 +080065# When env['gles'] is set, the targets defined in mapi/glapi/SConscript are not
66# used. libgl-xlib and libgl-gdi adapt themselves to use the targets defined
67# in mapi/glapi-shared/SConscript. mesa/SConscript also adapts itself to
68# enable OpenGL ES support.
Brian Pauldff36e92012-05-30 10:08:11 -060069SConscript('mapi/glapi/gen/SConscript')
José Fonseca601498a2010-11-01 13:30:22 +000070SConscript('mapi/glapi/SConscript')
Alexander von Gluck IV61ef6972013-12-31 15:39:49 -060071
72# Haiku C++ libGL dispatch (renderers depend on libgl)
73if env['platform'] in ['haiku']:
74 SConscript('hgl/SConscript')
75
José Fonseca601498a2010-11-01 13:30:22 +000076SConscript('mesa/SConscript')
José Fonseca1ca29452010-08-13 13:53:04 +010077
Brian Paul88625e62011-09-16 10:11:52 -060078if not env['embedded']:
Vinson Lee5cf69322012-05-23 17:26:20 -070079 if env['platform'] not in ('cygwin', 'darwin', 'freebsd', 'haiku', 'windows'):
José Fonsecaf8aeb1c2011-09-20 20:40:05 +010080 SConscript('glx/SConscript')
Alexander von Gluck IV400b8332014-12-22 10:10:13 -050081 if env['platform'] == 'haiku':
Emil Velikove7e29182015-07-14 02:04:30 +010082 SConscript('egl/SConscript')
Keith Whitwelle3c6d412010-06-08 17:38:01 +010083
Chia-I Wubb770af2011-01-14 17:50:29 +080084 if env['gles']:
85 SConscript('mapi/shared-glapi/SConscript')
86
José Fonseca706eda32010-03-09 15:07:57 +000087SConscript('gallium/SConscript')
José Fonseca57d00012009-01-23 12:32:35 +000088