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 23from __future__ import print_function 24import os 25import os.path 26import sys 27import SCons.Util 28 29import common 30 31####################################################################### 32# Minimal scons version 33 34EnsureSConsVersion(2, 4) 35EnsurePythonVersion(2, 7) 36 37 38####################################################################### 39# Configuration options 40 41opts = Variables('config.py') 42common.AddOptions(opts) 43 44env = Environment( 45 options = opts, 46 tools = ['gallium'], 47 toolpath = ['#scons'], 48 ENV = os.environ, 49) 50 51# XXX: This creates a many problems as it saves... 52#opts.Save('config.py', env) 53 54# Backwards compatability with old target configuration variable 55try: 56 targets = ARGUMENTS['targets'] 57except KeyError: 58 pass 59else: 60 targets = targets.split(',') 61 print('scons: warning: targets option is deprecated; pass the targets on their own such as') 62 print() 63 print(' scons %s' % ' '.join(targets)) 64 print() 65 COMMAND_LINE_TARGETS.append(targets) 66 67 68Help(opts.GenerateHelpText(env)) 69 70 71####################################################################### 72# Print a deprecation warning for using scons on non-windows 73 74if common.host_platform != 'windows' and env['platform'] != 'windows': 75 if env['force_scons']: 76 print("WARNING: Scons is deprecated for non-windows platforms (including cygwin) " 77 "please use meson instead.", file=sys.stderr) 78 else: 79 print("ERROR: Scons is deprecated for non-windows platforms (including cygwin) " 80 "please use meson instead. If you really need to use scons you " 81 "can add `force_scons=1` to the scons command line.", file=sys.stderr) 82 sys.exit(1) 83else: 84 print("WARNING: Scons support is in the process of being deprecated on " 85 "on windows platforms (including mingw). If you haven't already " 86 "please try using meson for windows builds. Be sure to report any " 87 "issues you run into", file=sys.stderr) 88 89 90####################################################################### 91# Environment setup 92 93with open("VERSION") as f: 94 mesa_version = f.read().strip() 95env.Append(CPPDEFINES = [ 96 ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version), 97 ('PACKAGE_BUGREPORT', '\\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\\"'), 98]) 99 100# Includes 101env.Prepend(CPPPATH = [ 102 '#/include', 103]) 104env.Append(CPPPATH = [ 105 '#/src/gallium/include', 106 '#/src/gallium/auxiliary', 107 '#/src/gallium/drivers', 108 '#/src/gallium/winsys', 109]) 110 111# for debugging 112#print env.Dump() 113 114 115# Add a check target for running tests 116check = env.Alias('check') 117env.AlwaysBuild(check) 118 119 120####################################################################### 121# Invoke host SConscripts 122# 123# For things that are meant to be run on the native host build machine, instead 124# of the target machine. 125# 126 127# Create host environent 128if env['crosscompile'] and not env['embedded']: 129 host_env = Environment( 130 options = opts, 131 # no tool used 132 tools = [], 133 toolpath = ['#scons'], 134 ENV = os.environ, 135 ) 136 137 # Override options 138 host_env['platform'] = common.host_platform 139 host_env['machine'] = common.host_machine 140 host_env['toolchain'] = 'default' 141 host_env['llvm'] = False 142 143 host_env.Tool('gallium') 144 145 host_env['hostonly'] = True 146 assert host_env['crosscompile'] == False 147 148 target_env = env 149 env = host_env 150 Export('env') 151 152 SConscript( 153 'src/SConscript', 154 variant_dir = host_env['build_dir'], 155 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 156 ) 157 158 env = target_env 159 160Export('env') 161 162####################################################################### 163# Invoke SConscripts 164 165# TODO: Build several variants at the same time? 166# http://www.scons.org/wiki/SimultaneousVariantBuilds 167 168SConscript( 169 'src/SConscript', 170 variant_dir = env['build_dir'], 171 duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html 172) 173 174 175######################################################################## 176# List all aliases 177 178try: 179 from SCons.Node.Alias import default_ans 180except ImportError: 181 pass 182else: 183 aliases = sorted(default_ans.keys()) 184 env.Help('\n') 185 env.Help('Recognized targets:\n') 186 for alias in aliases: 187 env.Help(' %s\n' % alias) 188