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