blob: f905189dd9e518624bc1b4d7f1092bfe6f0728d0 [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
2# Top-level SConstruct
José Fonsecac42e6252008-01-31 13:14:35 +09003#
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -06004# For example, invoke scons as
José Fonsecac42e6252008-01-31 13:14:35 +09005#
José Fonseca601498a2010-11-01 13:30:22 +00006# scons build=debug llvm=yes machine=x86
José Fonsecac42e6252008-01-31 13:14:35 +09007#
8# to set configuration variables. Or you can write those options to a file
9# named config.py:
10#
11# # config.py
José Fonseca601498a2010-11-01 13:30:22 +000012# build='debug'
13# llvm=True
José Fonseca81b6a802008-02-06 14:36:50 +090014# machine='x86'
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060015#
José Fonsecac42e6252008-01-31 13:14:35 +090016# Invoke
17#
18# scons -h
19#
20# to get the full list of options. See scons manpage for more info.
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060021#
José Fonsecac42e6252008-01-31 13:14:35 +090022
Dylan Baker79e73882019-10-21 09:24:12 -070023from __future__ import print_function
José Fonseca94090432008-02-27 17:36:28 +090024import os
25import os.path
26import sys
Alan Hourihane550fc192010-01-26 19:57:34 +000027import SCons.Util
José Fonsecad710a7c2008-02-19 18:53:16 +090028
José Fonseca94090432008-02-27 17:36:28 +090029import common
José Fonseca58a3d7d2008-02-23 19:49:08 +090030
José Fonseca94090432008-02-27 17:36:28 +090031#######################################################################
Juan A. Suarez Romero810c9a42018-08-01 17:48:11 +020032# Minimal scons version
33
34EnsureSConsVersion(2, 4)
Dylan Baker64e46382018-08-14 10:24:29 -070035EnsurePythonVersion(2, 7)
Juan A. Suarez Romero810c9a42018-08-01 17:48:11 +020036
37
38#######################################################################
José Fonseca94090432008-02-27 17:36:28 +090039# Configuration options
40
José Fonsecae9fb90a2009-05-01 16:12:17 +010041opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010042common.AddOptions(opts)
Jonathan White3c819922008-08-29 11:30:32 -060043
José Fonseca81b6a802008-02-06 14:36:50 +090044env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090045 options = opts,
46 tools = ['gallium'],
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060047 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090048 ENV = os.environ,
49)
50
José Fonsecab1156622011-07-01 19:04:57 +010051# XXX: This creates a many problems as it saves...
52#opts.Save('config.py', env)
José Fonsecaef4bf402011-06-17 20:11:35 +010053
José Fonseca601498a2010-11-01 13:30:22 +000054# Backwards compatability with old target configuration variable
55try:
56 targets = ARGUMENTS['targets']
57except KeyError:
58 pass
59else:
60 targets = targets.split(',')
Eric Engestrom7d482192017-09-19 13:56:34 +010061 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()
José Fonseca601498a2010-11-01 13:30:22 +000065 COMMAND_LINE_TARGETS.append(targets)
66
Alan Hourihane6544be62010-01-26 19:14:16 +000067
José Fonsecac42e6252008-01-31 13:14:35 +090068Help(opts.GenerateHelpText(env))
69
Dylan Baker54053bc2019-10-21 09:29:23 -070070
71#######################################################################
72# Print a deprecation warning for using scons on non-windows
73
Jose Fonsecaace51382019-10-25 22:09:34 +010074if common.host_platform != 'windows' and env['platform'] != 'windows':
75 if env['force_scons']:
Dylan Baker54053bc2019-10-21 09:29:23 -070076 print("WARNING: Scons is deprecated for non-windows platforms (including cygwin) "
77 "please use meson instead.", file=sys.stderr)
78 else:
79 print("ERROR: Scons is deprecated for non-windows platforms (including cygwin) "
80 "please use meson instead. If you really need to use scons you "
81 "can add `force_scons=1` to the scons command line.", file=sys.stderr)
82 sys.exit(1)
Dylan Baker61ed9892019-10-21 10:18:50 -070083else:
84 print("WARNING: Scons support is in the process of being deprecated on "
85 "on windows platforms (including mingw). If you haven't already "
86 "please try using meson for windows builds. Be sure to report any "
87 "issues you run into", file=sys.stderr)
88
89
José Fonsecac42e6252008-01-31 13:14:35 +090090#######################################################################
91# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090092
Emil Velikov488b3ed2013-07-25 23:45:45 +010093with open("VERSION") as f:
94 mesa_version = f.read().strip()
José Fonsecacff70dc2013-03-13 13:13:08 +000095env.Append(CPPDEFINES = [
Emil Velikov488b3ed2013-07-25 23:45:45 +010096 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
Adam Jackson5b5c5bf2019-09-18 15:59:41 -040097 ('PACKAGE_BUGREPORT', '\\"https://gitlab.freedesktop.org/mesa/mesa/issues\\"'),
José Fonsecacff70dc2013-03-13 13:13:08 +000098])
99
José Fonsecac42e6252008-01-31 13:14:35 +0900100# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -0700101env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +0900102 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -0700103])
104env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +0000105 '#/src/gallium/include',
106 '#/src/gallium/auxiliary',
107 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +0000108 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +0900109])
110
José Fonseca4f17bd22008-03-12 13:34:30 +0000111# for debugging
112#print env.Dump()
113
José Fonsecac42e6252008-01-31 13:14:35 +0900114
Jose Fonseca50ddf032016-04-13 13:31:04 +0100115# Add a check target for running tests
116check = env.Alias('check')
117env.AlwaysBuild(check)
118
119
José Fonsecac42e6252008-01-31 13:14:35 +0900120#######################################################################
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -0600121# Invoke host SConscripts
122#
José Fonsecae1bc68b2011-01-13 20:52:01 +0000123# For things that are meant to be run on the native host build machine, instead
124# of the target machine.
125#
126
127# Create host environent
José Fonseca41750102011-06-17 14:48:28 +0100128if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +0000129 host_env = Environment(
130 options = opts,
131 # no tool used
132 tools = [],
133 toolpath = ['#scons'],
134 ENV = os.environ,
135 )
136
137 # Override options
138 host_env['platform'] = common.host_platform
139 host_env['machine'] = common.host_machine
140 host_env['toolchain'] = 'default'
141 host_env['llvm'] = False
142
143 host_env.Tool('gallium')
144
José Fonseca982609f2011-02-11 17:38:54 +0000145 host_env['hostonly'] = True
146 assert host_env['crosscompile'] == False
147
José Fonseca9f9d6482011-02-15 15:31:19 +0000148 target_env = env
149 env = host_env
150 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000151
José Fonsecae1bc68b2011-01-13 20:52:01 +0000152 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000153 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000154 variant_dir = host_env['build_dir'],
155 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000156 )
157
José Fonseca9f9d6482011-02-15 15:31:19 +0000158 env = target_env
159
José Fonseca982609f2011-02-11 17:38:54 +0000160Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000161
162#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900163# Invoke SConscripts
164
José Fonsecaf4192cb42008-01-31 14:21:49 +0900165# TODO: Build several variants at the same time?
166# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900167
168SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000169 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100170 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900171 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
172)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000173
José Fonseca10562fb2011-06-17 20:11:50 +0100174
175########################################################################
176# List all aliases
177
178try:
179 from SCons.Node.Alias import default_ans
180except ImportError:
181 pass
182else:
Eric Engestrome3610472017-09-19 13:56:56 +0100183 aliases = sorted(default_ans.keys())
José Fonseca10562fb2011-06-17 20:11:50 +0100184 env.Help('\n')
185 env.Help('Recognized targets:\n')
186 for alias in aliases:
187 env.Help(' %s\n' % alias)