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# Minimal scons version 32 33EnsureSConsVersion(2, 4) 34EnsurePythonVersion(2, 7) 35 36 37####################################################################### 38# Configuration options 39 40opts = Variables('config.py') 41common.AddOptions(opts) 42 43env = Environment( 44 options = opts, 45 tools = ['gallium'], 46 toolpath = ['#scons'], 47 ENV = os.environ, 48) 49 50# XXX: This creates a many problems as it saves... 51#opts.Save('config.py', env) 52 53# Backwards compatability with old target configuration variable 54try: 55 targets = ARGUMENTS['targets'] 56except KeyError: 57 pass 58else: 59 targets = targets.split(',') 60 print('scons: warning: targets option is deprecated; pass the targets on their own such as') 61 print() 62 print(' scons %s' % ' '.join(targets)) 63 print() 64 COMMAND_LINE_TARGETS.append(targets) 65 66 67Help(opts.GenerateHelpText(env)) 68 69####################################################################### 70# Environment setup 71 72with open("VERSION") as f: 73 mesa_version = f.read().strip() 74env.Append(CPPDEFINES = [ 75 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version), 76 ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'), 77]) 78 79# Includes 80env.Prepend(CPPPATH = [ 81 '#/include', 82]) 83env.Append(CPPPATH = [ 84 '#/src/gallium/include', 85 '#/src/gallium/auxiliary', 86 '#/src/gallium/drivers', 87 '#/src/gallium/winsys', 88]) 89 90# for debugging 91#print env.Dump() 92 93 94# Add a check target for running tests 95check = env.Alias('check') 96env.AlwaysBuild(check) 97 98 99####################################################################### 100# Invoke host SConscripts 101# 102# For things that are meant to be run on the native host build machine, instead 103# of the target machine. 104# 105 106# Create host environent 107if env['crosscompile'] and not env['embedded']: 108 host_env = Environment( 109 options = opts, 110 # no tool used 111 tools = [], 112 toolpath = ['#scons'], 113 ENV = os.environ, 114 ) 115 116 # Override options 117 host_env['platform'] = common.host_platform 118 host_env['machine'] = common.host_machine 119 host_env['toolchain'] = 'default' 120 host_env['llvm'] = False 121 122 host_env.Tool('gallium') 123 124 host_env['hostonly'] = True 125 assert host_env['crosscompile'] == False 126 127 target_env = env 128 env = host_env 129 Export('env') 130 131 SConscript( 132 'src/SConscript', 133 variant_dir = host_env['build_dir'], 134 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 135 ) 136 137 env = target_env 138 139Export('env') 140 141####################################################################### 142# Invoke SConscripts 143 144# TODO: Build several variants at the same time? 145# http://www.scons.org/wiki/SimultaneousVariantBuilds 146 147SConscript( 148 'src/SConscript', 149 variant_dir = env['build_dir'], 150 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 151) 152 153 154######################################################################## 155# List all aliases 156 157try: 158 from SCons.Node.Alias import default_ans 159except ImportError: 160 pass 161else: 162 aliases = sorted(default_ans.keys()) 163 env.Help('\n') 164 env.Help('Recognized targets:\n') 165 for alias in aliases: 166 env.Help(' %s\n' % alias) 167