José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 1 | ####################################################################### |
| 2 | # Top-level SConstruct |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 3 | # |
| 4 | # For example, invoke scons as |
| 5 | # |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 6 | # scons debug=1 dri=0 machine=x86 |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 7 | # |
| 8 | # to set configuration variables. Or you can write those options to a file |
| 9 | # named config.py: |
| 10 | # |
| 11 | # # config.py |
| 12 | # debug=1 |
| 13 | # dri=0 |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 14 | # machine='x86' |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 15 | # |
| 16 | # Invoke |
| 17 | # |
| 18 | # scons -h |
| 19 | # |
| 20 | # to get the full list of options. See scons manpage for more info. |
| 21 | # |
| 22 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 23 | import os |
| 24 | import os.path |
| 25 | import sys |
Alan Hourihane | 550fc19 | 2010-01-26 19:57:34 +0000 | [diff] [blame] | 26 | import SCons.Util |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 27 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 28 | import common |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 29 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 30 | ####################################################################### |
| 31 | # Configuration options |
| 32 | |
José Fonseca | 6410e94 | 2008-07-13 23:36:59 +0900 | [diff] [blame] | 33 | default_statetrackers = 'mesa' |
Keith Whitwell | 00fe54a | 2010-06-07 16:43:49 +0100 | [diff] [blame] | 34 | default_targets = 'graw-null' |
José Fonseca | 6410e94 | 2008-07-13 23:36:59 +0900 | [diff] [blame] | 35 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 36 | if common.default_platform in ('linux', 'freebsd', 'darwin'): |
Jakob Bornecrantz | 9f7f711 | 2010-05-12 21:11:39 +0100 | [diff] [blame] | 37 | default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe' |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 38 | default_winsys = 'xlib' |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 39 | elif common.default_platform in ('winddk',): |
Jakob Bornecrantz | 9f7f711 | 2010-05-12 21:11:39 +0100 | [diff] [blame] | 40 | default_drivers = 'softpipe,svga,i915,i965,trace,identity' |
José Fonseca | 5a67df6 | 2008-06-03 00:04:19 +0900 | [diff] [blame] | 41 | default_winsys = 'all' |
Alan Hourihane | dea98eb | 2010-01-26 20:58:11 +0000 | [diff] [blame] | 42 | elif common.default_platform in ('embedded',): |
| 43 | default_drivers = 'softpipe,llvmpipe' |
| 44 | default_winsys = 'xlib' |
José Fonseca | 26c57d1 | 2008-02-23 00:46:40 +0900 | [diff] [blame] | 45 | else: |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 46 | default_drivers = 'all' |
| 47 | default_winsys = 'all' |
José Fonseca | e70a431 | 2008-02-24 16:43:07 +0900 | [diff] [blame] | 48 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 49 | opts = Variables('config.py') |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 50 | common.AddOptions(opts) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 51 | opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, |
Chia-I Wu | 1e6c10f | 2010-05-31 11:47:58 +0800 | [diff] [blame] | 52 | ['mesa', 'python', 'xorg', 'egl'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 53 | opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, |
Jakob Bornecrantz | aeee526 | 2010-05-13 20:29:18 +0100 | [diff] [blame] | 54 | ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'r600', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 55 | opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, |
Jakob Bornecrantz | aeee526 | 2010-05-13 20:29:18 +0100 | [diff] [blame] | 56 | ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'r600', 'graw-xlib'])) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 57 | |
Keith Whitwell | 39087f6 | 2010-05-14 10:55:07 +0100 | [diff] [blame] | 58 | opts.Add(ListVariable('targets', 'driver targets to build', default_targets, |
| 59 | ['dri-i915', |
| 60 | 'dri-i965', |
| 61 | 'dri-nouveau', |
| 62 | 'dri-radeong', |
| 63 | 'dri-swrast', |
| 64 | 'dri-vmwgfx', |
| 65 | 'egl-i915', |
| 66 | 'egl-i965', |
| 67 | 'egl-nouveau', |
| 68 | 'egl-radeon', |
| 69 | 'egl-swrast', |
| 70 | 'egl-vmwgfx', |
| 71 | 'graw-xlib', |
Keith Whitwell | 00fe54a | 2010-06-07 16:43:49 +0100 | [diff] [blame] | 72 | 'graw-null', |
Keith Whitwell | 39087f6 | 2010-05-14 10:55:07 +0100 | [diff] [blame] | 73 | 'libgl-gdi', |
| 74 | 'libgl-xlib', |
| 75 | 'xorg-i915', |
| 76 | 'xorg-i965', |
| 77 | 'xorg-nouveau', |
| 78 | 'xorg-radeon', |
| 79 | 'xorg-vmwgfx'])) |
| 80 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 81 | opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) |
Jonathan White | 3c81992 | 2008-08-29 11:30:32 -0600 | [diff] [blame] | 82 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 83 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 84 | options = opts, |
| 85 | tools = ['gallium'], |
José Fonseca | 2c4349a | 2008-07-15 07:56:42 +0900 | [diff] [blame] | 86 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 87 | ENV = os.environ, |
| 88 | ) |
| 89 | |
Alan Hourihane | 6544be6 | 2010-01-26 19:14:16 +0000 | [diff] [blame] | 90 | if os.environ.has_key('CC'): |
| 91 | env['CC'] = os.environ['CC'] |
| 92 | if os.environ.has_key('CFLAGS'): |
| 93 | env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) |
| 94 | if os.environ.has_key('CXX'): |
| 95 | env['CXX'] = os.environ['CXX'] |
| 96 | if os.environ.has_key('CXXFLAGS'): |
| 97 | env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) |
| 98 | if os.environ.has_key('LDFLAGS'): |
| 99 | env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) |
| 100 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 101 | Help(opts.GenerateHelpText(env)) |
| 102 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 103 | # replicate options values in local variables |
| 104 | debug = env['debug'] |
| 105 | dri = env['dri'] |
| 106 | machine = env['machine'] |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 107 | platform = env['platform'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 108 | |
| 109 | # derived options |
| 110 | x86 = machine == 'x86' |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 111 | ppc = machine == 'ppc' |
Alan Hourihane | dea98eb | 2010-01-26 20:58:11 +0000 | [diff] [blame] | 112 | gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 113 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 114 | |
| 115 | Export([ |
| 116 | 'debug', |
| 117 | 'x86', |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 118 | 'ppc', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 119 | 'dri', |
| 120 | 'platform', |
| 121 | 'gcc', |
| 122 | 'msvc', |
| 123 | ]) |
| 124 | |
| 125 | |
| 126 | ####################################################################### |
| 127 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 128 | |
Jakob Bornecrantz | 2c3fb4e | 2010-05-04 12:06:37 +0100 | [diff] [blame] | 129 | # Always build trace, rbug, identity, softpipe, and llvmpipe (where possible) |
José Fonseca | db2e151 | 2010-02-25 17:02:52 +0000 | [diff] [blame] | 130 | if 'trace' not in env['drivers']: |
| 131 | env['drivers'].append('trace') |
Jakob Bornecrantz | 2c3fb4e | 2010-05-04 12:06:37 +0100 | [diff] [blame] | 132 | if 'rbug' not in env['drivers']: |
| 133 | env['drivers'].append('rbug') |
Jakob Bornecrantz | 40d4b41 | 2010-06-28 22:22:53 +0200 | [diff] [blame] | 134 | if 'galahad' not in env['drivers']: |
| 135 | env['drivers'].append('galahad') |
José Fonseca | 78d8e6c | 2010-03-09 17:08:16 +0000 | [diff] [blame] | 136 | if 'identity' not in env['drivers']: |
| 137 | env['drivers'].append('identity') |
José Fonseca | 47a89e9 | 2010-04-10 03:01:30 +0100 | [diff] [blame] | 138 | if 'softpipe' not in env['drivers']: |
| 139 | env['drivers'].append('softpipe') |
| 140 | if env['llvm'] and 'llvmpipe' not in env['drivers']: |
| 141 | env['drivers'].append('llvmpipe') |
Joakim Sindholt | fb08e03 | 2010-06-05 16:53:38 +0200 | [diff] [blame] | 142 | if 'sw' not in env['drivers']: |
| 143 | env['drivers'].append('sw') |
José Fonseca | db2e151 | 2010-02-25 17:02:52 +0000 | [diff] [blame] | 144 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 145 | # Includes |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 146 | env.Prepend(CPPPATH = [ |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 147 | '#/include', |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 148 | ]) |
| 149 | env.Append(CPPPATH = [ |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 150 | '#/src/gallium/include', |
| 151 | '#/src/gallium/auxiliary', |
| 152 | '#/src/gallium/drivers', |
José Fonseca | 601bfb5 | 2010-03-10 10:34:29 +0000 | [diff] [blame] | 153 | '#/src/gallium/winsys', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 154 | ]) |
| 155 | |
José Fonseca | dc6bcc9 | 2010-01-10 10:36:35 +0000 | [diff] [blame] | 156 | if env['msvc']: |
| 157 | env.Append(CPPPATH = ['#include/c99']) |
| 158 | |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 159 | # Embedded |
| 160 | if platform == 'embedded': |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 161 | env.Append(CPPDEFINES = [ |
| 162 | '_POSIX_SOURCE', |
| 163 | ('_POSIX_C_SOURCE', '199309L'), |
| 164 | '_SVID_SOURCE', |
| 165 | '_BSD_SOURCE', |
| 166 | '_GNU_SOURCE', |
| 167 | |
| 168 | 'PTHREADS', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 169 | ]) |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 170 | env.Append(LIBS = [ |
| 171 | 'm', |
| 172 | 'pthread', |
| 173 | 'dl', |
| 174 | ]) |
| 175 | |
| 176 | # Posix |
| 177 | if platform in ('posix', 'linux', 'freebsd', 'darwin'): |
| 178 | env.Append(CPPDEFINES = [ |
| 179 | '_POSIX_SOURCE', |
| 180 | ('_POSIX_C_SOURCE', '199309L'), |
| 181 | '_SVID_SOURCE', |
| 182 | '_BSD_SOURCE', |
| 183 | '_GNU_SOURCE', |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 184 | 'PTHREADS', |
| 185 | 'HAVE_POSIX_MEMALIGN', |
| 186 | ]) |
Jakob Bornecrantz | 2ebe027 | 2010-05-12 22:48:32 +0100 | [diff] [blame] | 187 | if gcc: |
| 188 | env.Append(CFLAGS = ['-fvisibility=hidden']) |
Vinson Lee | d57ba16 | 2010-01-23 21:05:58 -0800 | [diff] [blame] | 189 | if platform == 'darwin': |
| 190 | env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 191 | env.Append(LIBS = [ |
| 192 | 'm', |
| 193 | 'pthread', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 194 | 'dl', |
| 195 | ]) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 196 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 197 | # for debugging |
| 198 | #print env.Dump() |
| 199 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 200 | Export('env') |
| 201 | |
| 202 | |
| 203 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 204 | # Invoke SConscripts |
| 205 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 206 | # TODO: Build several variants at the same time? |
| 207 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 208 | |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 209 | if env['platform'] != common.default_platform: |
| 210 | # GLSL code has to be built twice -- one for the host OS, another for the target OS... |
| 211 | |
| 212 | host_env = Environment( |
| 213 | # options are ignored |
| 214 | # default tool is used |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 215 | tools = ['default', 'custom'], |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 216 | toolpath = ['#scons'], |
| 217 | ENV = os.environ, |
| 218 | ) |
| 219 | |
| 220 | host_env['platform'] = common.default_platform |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 221 | host_env['machine'] = common.default_machine |
| 222 | host_env['debug'] = env['debug'] |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 223 | |
| 224 | SConscript( |
| 225 | 'src/glsl/SConscript', |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 226 | variant_dir = os.path.join(env['build'], 'host'), |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 227 | duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 228 | exports={'env':host_env}, |
| 229 | ) |
| 230 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 231 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 232 | 'src/SConscript', |
José Fonseca | 9bf83fb | 2009-01-24 15:56:28 +0000 | [diff] [blame] | 233 | variant_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 234 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 235 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 236 | |
José Fonseca | 8c7d39c | 2010-02-15 20:48:24 +0000 | [diff] [blame] | 237 | env.Default('src') |
| 238 | |