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, |
Vinson Lee | bd93670 | 2010-04-24 16:22:47 -0700 | [diff] [blame] | 53 | ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx'])) |
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 | db5c223 | 2010-03-28 09:53:58 -0700 | [diff] [blame] | 55 | ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) |
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'] |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 84 | |
| 85 | # derived options |
| 86 | x86 = machine == 'x86' |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 87 | ppc = machine == 'ppc' |
Alan Hourihane | dea98eb | 2010-01-26 20:58:11 +0000 | [diff] [blame] | 88 | gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded') |
José Fonseca | 35460fc | 2008-04-25 18:16:25 +0900 | [diff] [blame] | 89 | msvc = platform in ('windows', 'winddk') |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 90 | |
| 91 | Export([ |
| 92 | 'debug', |
| 93 | 'x86', |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 94 | 'ppc', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 95 | 'dri', |
| 96 | 'platform', |
| 97 | 'gcc', |
| 98 | 'msvc', |
| 99 | ]) |
| 100 | |
| 101 | |
| 102 | ####################################################################### |
| 103 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 104 | |
José Fonseca | 47a89e9 | 2010-04-10 03:01:30 +0100 | [diff] [blame] | 105 | # Always build trace, identity, softpipe, and llvmpipe (where possible) |
José Fonseca | db2e151 | 2010-02-25 17:02:52 +0000 | [diff] [blame] | 106 | if 'trace' not in env['drivers']: |
| 107 | env['drivers'].append('trace') |
José Fonseca | 78d8e6c | 2010-03-09 17:08:16 +0000 | [diff] [blame] | 108 | if 'identity' not in env['drivers']: |
| 109 | env['drivers'].append('identity') |
José Fonseca | 47a89e9 | 2010-04-10 03:01:30 +0100 | [diff] [blame] | 110 | if 'softpipe' not in env['drivers']: |
| 111 | env['drivers'].append('softpipe') |
| 112 | if env['llvm'] and 'llvmpipe' not in env['drivers']: |
| 113 | env['drivers'].append('llvmpipe') |
José Fonseca | db2e151 | 2010-02-25 17:02:52 +0000 | [diff] [blame] | 114 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 115 | # Includes |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 116 | env.Prepend(CPPPATH = [ |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 117 | '#/include', |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 118 | ]) |
| 119 | env.Append(CPPPATH = [ |
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 | 601bfb5 | 2010-03-10 10:34:29 +0000 | [diff] [blame] | 123 | '#/src/gallium/winsys', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 124 | ]) |
| 125 | |
José Fonseca | dc6bcc9 | 2010-01-10 10:36:35 +0000 | [diff] [blame] | 126 | if env['msvc']: |
| 127 | env.Append(CPPPATH = ['#include/c99']) |
| 128 | |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 129 | # Embedded |
| 130 | if platform == 'embedded': |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 131 | env.Append(CPPDEFINES = [ |
| 132 | '_POSIX_SOURCE', |
| 133 | ('_POSIX_C_SOURCE', '199309L'), |
| 134 | '_SVID_SOURCE', |
| 135 | '_BSD_SOURCE', |
| 136 | '_GNU_SOURCE', |
| 137 | |
| 138 | 'PTHREADS', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 139 | ]) |
Alan Hourihane | 32e6043 | 2010-01-28 17:26:05 +0000 | [diff] [blame] | 140 | env.Append(LIBS = [ |
| 141 | 'm', |
| 142 | 'pthread', |
| 143 | 'dl', |
| 144 | ]) |
| 145 | |
| 146 | # Posix |
| 147 | if platform in ('posix', 'linux', 'freebsd', 'darwin'): |
| 148 | env.Append(CPPDEFINES = [ |
| 149 | '_POSIX_SOURCE', |
| 150 | ('_POSIX_C_SOURCE', '199309L'), |
| 151 | '_SVID_SOURCE', |
| 152 | '_BSD_SOURCE', |
| 153 | '_GNU_SOURCE', |
| 154 | |
| 155 | 'PTHREADS', |
| 156 | 'HAVE_POSIX_MEMALIGN', |
| 157 | ]) |
Vinson Lee | d57ba16 | 2010-01-23 21:05:58 -0800 | [diff] [blame] | 158 | if platform == 'darwin': |
| 159 | env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 160 | env.Append(LIBS = [ |
| 161 | 'm', |
| 162 | 'pthread', |
José Fonseca | 0013796 | 2008-02-07 19:59:17 +0900 | [diff] [blame] | 163 | 'dl', |
| 164 | ]) |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 165 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 166 | # for debugging |
| 167 | #print env.Dump() |
| 168 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 169 | Export('env') |
| 170 | |
| 171 | |
| 172 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 173 | # Invoke SConscripts |
| 174 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 175 | # TODO: Build several variants at the same time? |
| 176 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 177 | |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 178 | if env['platform'] != common.default_platform: |
| 179 | # GLSL code has to be built twice -- one for the host OS, another for the target OS... |
| 180 | |
| 181 | host_env = Environment( |
| 182 | # options are ignored |
| 183 | # default tool is used |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 184 | tools = ['default', 'custom'], |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 185 | toolpath = ['#scons'], |
| 186 | ENV = os.environ, |
| 187 | ) |
| 188 | |
| 189 | host_env['platform'] = common.default_platform |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 190 | host_env['machine'] = common.default_machine |
| 191 | host_env['debug'] = env['debug'] |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 192 | |
| 193 | SConscript( |
| 194 | 'src/glsl/SConscript', |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 195 | variant_dir = os.path.join(env['build'], 'host'), |
José Fonseca | 491f384 | 2009-12-10 16:29:04 +0000 | [diff] [blame] | 196 | duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 197 | exports={'env':host_env}, |
| 198 | ) |
| 199 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 200 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 201 | 'src/SConscript', |
José Fonseca | 9bf83fb | 2009-01-24 15:56:28 +0000 | [diff] [blame] | 202 | variant_dir = env['build'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 203 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 204 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 205 | |
José Fonseca | 8c7d39c | 2010-02-15 20:48:24 +0000 | [diff] [blame] | 206 | env.Default('src') |
| 207 | |
| 208 | SConscript( |
| 209 | 'progs/SConscript', |
| 210 | variant_dir = os.path.join('progs', env['build']), |
| 211 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 212 | ) |