blob: b00a7fe1c989fdf4fffa70e10f2ba8a7a292711f [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
Chia-I Wubb770af2011-01-14 17:50:29 +080062# fail early for a common error on windows
63if env['gles']:
64 try:
65 import libxml2
66 except ImportError:
67 raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
José Fonsecac42e6252008-01-31 13:14:35 +090068
69#######################################################################
70# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090071
José Fonsecacff70dc2013-03-13 13:13:08 +000072env.Append(CPPDEFINES = [
Kenneth Graunkea8c8c5f2013-07-25 13:33:02 -070073 ('PACKAGE_VERSION', '\\"9.3.0-devel\\"'),
José Fonsecacff70dc2013-03-13 13:13:08 +000074 ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
75])
76
José Fonsecac42e6252008-01-31 13:14:35 +090077# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -070078env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +090079 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -070080])
81env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +000082 '#/src/gallium/include',
83 '#/src/gallium/auxiliary',
84 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +000085 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +090086])
87
José Fonsecadc6bcc92010-01-10 10:36:35 +000088if env['msvc']:
89 env.Append(CPPPATH = ['#include/c99'])
90
José Fonseca4f17bd22008-03-12 13:34:30 +000091# for debugging
92#print env.Dump()
93
José Fonsecac42e6252008-01-31 13:14:35 +090094
95#######################################################################
José Fonsecae1bc68b2011-01-13 20:52:01 +000096# Invoke host SConscripts
97#
98# For things that are meant to be run on the native host build machine, instead
99# of the target machine.
100#
101
102# Create host environent
José Fonseca41750102011-06-17 14:48:28 +0100103if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +0000104 host_env = Environment(
105 options = opts,
106 # no tool used
107 tools = [],
108 toolpath = ['#scons'],
109 ENV = os.environ,
110 )
111
112 # Override options
113 host_env['platform'] = common.host_platform
114 host_env['machine'] = common.host_machine
115 host_env['toolchain'] = 'default'
116 host_env['llvm'] = False
117
118 host_env.Tool('gallium')
119
José Fonseca982609f2011-02-11 17:38:54 +0000120 host_env['hostonly'] = True
121 assert host_env['crosscompile'] == False
122
José Fonseca6826d582011-02-11 17:59:36 +0000123 if host_env['msvc']:
124 host_env.Append(CPPPATH = ['#include/c99'])
125
José Fonseca9f9d6482011-02-15 15:31:19 +0000126 target_env = env
127 env = host_env
128 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000129
José Fonsecae1bc68b2011-01-13 20:52:01 +0000130 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000131 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000132 variant_dir = host_env['build_dir'],
133 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000134 )
135
José Fonseca9f9d6482011-02-15 15:31:19 +0000136 env = target_env
137
José Fonseca982609f2011-02-11 17:38:54 +0000138Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000139
140#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900141# Invoke SConscripts
142
José Fonsecaf4192cb42008-01-31 14:21:49 +0900143# TODO: Build several variants at the same time?
144# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900145
146SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000147 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100148 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900149 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
150)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000151
José Fonseca10562fb2011-06-17 20:11:50 +0100152
153########################################################################
154# List all aliases
155
156try:
157 from SCons.Node.Alias import default_ans
158except ImportError:
159 pass
160else:
161 aliases = default_ans.keys()
162 aliases.sort()
163 env.Help('\n')
164 env.Help('Recognized targets:\n')
165 for alias in aliases:
166 env.Help(' %s\n' % alias)