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' |
| 34 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 35 | if common.default_platform in ('linux', 'freebsd', 'darwin'): |
Keith Whitwell | a5585cb | 2009-12-21 19:18:41 +0000 | [diff] [blame] | 36 | default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe' |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 37 | default_winsys = 'xlib' |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 38 | elif common.default_platform in ('winddk',): |
Keith Whitwell | a5585cb | 2009-12-21 19:18:41 +0000 | [diff] [blame] | 39 | default_drivers = 'softpipe,svga,i915,i965,trace,identity' |
José Fonseca | 5a67df6 | 2008-06-03 00:04:19 +0900 | [diff] [blame] | 40 | default_winsys = 'all' |
Alan Hourihane | dea98eb | 2010-01-26 20:58:11 +0000 | [diff] [blame] | 41 | elif common.default_platform in ('embedded',): |
| 42 | default_drivers = 'softpipe,llvmpipe' |
| 43 | default_winsys = 'xlib' |
José Fonseca | 26c57d1 | 2008-02-23 00:46:40 +0900 | [diff] [blame] | 44 | else: |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 45 | default_drivers = 'all' |
| 46 | default_winsys = 'all' |
José Fonseca | e70a431 | 2008-02-24 16:43:07 +0900 | [diff] [blame] | 47 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 48 | opts = Variables('config.py') |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 49 | common.AddOptions(opts) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 50 | opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, |
Michel Dänzer | d22bd14 | 2009-08-25 15:39:05 +0200 | [diff] [blame] | 51 | ['mesa', 'python', 'xorg'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 52 | opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, |
José Fonseca | 89d778f | 2010-01-01 00:22:48 +0000 | [diff] [blame] | 53 | ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 54 | opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, |
Keith Whitwell | a5585cb | 2009-12-21 19:18:41 +0000 | [diff] [blame] | 55 | ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon'])) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 56 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 57 | 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] | 58 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 59 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 60 | options = opts, |
| 61 | tools = ['gallium'], |
José Fonseca | 2c4349a | 2008-07-15 07:56:42 +0900 | [diff] [blame] | 62 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 63 | ENV = os.environ, |
| 64 | ) |
| 65 | |
Alan Hourihane | 6544be6 | 2010-01-26 19:14:16 +0000 | [diff] [blame] | 66 | if os.environ.has_key('CC'): |
| 67 | env['CC'] = os.environ['CC'] |
| 68 | if os.environ.has_key('CFLAGS'): |
| 69 | env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) |
| 70 | if os.environ.has_key('CXX'): |
| 71 | env['CXX'] = os.environ['CXX'] |
| 72 | if os.environ.has_key('CXXFLAGS'): |
| 73 | env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) |
| 74 | if os.environ.has_key('LDFLAGS'): |
| 75 | env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) |
| 76 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 77 | Help(opts.GenerateHelpText(env)) |
| 78 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 79 | # replicate options values in local variables |
| 80 | debug = env['debug'] |
| 81 | dri = env['dri'] |
| 82 | machine = env['machine'] |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 83 | platform = env['platform'] |
Zack Rusin | c61bf36 | 2010-02-08 18:05:22 -0500 | [diff] [blame] | 84 | drawllvm = 'llvmpipe' in env['drivers'] |
| 85 | |
Zack Rusin | 08e2eab | 2010-02-10 00:07:51 -0500 | [diff] [blame] | 86 | # LLVM support in the Draw module |
| 87 | if drawllvm: |
| 88 | env.Tool('llvm') |
| 89 | if not env.has_key('LLVM_VERSION'): |
| 90 | drawllvm = False |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 91 | |
| 92 | # derived options |
| 93 | x86 = machine == 'x86' |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 94 | ppc = machine == 'ppc' |
Alan Hourihane | dea98eb | 2010-01-26 20:58:11 +0000 | [diff] [blame] | 95 | gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 96 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 97 | |
| 98 | Export([ |
| 99 | 'debug', |
| 100 | 'x86', |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 101 | 'ppc', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 102 | 'dri', |
Zack Rusin | c61bf36 | 2010-02-08 18:05:22 -0500 | [diff] [blame] | 103 | 'drawllvm', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 104 | 'platform', |
| 105 | 'gcc', |
| 106 | 'msvc', |
| 107 | ]) |
| 108 | |
| 109 | |
| 110 | ####################################################################### |
| 111 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 112 | |
José Fonseca | db2e151 | 2010-02-25 17:02:52 +0000 | [diff] [blame] | 113 | # Always build trace driver |
| 114 | if 'trace' not in env['drivers']: |
| 115 | env['drivers'].append('trace') |
| 116 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 117 | # Includes |
| 118 | env.Append(CPPPATH = [ |
| 119 | '#/include', |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 120 | '#/src/gallium/include', |
| 121 | '#/src/gallium/auxiliary', |
| 122 | '#/src/gallium/drivers', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 123 | ]) |
| 124 | |
José Fonseca | dc6bcc9 | 2010-01-10 10:36:35 +0000 | [diff] [blame] | 125 | if env['msvc']: |
| 126 | env.Append(CPPPATH = ['#include/c99']) |
| 127 | |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 128 | # Embedded |
| 129 | if platform == 'embedded': |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 130 | env.Append(CPPDEFINES = [ |
| 131 | '_POSIX_SOURCE', |
| 132 | ('_POSIX_C_SOURCE', '199309L'), |
| 133 | '_SVID_SOURCE', |
| 134 | '_BSD_SOURCE', |
| 135 | '_GNU_SOURCE', |
| 136 | |
| 137 | 'PTHREADS', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 138 | ]) |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 139 | env.Append(LIBS = [ |
| 140 | 'm', |
| 141 | 'pthread', |
| 142 | 'dl', |
| 143 | ]) |
| 144 | |
| 145 | # Posix |
| 146 | if platform in ('posix', 'linux', 'freebsd', 'darwin'): |
| 147 | env.Append(CPPDEFINES = [ |
| 148 | '_POSIX_SOURCE', |
| 149 | ('_POSIX_C_SOURCE', '199309L'), |
| 150 | '_SVID_SOURCE', |
| 151 | '_BSD_SOURCE', |
| 152 | '_GNU_SOURCE', |
| 153 | |
| 154 | 'PTHREADS', |
| 155 | 'HAVE_POSIX_MEMALIGN', |
| 156 | ]) |
Vinson Lee | d57ba16 | 2010-01-23 21:05:58 -0800 | [diff] [blame] | 157 | if platform == 'darwin': |
| 158 | env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 159 | env.Append(CPPPATH = ['/usr/X11R6/include']) |
| 160 | env.Append(LIBPATH = ['/usr/X11R6/lib']) |
| 161 | env.Append(LIBS = [ |
| 162 | 'm', |
| 163 | 'pthread', |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 164 | 'expat', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 165 | 'dl', |
| 166 | ]) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 167 | |
| 168 | # DRI |
| 169 | if dri: |
| 170 | env.ParseConfig('pkg-config --cflags --libs libdrm') |
| 171 | env.Append(CPPDEFINES = [ |
| 172 | ('USE_EXTERNAL_DXTN_LIB', '1'), |
| 173 | 'IN_DRI_DRIVER', |
| 174 | 'GLX_DIRECT_RENDERING', |
| 175 | 'GLX_INDIRECT_RENDERING', |
| 176 | ]) |
| 177 | |
Zack Rusin | c61bf36 | 2010-02-08 18:05:22 -0500 | [diff] [blame] | 178 | # LLVM support in the Draw module |
| 179 | if drawllvm: |
Zack Rusin | 08e2eab | 2010-02-10 00:07:51 -0500 | [diff] [blame] | 180 | env.Append(CPPDEFINES = ['DRAW_LLVM']) |
José Fonseca | e773a81 | 2008-02-19 10:50:39 +0900 | [diff] [blame] | 181 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 182 | # libGL |
José Fonseca | a7ce6d3 | 2008-04-25 19:53:13 +0900 | [diff] [blame] | 183 | if platform in ('linux', 'freebsd', 'darwin'): |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 184 | env.Append(LIBS = [ |
| 185 | 'X11', |
| 186 | 'Xext', |
| 187 | 'Xxf86vm', |
| 188 | 'Xdamage', |
| 189 | 'Xfixes', |
| 190 | ]) |
| 191 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 192 | # for debugging |
| 193 | #print env.Dump() |
| 194 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 195 | Export('env') |
| 196 | |
| 197 | |
| 198 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 199 | # Invoke SConscripts |
| 200 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 201 | # TODO: Build several variants at the same time? |
| 202 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 203 | |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 204 | if env['platform'] != common.default_platform: |
| 205 | # GLSL code has to be built twice -- one for the host OS, another for the target OS... |
| 206 | |
| 207 | host_env = Environment( |
| 208 | # options are ignored |
| 209 | # default tool is used |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 210 | tools = ['default', 'custom'], |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 211 | toolpath = ['#scons'], |
| 212 | ENV = os.environ, |
| 213 | ) |
| 214 | |
| 215 | host_env['platform'] = common.default_platform |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 216 | host_env['machine'] = common.default_machine |
| 217 | host_env['debug'] = env['debug'] |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 218 | |
| 219 | SConscript( |
| 220 | 'src/glsl/SConscript', |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 221 | variant_dir = os.path.join(env['build'], 'host'), |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 222 | duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 223 | exports={'env':host_env}, |
| 224 | ) |
| 225 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 226 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 227 | 'src/SConscript', |
José Fonseca | 9bf83fb | 2009-01-24 15:56:28 +0000 | [diff] [blame] | 228 | variant_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 229 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 230 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 231 | |
José Fonseca | 8c7d39c | 2010-02-15 20:48:24 +0000 | [diff] [blame] | 232 | env.Default('src') |
| 233 | |
| 234 | SConscript( |
| 235 | 'progs/SConscript', |
| 236 | variant_dir = os.path.join('progs', env['build']), |
| 237 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 238 | ) |