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 | # XXX: This creates a many problems as it saves...
|
---|
44 | #opts.Save('config.py', env)
|
---|
45 |
|
---|
46 | # Backwards compatability with old target configuration variable
|
---|
47 | try:
|
---|
48 | targets = ARGUMENTS['targets']
|
---|
49 | except KeyError:
|
---|
50 | pass
|
---|
51 | else:
|
---|
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 |
|
---|
60 | Help(opts.GenerateHelpText(env))
|
---|
61 |
|
---|
62 | #######################################################################
|
---|
63 | # Environment setup
|
---|
64 |
|
---|
65 | with open("VERSION") as f:
|
---|
66 | mesa_version = f.read().strip()
|
---|
67 | env.Append(CPPDEFINES = [
|
---|
68 | ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
|
---|
69 | ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
|
---|
70 | ])
|
---|
71 |
|
---|
72 | # Includes
|
---|
73 | env.Prepend(CPPPATH = [
|
---|
74 | '#/include',
|
---|
75 | ])
|
---|
76 | env.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 | # Add a check target for running tests
|
---|
88 | check = env.Alias('check')
|
---|
89 | env.AlwaysBuild(check)
|
---|
90 |
|
---|
91 |
|
---|
92 | #######################################################################
|
---|
93 | # Invoke host SConscripts
|
---|
94 | #
|
---|
95 | # For things that are meant to be run on the native host build machine, instead
|
---|
96 | # of the target machine.
|
---|
97 | #
|
---|
98 |
|
---|
99 | # Create host environent
|
---|
100 | if env['crosscompile'] and not env['embedded']:
|
---|
101 | host_env = Environment(
|
---|
102 | options = opts,
|
---|
103 | # no tool used
|
---|
104 | tools = [],
|
---|
105 | toolpath = ['#scons'],
|
---|
106 | ENV = os.environ,
|
---|
107 | )
|
---|
108 |
|
---|
109 | # Override options
|
---|
110 | host_env['platform'] = common.host_platform
|
---|
111 | host_env['machine'] = common.host_machine
|
---|
112 | host_env['toolchain'] = 'default'
|
---|
113 | host_env['llvm'] = False
|
---|
114 |
|
---|
115 | host_env.Tool('gallium')
|
---|
116 |
|
---|
117 | host_env['hostonly'] = True
|
---|
118 | assert host_env['crosscompile'] == False
|
---|
119 |
|
---|
120 | target_env = env
|
---|
121 | env = host_env
|
---|
122 | Export('env')
|
---|
123 |
|
---|
124 | SConscript(
|
---|
125 | 'src/SConscript',
|
---|
126 | variant_dir = host_env['build_dir'],
|
---|
127 | duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
|
---|
128 | )
|
---|
129 |
|
---|
130 | env = target_env
|
---|
131 |
|
---|
132 | Export('env')
|
---|
133 |
|
---|
134 | #######################################################################
|
---|
135 | # Invoke SConscripts
|
---|
136 |
|
---|
137 | # TODO: Build several variants at the same time?
|
---|
138 | # http://www.scons.org/wiki/SimultaneousVariantBuilds
|
---|
139 |
|
---|
140 | SConscript(
|
---|
141 | 'src/SConscript',
|
---|
142 | variant_dir = env['build_dir'],
|
---|
143 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
|
---|
144 | )
|
---|
145 |
|
---|
146 |
|
---|
147 | ########################################################################
|
---|
148 | # List all aliases
|
---|
149 |
|
---|
150 | try:
|
---|
151 | from SCons.Node.Alias import default_ans
|
---|
152 | except ImportError:
|
---|
153 | pass
|
---|
154 | else:
|
---|
155 | aliases = sorted(default_ans.keys())
|
---|
156 | env.Help('\n')
|
---|
157 | env.Help('Recognized targets:\n')
|
---|
158 | for alias in aliases:
|
---|
159 | env.Help(' %s\n' % alias)
|
---|