scons: require scons 2.4 or greater
[mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as
5 #
6 # scons build=debug llvm=yes machine=x86
7 #
8 # to set configuration variables. Or you can write those options to a file
9 # named config.py:
10 #
11 # # config.py
12 # build='debug'
13 # llvm=True
14 # machine='x86'
15 #
16 # Invoke
17 #
18 # scons -h
19 #
20 # to get the full list of options. See scons manpage for more info.
21 #
22
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Minimal scons version
32
33 EnsureSConsVersion(2, 4)
34
35
36 #######################################################################
37 # Configuration options
38
39 opts = Variables('config.py')
40 common.AddOptions(opts)
41
42 env = Environment(
43 options = opts,
44 tools = ['gallium'],
45 toolpath = ['#scons'],
46 ENV = os.environ,
47 )
48
49 # XXX: This creates a many problems as it saves...
50 #opts.Save('config.py', env)
51
52 # Backwards compatability with old target configuration variable
53 try:
54 targets = ARGUMENTS['targets']
55 except KeyError:
56 pass
57 else:
58 targets = targets.split(',')
59 print('scons: warning: targets option is deprecated; pass the targets on their own such as')
60 print()
61 print(' scons %s' % ' '.join(targets))
62 print()
63 COMMAND_LINE_TARGETS.append(targets)
64
65
66 Help(opts.GenerateHelpText(env))
67
68 #######################################################################
69 # Environment setup
70
71 with open("VERSION") as f:
72 mesa_version = f.read().strip()
73 env.Append(CPPDEFINES = [
74 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
75 ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
76 ])
77
78 # Includes
79 env.Prepend(CPPPATH = [
80 '#/include',
81 ])
82 env.Append(CPPPATH = [
83 '#/src/gallium/include',
84 '#/src/gallium/auxiliary',
85 '#/src/gallium/drivers',
86 '#/src/gallium/winsys',
87 ])
88
89 # for debugging
90 #print env.Dump()
91
92
93 # Add a check target for running tests
94 check = env.Alias('check')
95 env.AlwaysBuild(check)
96
97
98 #######################################################################
99 # Invoke host SConscripts
100 #
101 # For things that are meant to be run on the native host build machine, instead
102 # of the target machine.
103 #
104
105 # Create host environent
106 if env['crosscompile'] and not env['embedded']:
107 host_env = Environment(
108 options = opts,
109 # no tool used
110 tools = [],
111 toolpath = ['#scons'],
112 ENV = os.environ,
113 )
114
115 # Override options
116 host_env['platform'] = common.host_platform
117 host_env['machine'] = common.host_machine
118 host_env['toolchain'] = 'default'
119 host_env['llvm'] = False
120
121 host_env.Tool('gallium')
122
123 host_env['hostonly'] = True
124 assert host_env['crosscompile'] == False
125
126 target_env = env
127 env = host_env
128 Export('env')
129
130 SConscript(
131 'src/SConscript',
132 variant_dir = host_env['build_dir'],
133 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
134 )
135
136 env = target_env
137
138 Export('env')
139
140 #######################################################################
141 # Invoke SConscripts
142
143 # TODO: Build several variants at the same time?
144 # http://www.scons.org/wiki/SimultaneousVariantBuilds
145
146 SConscript(
147 'src/SConscript',
148 variant_dir = env['build_dir'],
149 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
150 )
151
152
153 ########################################################################
154 # List all aliases
155
156 try:
157 from SCons.Node.Alias import default_ans
158 except ImportError:
159 pass
160 else:
161 aliases = sorted(default_ans.keys())
162 env.Help('\n')
163 env.Help('Recognized targets:\n')
164 for alias in aliases:
165 env.Help(' %s\n' % alias)