SConstruct revision 848b8605
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
23import os
24import os.path
25import sys
26import SCons.Util
27
28import common
29
30#######################################################################
31# Configuration options
32
33opts = Variables('config.py')
34common.AddOptions(opts)
35
36env = Environment(
37	options = opts,
38	tools = ['gallium'],
39	toolpath = ['#scons'],	
40	ENV = os.environ,
41)
42
43# XXX: This creates a many problems as it saves...
44#opts.Save('config.py', env)
45
46# 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
59
60Help(opts.GenerateHelpText(env))
61
62#######################################################################
63# Environment setup
64
65with open("VERSION") as f:
66  mesa_version = f.read().strip()
67env.Append(CPPDEFINES = [
68    ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
69    ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
70])
71
72# Includes
73env.Prepend(CPPPATH = [
74	'#/include',
75])
76env.Append(CPPPATH = [
77	'#/src/gallium/include',
78	'#/src/gallium/auxiliary',
79	'#/src/gallium/drivers',
80	'#/src/gallium/winsys',
81])
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
95if 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    target_env = env
116    env = host_env
117    Export('env')
118
119    SConscript(
120        'src/SConscript',
121        variant_dir = host_env['build_dir'],
122        duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
123    )
124
125    env = target_env
126
127Export('env')
128
129#######################################################################
130# Invoke SConscripts
131
132# TODO: Build several variants at the same time?
133# http://www.scons.org/wiki/SimultaneousVariantBuilds
134
135SConscript(
136	'src/SConscript',
137	variant_dir = env['build_dir'],
138	duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
139)
140
141
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)
156