blob: 696718c8eb445341d714094c9f8c09a19fa35fa8 [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#######################################################################
31# Configuration options
32
José Fonsecae9fb90a2009-05-01 16:12:17 +010033opts = Variables('config.py')
José Fonseca13174c12008-03-03 18:52:37 +010034common.AddOptions(opts)
Jonathan White3c819922008-08-29 11:30:32 -060035
José Fonseca81b6a802008-02-06 14:36:50 +090036env = Environment(
José Fonsecab04aa712008-06-06 14:48:57 +090037 options = opts,
38 tools = ['gallium'],
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060039 toolpath = ['#scons'],
José Fonsecab04aa712008-06-06 14:48:57 +090040 ENV = os.environ,
41)
42
José Fonsecab1156622011-07-01 19:04:57 +010043# XXX: This creates a many problems as it saves...
44#opts.Save('config.py', env)
José Fonsecaef4bf402011-06-17 20:11:35 +010045
José Fonseca601498a2010-11-01 13:30:22 +000046# Backwards compatability with old target configuration variable
47try:
48 targets = ARGUMENTS['targets']
49except KeyError:
50 pass
51else:
52 targets = targets.split(',')
53 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
54 print
55 print ' scons %s' % ' '.join(targets)
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060056 print
José Fonseca601498a2010-11-01 13:30:22 +000057 COMMAND_LINE_TARGETS.append(targets)
58
Alan Hourihane6544be62010-01-26 19:14:16 +000059
José Fonsecac42e6252008-01-31 13:14:35 +090060Help(opts.GenerateHelpText(env))
61
José Fonsecac42e6252008-01-31 13:14:35 +090062#######################################################################
63# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090064
Emil Velikov488b3ed2013-07-25 23:45:45 +010065with open("VERSION") as f:
66 mesa_version = f.read().strip()
José Fonsecacff70dc2013-03-13 13:13:08 +000067env.Append(CPPDEFINES = [
Emil Velikov488b3ed2013-07-25 23:45:45 +010068 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
José Fonsecacff70dc2013-03-13 13:13:08 +000069 ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
70])
71
José Fonsecac42e6252008-01-31 13:14:35 +090072# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -070073env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +090074 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -070075])
76env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +000077 '#/src/gallium/include',
78 '#/src/gallium/auxiliary',
79 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +000080 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +090081])
82
José Fonseca4f17bd22008-03-12 13:34:30 +000083# for debugging
84#print env.Dump()
85
José Fonsecac42e6252008-01-31 13:14:35 +090086
Jose Fonseca50ddf032016-04-13 13:31:04 +010087# Add a check target for running tests
88check = env.Alias('check')
89env.AlwaysBuild(check)
90
91
José Fonsecac42e6252008-01-31 13:14:35 +090092#######################################################################
Giuseppe Bilotta8c00fe32016-05-25 07:30:06 -060093# Invoke host SConscripts
94#
José Fonsecae1bc68b2011-01-13 20:52:01 +000095# For things that are meant to be run on the native host build machine, instead
96# of the target machine.
97#
98
99# Create host environent
José Fonseca41750102011-06-17 14:48:28 +0100100if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +0000101 host_env = Environment(
102 options = opts,
103 # no tool used
104 tools = [],
105 toolpath = ['#scons'],
106 ENV = os.environ,
107 )
108
109 # Override options
110 host_env['platform'] = common.host_platform
111 host_env['machine'] = common.host_machine
112 host_env['toolchain'] = 'default'
113 host_env['llvm'] = False
114
115 host_env.Tool('gallium')
116
José Fonseca982609f2011-02-11 17:38:54 +0000117 host_env['hostonly'] = True
118 assert host_env['crosscompile'] == False
119
José Fonseca9f9d6482011-02-15 15:31:19 +0000120 target_env = env
121 env = host_env
122 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000123
José Fonsecae1bc68b2011-01-13 20:52:01 +0000124 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000125 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000126 variant_dir = host_env['build_dir'],
127 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000128 )
129
José Fonseca9f9d6482011-02-15 15:31:19 +0000130 env = target_env
131
José Fonseca982609f2011-02-11 17:38:54 +0000132Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000133
134#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900135# Invoke SConscripts
136
José Fonsecaf4192cb42008-01-31 14:21:49 +0900137# TODO: Build several variants at the same time?
138# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900139
140SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000141 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100142 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900143 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
144)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000145
José Fonseca10562fb2011-06-17 20:11:50 +0100146
147########################################################################
148# List all aliases
149
150try:
151 from SCons.Node.Alias import default_ans
152except ImportError:
153 pass
154else:
155 aliases = default_ans.keys()
156 aliases.sort()
157 env.Help('\n')
158 env.Help('Recognized targets:\n')
159 for alias in aliases:
160 env.Help(' %s\n' % alias)