blob: 6b725c4b6959a7f994ff1a5327cd2bfbb304195a [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é Fonsecaef4bf402011-06-17 20:11:35 +010043opts.Save('config.py', env)
44
José Fonseca601498a2010-11-01 13:30:22 +000045# Backwards compatability with old target configuration variable
46try:
47 targets = ARGUMENTS['targets']
48except KeyError:
49 pass
50else:
51 targets = targets.split(',')
52 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
53 print
54 print ' scons %s' % ' '.join(targets)
55 print
56 COMMAND_LINE_TARGETS.append(targets)
57
Alan Hourihane6544be62010-01-26 19:14:16 +000058
José Fonsecac42e6252008-01-31 13:14:35 +090059Help(opts.GenerateHelpText(env))
60
Chia-I Wubb770af2011-01-14 17:50:29 +080061# fail early for a common error on windows
62if env['gles']:
63 try:
64 import libxml2
65 except ImportError:
66 raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
José Fonsecac42e6252008-01-31 13:14:35 +090067
68#######################################################################
69# Environment setup
José Fonsecac42e6252008-01-31 13:14:35 +090070
71# Includes
Vinson Lee5fd97572010-04-26 01:08:34 -070072env.Prepend(CPPPATH = [
José Fonsecac42e6252008-01-31 13:14:35 +090073 '#/include',
Vinson Lee5fd97572010-04-26 01:08:34 -070074])
75env.Append(CPPPATH = [
José Fonseca33ceb672008-02-18 10:52:44 +000076 '#/src/gallium/include',
77 '#/src/gallium/auxiliary',
78 '#/src/gallium/drivers',
José Fonseca601bfb52010-03-10 10:34:29 +000079 '#/src/gallium/winsys',
José Fonsecac42e6252008-01-31 13:14:35 +090080])
81
José Fonsecadc6bcc92010-01-10 10:36:35 +000082if env['msvc']:
83 env.Append(CPPPATH = ['#include/c99'])
84
José Fonseca4f17bd22008-03-12 13:34:30 +000085# for debugging
86#print env.Dump()
87
José Fonsecac42e6252008-01-31 13:14:35 +090088
89#######################################################################
José Fonsecae1bc68b2011-01-13 20:52:01 +000090# Invoke host SConscripts
91#
92# For things that are meant to be run on the native host build machine, instead
93# of the target machine.
94#
95
96# Create host environent
José Fonseca41750102011-06-17 14:48:28 +010097if env['crosscompile'] and not env['embedded']:
José Fonsecae1bc68b2011-01-13 20:52:01 +000098 host_env = Environment(
99 options = opts,
100 # no tool used
101 tools = [],
102 toolpath = ['#scons'],
103 ENV = os.environ,
104 )
105
106 # Override options
107 host_env['platform'] = common.host_platform
108 host_env['machine'] = common.host_machine
109 host_env['toolchain'] = 'default'
110 host_env['llvm'] = False
111
112 host_env.Tool('gallium')
113
José Fonseca982609f2011-02-11 17:38:54 +0000114 host_env['hostonly'] = True
115 assert host_env['crosscompile'] == False
116
José Fonseca6826d582011-02-11 17:59:36 +0000117 if host_env['msvc']:
118 host_env.Append(CPPPATH = ['#include/c99'])
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