SConstruct revision 41750107496858a047afa8d81d20fe903f285a78
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 23import os 24import os.path 25import sys 26import SCons.Util 27 28import common 29 30####################################################################### 31# Configuration options 32 33opts = Variables('config.py') 34common.AddOptions(opts) 35 36env = Environment( 37 options = opts, 38 tools = ['gallium'], 39 toolpath = ['#scons'], 40 ENV = os.environ, 41) 42 43# Backwards compatability with old target configuration variable 44try: 45 targets = ARGUMENTS['targets'] 46except KeyError: 47 pass 48else: 49 targets = targets.split(',') 50 print 'scons: warning: targets option is deprecated; pass the targets on their own such as' 51 print 52 print ' scons %s' % ' '.join(targets) 53 print 54 COMMAND_LINE_TARGETS.append(targets) 55 56 57Help(opts.GenerateHelpText(env)) 58 59# fail early for a common error on windows 60if env['gles']: 61 try: 62 import libxml2 63 except ImportError: 64 raise SCons.Errors.UserError, "GLES requires libxml2-python to build" 65 66####################################################################### 67# Environment setup 68 69# Includes 70env.Prepend(CPPPATH = [ 71 '#/include', 72]) 73env.Append(CPPPATH = [ 74 '#/src/gallium/include', 75 '#/src/gallium/auxiliary', 76 '#/src/gallium/drivers', 77 '#/src/gallium/winsys', 78]) 79 80if env['msvc']: 81 env.Append(CPPPATH = ['#include/c99']) 82 83# Posix 84if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'): 85 env.Append(CPPDEFINES = [ 86 '_POSIX_SOURCE', 87 ('_POSIX_C_SOURCE', '199309L'), 88 '_SVID_SOURCE', 89 '_BSD_SOURCE', 90 '_GNU_SOURCE', 91 'PTHREADS', 92 'HAVE_POSIX_MEMALIGN', 93 ]) 94 if env['gcc']: 95 env.Append(CFLAGS = ['-fvisibility=hidden']) 96 if env['platform'] == 'darwin': 97 env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) 98 env.Append(LIBS = [ 99 'm', 100 'pthread', 101 'dl', 102 ]) 103 104# for debugging 105#print env.Dump() 106 107 108####################################################################### 109# Invoke host SConscripts 110# 111# For things that are meant to be run on the native host build machine, instead 112# of the target machine. 113# 114 115# Create host environent 116if env['crosscompile'] and not env['embedded']: 117 host_env = Environment( 118 options = opts, 119 # no tool used 120 tools = [], 121 toolpath = ['#scons'], 122 ENV = os.environ, 123 ) 124 125 # Override options 126 host_env['platform'] = common.host_platform 127 host_env['machine'] = common.host_machine 128 host_env['toolchain'] = 'default' 129 host_env['llvm'] = False 130 131 host_env.Tool('gallium') 132 133 host_env['hostonly'] = True 134 assert host_env['crosscompile'] == False 135 136 if host_env['msvc']: 137 host_env.Append(CPPPATH = ['#include/c99']) 138 139 target_env = env 140 env = host_env 141 Export('env') 142 143 SConscript( 144 'src/SConscript', 145 variant_dir = host_env['build_dir'], 146 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 147 ) 148 149 env = target_env 150 151Export('env') 152 153####################################################################### 154# Invoke SConscripts 155 156# TODO: Build several variants at the same time? 157# http://www.scons.org/wiki/SimultaneousVariantBuilds 158 159SConscript( 160 'src/SConscript', 161 variant_dir = env['build_dir'], 162 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 163) 164 165