blob: 51dc301a9a86dc474854510990c3389cd9f249d9 [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
José Fonseca94090432008-02-27 17:36:28 +090023import os
24import os.path
25import sys
Alan Hourihane550fc192010-01-26 19:57:34 +000026import SCons.Util
José Fonsecad710a7c2008-02-19 18:53:16 +090027
José Fonseca94090432008-02-27 17:36:28 +090028import common
José Fonseca58a3d7d2008-02-23 19:49:08 +090029
José Fonseca94090432008-02-27 17:36:28 +090030#######################################################################
Juan A. Suarez Romero810c9a42018-08-01 17:48:11 +020031# Minimal scons version
32
33EnsureSConsVersion(2, 4)
Dylan Baker64e46382018-08-14 10:24:29 -070034EnsurePythonVersion(2, 7)
Juan A. Suarez Romero810c9a42018-08-01 17:48:11 +020035
36
37#######################################################################
José Fonseca94090432008-02-27 17:36:28 +090038# Configuration options
39
José Fonsecae9fb90a2009-05-01 16:12:17 +010040opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010041common.AddOptions(opts)
Jonathan White3c819922008-08-29 11:30:32 -060042
José Fonseca81b6a802008-02-06 14:36:50 +090043env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090044 options = opts,
45 tools = ['gallium'],
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060046 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090047 ENV = os.environ,
48)
49
José Fonsecab1156622011-07-01 19:04:57 +010050# XXX: This creates a many problems as it saves...
51#opts.Save('config.py', env)
José Fonsecaef4bf402011-06-17 20:11:35 +010052
José Fonseca601498a2010-11-01 13:30:22 +000053# Backwards compatability with old target configuration variable
54try:
55 targets = ARGUMENTS['targets']
56except KeyError:
57 pass
58else:
59 targets = targets.split(',')
Eric Engestrom7d482192017-09-19 13:56:34 +010060 print('scons: warning: targets option is deprecated; pass the targets on their own such as')
61 print()
62 print(' scons %s' % ' '.join(targets))
63 print()
José Fonseca601498a2010-11-01 13:30:22 +000064 COMMAND_LINE_TARGETS.append(targets)
65
Alan Hourihane6544be62010-01-26 19:14:16 +000066
José Fonsecac42e6252008-01-31 13:14:35 +090067Help(opts.GenerateHelpText(env))
68
José Fonsecac42e6252008-01-31 13:14:35 +090069#######################################################################
70# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090071
Emil Velikov488b3ed2013-07-25 23:45:45 +010072with open("VERSION") as f:
73 mesa_version = f.read().strip()
José Fonsecacff70dc2013-03-13 13:13:08 +000074env.Append(CPPDEFINES = [
Emil Velikov488b3ed2013-07-25 23:45:45 +010075 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
José Fonsecacff70dc2013-03-13 13:13:08 +000076 ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
77])
78
José Fonsecac42e6252008-01-31 13:14:35 +090079# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -070080env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +090081 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -070082])
83env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +000084 '#/src/gallium/include',
85 '#/src/gallium/auxiliary',
86 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +000087 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +090088])
89
José Fonseca4f17bd22008-03-12 13:34:30 +000090# for debugging
91#print env.Dump()
92
José Fonsecac42e6252008-01-31 13:14:35 +090093
Jose Fonseca50ddf032016-04-13 13:31:04 +010094# Add a check target for running tests
95check = env.Alias('check')
96env.AlwaysBuild(check)
97
98
José Fonsecac42e6252008-01-31 13:14:35 +090099#######################################################################
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -0600100# Invoke host SConscripts
101#
José Fonsecae1bc68b2011-01-13 20:52:01 +0000102# For things that are meant to be run on the native host build machine, instead
103# of the target machine.
104#
105
106# Create host environent
José Fonseca41750102011-06-17 14:48:28 +0100107if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +0000108 host_env = Environment(
109 options = opts,
110 # no tool used
111 tools = [],
112 toolpath = ['#scons'],
113 ENV = os.environ,
114 )
115
116 # Override options
117 host_env['platform'] = common.host_platform
118 host_env['machine'] = common.host_machine
119 host_env['toolchain'] = 'default'
120 host_env['llvm'] = False
121
122 host_env.Tool('gallium')
123
José Fonseca982609f2011-02-11 17:38:54 +0000124 host_env['hostonly'] = True
125 assert host_env['crosscompile'] == False
126
José Fonseca9f9d6482011-02-15 15:31:19 +0000127 target_env = env
128 env = host_env
129 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000130
José Fonsecae1bc68b2011-01-13 20:52:01 +0000131 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000132 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000133 variant_dir = host_env['build_dir'],
134 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000135 )
136
José Fonseca9f9d6482011-02-15 15:31:19 +0000137 env = target_env
138
José Fonseca982609f2011-02-11 17:38:54 +0000139Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000140
141#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900142# Invoke SConscripts
143
José Fonsecaf4192cb42008-01-31 14:21:49 +0900144# TODO: Build several variants at the same time?
145# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900146
147SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000148 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100149 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900150 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
151)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000152
José Fonseca10562fb2011-06-17 20:11:50 +0100153
154########################################################################
155# List all aliases
156
157try:
158 from SCons.Node.Alias import default_ans
159except ImportError:
160 pass
161else:
Eric Engestrome3610472017-09-19 13:56:56 +0100162 aliases = sorted(default_ans.keys())
José Fonseca10562fb2011-06-17 20:11:50 +0100163 env.Help('\n')
164 env.Help('Recognized targets:\n')
165 for alias in aliases:
166 env.Help(' %s\n' % alias)