104cc38aa638a33e767252a1fc770476a611d901
[mesa.git] / SConstruct
1 #######################################################################
2 # Top-level SConstruct
3 #
4 # For example, invoke scons as
5 #
6 # scons build=debug llvm=yes machine=x86
7 #
8 # to set configuration variables. Or you can write those options to a file
9 # named config.py:
10 #
11 # # config.py
12 # build='debug'
13 # llvm=True
14 # machine='x86'
15 #
16 # Invoke
17 #
18 # scons -h
19 #
20 # to get the full list of options. See scons manpage for more info.
21 #
22
23 import os
24 import os.path
25 import sys
26 import SCons.Util
27
28 import common
29
30 #######################################################################
31 # Configuration options
32
33 opts = Variables('config.py')
34 common.AddOptions(opts)
35
36 env = Environment(
37 options = opts,
38 tools = ['gallium'],
39 toolpath = ['#scons'],
40 ENV = os.environ,
41 )
42
43 # Backwards compatability with old target configuration variable
44 try:
45 targets = ARGUMENTS['targets']
46 except KeyError:
47 pass
48 else:
49 targets = targets.split(',')
50 print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
51 print
52 print ' scons %s' % ' '.join(targets)
53 print
54 COMMAND_LINE_TARGETS.append(targets)
55
56
57 Help(opts.GenerateHelpText(env))
58
59 # fail early for a common error on windows
60 if env['gles']:
61 try:
62 import libxml2
63 except ImportError:
64 raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
65
66 #######################################################################
67 # Environment setup
68
69 # Includes
70 env.Prepend(CPPPATH = [
71 '#/include',
72 ])
73 env.Append(CPPPATH = [
74 '#/src/gallium/include',
75 '#/src/gallium/auxiliary',
76 '#/src/gallium/drivers',
77 '#/src/gallium/winsys',
78 ])
79
80 if env['msvc']:
81 env.Append(CPPPATH = ['#include/c99'])
82
83 # for debugging
84 #print env.Dump()
85
86
87 #######################################################################
88 # 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
95 if env['crosscompile'] and not env['embedded']:
96 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
112 host_env['hostonly'] = True
113 assert host_env['crosscompile'] == False
114
115 if host_env['msvc']:
116 host_env.Append(CPPPATH = ['#include/c99'])
117
118 target_env = env
119 env = host_env
120 Export('env')
121
122 SConscript(
123 'src/SConscript',
124 variant_dir = host_env['build_dir'],
125 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
126 )
127
128 env = target_env
129
130 Export('env')
131
132 #######################################################################
133 # Invoke SConscripts
134
135 # TODO: Build several variants at the same time?
136 # http://www.scons.org/wiki/SimultaneousVariantBuilds
137
138 SConscript(
139 'src/SConscript',
140 variant_dir = env['build_dir'],
141 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
142 )
143