Home | History | Annotate | Line # | Download | only in dist
      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 
     23 import os
     24 import os.path
     25 import sys
     26 import SCons.Util
     27 
     28 import common
     29 
     30 #######################################################################
     31 # Minimal scons version
     32 
     33 EnsureSConsVersion(2, 4)
     34 EnsurePythonVersion(2, 7)
     35 
     36 
     37 #######################################################################
     38 # Configuration options
     39 
     40 opts = Variables('config.py')
     41 common.AddOptions(opts)
     42 
     43 env = 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
     54 try:
     55     targets = ARGUMENTS['targets']
     56 except KeyError:
     57     pass
     58 else:
     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 
     67 Help(opts.GenerateHelpText(env))
     68 
     69 #######################################################################
     70 # Environment setup
     71 
     72 with open("VERSION") as f:
     73   mesa_version = f.read().strip()
     74 env.Append(CPPDEFINES = [
     75     ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
     76     ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'),
     77 ])
     78 
     79 # Includes
     80 env.Prepend(CPPPATH = [
     81 	'#/include',
     82 ])
     83 env.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
     95 check = env.Alias('check')
     96 env.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
    107 if 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 
    139 Export('env')
    140 
    141 #######################################################################
    142 # Invoke SConscripts
    143 
    144 # TODO: Build several variants at the same time?
    145 # http://www.scons.org/wiki/SimultaneousVariantBuilds
    146 
    147 SConscript(
    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 
    157 try:
    158     from SCons.Node.Alias import default_ans
    159 except ImportError:
    160     pass
    161 else:
    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