blob: 4a3fef0805942f904618ebcff889dcc41b408d0f [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
72# 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é Fonsecadc6bcc92010-01-10 10:36:35 +000083if env['msvc']:
84 env.Append(CPPPATH = ['#include/c99'])
85
José Fonseca4f17bd22008-03-12 13:34:30 +000086# for debugging
87#print env.Dump()
88
José Fonsecac42e6252008-01-31 13:14:35 +090089
90#######################################################################
José Fonsecae1bc68b2011-01-13 20:52:01 +000091# Invoke host SConscripts
92#
93# For things that are meant to be run on the native host build machine, instead
94# of the target machine.
95#
96
97# Create host environent
José Fonseca41750102011-06-17 14:48:28 +010098if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +000099 host_env = Environment(
100 options = opts,
101 # no tool used
102 tools = [],
103 toolpath = ['#scons'],
104 ENV = os.environ,
105 )
106
107 # Override options
108 host_env['platform'] = common.host_platform
109 host_env['machine'] = common.host_machine
110 host_env['toolchain'] = 'default'
111 host_env['llvm'] = False
112
113 host_env.Tool('gallium')
114
José Fonseca982609f2011-02-11 17:38:54 +0000115 host_env['hostonly'] = True
116 assert host_env['crosscompile'] == False
117
José Fonseca6826d582011-02-11 17:59:36 +0000118 if host_env['msvc']:
119 host_env.Append(CPPPATH = ['#include/c99'])
120
José Fonseca9f9d6482011-02-15 15:31:19 +0000121 target_env = env
122 env = host_env
123 Export('env')
José Fonseca982609f2011-02-11 17:38:54 +0000124
José Fonsecae1bc68b2011-01-13 20:52:01 +0000125 SConscript(
José Fonseca982609f2011-02-11 17:38:54 +0000126 'src/SConscript',
José Fonsecae1bc68b2011-01-13 20:52:01 +0000127 variant_dir = host_env['build_dir'],
128 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
José Fonsecae1bc68b2011-01-13 20:52:01 +0000129 )
130
José Fonseca9f9d6482011-02-15 15:31:19 +0000131 env = target_env
132
José Fonseca982609f2011-02-11 17:38:54 +0000133Export('env')
José Fonsecae1bc68b2011-01-13 20:52:01 +0000134
135#######################################################################
José Fonsecac42e6252008-01-31 13:14:35 +0900136# Invoke SConscripts
137
José Fonsecaf4192cb42008-01-31 14:21:49 +0900138# TODO: Build several variants at the same time?
139# http://www.scons.org/wiki/SimultaneousVariantBuilds
José Fonsecac42e6252008-01-31 13:14:35 +0900140
141SConscript(
José Fonseca33ceb672008-02-18 10:52:44 +0000142 'src/SConscript',
José Fonseca67450f02010-09-29 14:08:53 +0100143 variant_dir = env['build_dir'],
José Fonsecac42e6252008-01-31 13:14:35 +0900144 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
145)
José Fonseca7bbf7f92009-12-31 21:10:25 +0000146
José Fonseca10562fb2011-06-17 20:11:50 +0100147
148########################################################################
149# List all aliases
150
151try:
152 from SCons.Node.Alias import default_ans
153except ImportError:
154 pass
155else:
156 aliases = default_ans.keys()
157 aliases.sort()
158 env.Help('\n')
159 env.Help('Recognized targets:\n')
160 for alias in aliases:
161 env.Help(' %s\n' % alias)