bin/gen_release_notes.py: html escape all external data
[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 from __future__ import print_function
24 import os
25 import os.path
26 import sys
27 import SCons.Util
28
29 import common
30
31 #######################################################################
32 # Minimal scons version
33
34 EnsureSConsVersion(2, 4)
35 EnsurePythonVersion(2, 7)
36
37
38 #######################################################################
39 # Configuration options
40
41 opts = Variables('config.py')
42 common.AddOptions(opts)
43
44 env = Environment(
45 options = opts,
46 tools = ['gallium'],
47 toolpath = ['#scons'],
48 ENV = os.environ,
49 )
50
51 # XXX: This creates a many problems as it saves...
52 #opts.Save('config.py', env)
53
54 # Backwards compatability with old target configuration variable
55 try:
56 targets = ARGUMENTS['targets']
57 except KeyError:
58 pass
59 else:
60 targets = targets.split(',')
61 print('scons: warning: targets option is deprecated; pass the targets on their own such as')
62 print()
63 print(' scons %s' % ' '.join(targets))
64 print()
65 COMMAND_LINE_TARGETS.append(targets)
66
67
68 Help(opts.GenerateHelpText(env))
69
70
71 #######################################################################
72 # Print a deprecation warning for using scons on non-windows
73
74 if common.host_platform != 'windows':
75 force = ARGUMENTS['force_scons']
76 if force.lower() not in {'false', 'off', 'none', '0', 'n'}:
77 print("WARNING: Scons is deprecated for non-windows platforms (including cygwin) "
78 "please use meson instead.", file=sys.stderr)
79 else:
80 print("ERROR: Scons is deprecated for non-windows platforms (including cygwin) "
81 "please use meson instead. If you really need to use scons you "
82 "can add `force_scons=1` to the scons command line.", file=sys.stderr)
83 sys.exit(1)
84 else:
85 print("WARNING: Scons support is in the process of being deprecated on "
86 "on windows platforms (including mingw). If you haven't already "
87 "please try using meson for windows builds. Be sure to report any "
88 "issues you run into", file=sys.stderr)
89
90
91 #######################################################################
92 # Environment setup
93
94 with open("VERSION") as f:
95 mesa_version = f.read().strip()
96 env.Append(CPPDEFINES = [
97 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
98 ('PACKAGE_BUGREPORT', '\\"https://gitlab.freedesktop.org/mesa/mesa/issues\\"'),
99 ])
100
101 # Includes
102 env.Prepend(CPPPATH = [
103 '#/include',
104 ])
105 env.Append(CPPPATH = [
106 '#/src/gallium/include',
107 '#/src/gallium/auxiliary',
108 '#/src/gallium/drivers',
109 '#/src/gallium/winsys',
110 ])
111
112 # for debugging
113 #print env.Dump()
114
115
116 # Add a check target for running tests
117 check = env.Alias('check')
118 env.AlwaysBuild(check)
119
120
121 #######################################################################
122 # Invoke host SConscripts
123 #
124 # For things that are meant to be run on the native host build machine, instead
125 # of the target machine.
126 #
127
128 # Create host environent
129 if env['crosscompile'] and not env['embedded']:
130 host_env = Environment(
131 options = opts,
132 # no tool used
133 tools = [],
134 toolpath = ['#scons'],
135 ENV = os.environ,
136 )
137
138 # Override options
139 host_env['platform'] = common.host_platform
140 host_env['machine'] = common.host_machine
141 host_env['toolchain'] = 'default'
142 host_env['llvm'] = False
143
144 host_env.Tool('gallium')
145
146 host_env['hostonly'] = True
147 assert host_env['crosscompile'] == False
148
149 target_env = env
150 env = host_env
151 Export('env')
152
153 SConscript(
154 'src/SConscript',
155 variant_dir = host_env['build_dir'],
156 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
157 )
158
159 env = target_env
160
161 Export('env')
162
163 #######################################################################
164 # Invoke SConscripts
165
166 # TODO: Build several variants at the same time?
167 # http://www.scons.org/wiki/SimultaneousVariantBuilds
168
169 SConscript(
170 'src/SConscript',
171 variant_dir = env['build_dir'],
172 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
173 )
174
175
176 ########################################################################
177 # List all aliases
178
179 try:
180 from SCons.Node.Alias import default_ans
181 except ImportError:
182 pass
183 else:
184 aliases = sorted(default_ans.keys())
185 env.Help('\n')
186 env.Help('Recognized targets:\n')
187 for alias in aliases:
188 env.Help(' %s\n' % alias)