blob: ef71ab69c3844cd0a3837f76f34d639ea460cd79 [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
2# Top-level SConstruct
José Fonsecac42e6252008-01-31 13:14:35 +09003#
4# For example, invoke scons as
5#
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'
José Fonsecac42e6252008-01-31 13:14:35 +090015#
16# Invoke
17#
18# scons -h
19#
20# to get the full list of options. See scons manpage for more info.
21#
22
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'],
José Fonseca2c4349a2008-07-15 07:56:42 +090039 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)
56 print
57 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
87#######################################################################
José Fonsecae1bc68b2011-01-13 20:52:01 +000088# Invoke host SConscripts
89#
90# For things that are meant to be run on the native host build machine, instead
91# of the target machine.
92#
93
94# Create host environent
José Fonseca41750102011-06-17 14:48:28 +010095if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +000096 host_env = Environment(
97 options = opts,
98 # no tool used
99 tools = [],
100 toolpath = ['#scons'],
101 ENV = os.environ,
102 )
103
104 # Override options
105 host_env['platform'] = common.host_platform
106 host_env['machine'] = common.host_machine
107 host_env['toolchain'] = 'default'
108 host_env['llvm'] = False
109
110 host_env.Tool('gallium')
111
José Fonseca982609f2011-02-11 17:38:54 +0000112 host_env['hostonly'] = True
113 assert host_env['crosscompile'] == False
114
José Fonseca9f9d6482011-02-15 15:31:19 +0000115 target_env = env
116 env = host_env
117 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000118
José Fonsecae1bc68b2011-01-13 20:52:01 +0000119 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000120 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000121 variant_dir = host_env['build_dir'],
122 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000123 )
124
José Fonseca9f9d6482011-02-15 15:31:19 +0000125 env = target_env
126
José Fonseca982609f2011-02-11 17:38:54 +0000127Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000128
129#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900130# Invoke SConscripts
131
José Fonsecaf4192cb42008-01-31 14:21:49 +0900132# TODO: Build several variants at the same time?
133# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900134
135SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000136 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100137 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900138 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
139)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000140
José Fonseca10562fb2011-06-17 20:11:50 +0100141
142########################################################################
143# List all aliases
144
145try:
146 from SCons.Node.Alias import default_ans
147except ImportError:
148 pass
149else:
150 aliases = default_ans.keys()
151 aliases.sort()
152 env.Help('\n')
153 env.Help('Recognized targets:\n')
154 for alias in aliases:
155 env.Help(' %s\n' % alias)