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 | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 6 | # scons build=debug llvm=yes 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 |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 12 | # build='debug' |
| 13 | # llvm=True |
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 | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 33 | opts = Variables('config.py') |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 34 | common.AddOptions(opts) |
Jonathan White | 3c81992 | 2008-08-29 11:30:32 -0600 | [diff] [blame] | 35 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 36 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 37 | options = opts, |
| 38 | tools = ['gallium'], |
José Fonseca | 2c4349a | 2008-07-15 07:56:42 +0900 | [diff] [blame] | 39 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 40 | ENV = os.environ, |
| 41 | ) |
| 42 | |
José Fonseca | b115662 | 2011-07-01 19:04:57 +0100 | [diff] [blame] | 43 | # XXX: This creates a many problems as it saves... |
| 44 | #opts.Save('config.py', env) |
José Fonseca | ef4bf40 | 2011-06-17 20:11:35 +0100 | [diff] [blame] | 45 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 46 | # Backwards compatability with old target configuration variable |
| 47 | try: |
| 48 | targets = ARGUMENTS['targets'] |
| 49 | except KeyError: |
| 50 | pass |
| 51 | else: |
| 52 | targets = targets.split(',') |
| 53 | print 'scons: warning: targets option is deprecated; pass the targets on their own such as' |
| 54 | print |
| 55 | print ' scons %s' % ' '.join(targets) |
| 56 | print |
| 57 | COMMAND_LINE_TARGETS.append(targets) |
| 58 | |
Alan Hourihane | 6544be6 | 2010-01-26 19:14:16 +0000 | [diff] [blame] | 59 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 60 | Help(opts.GenerateHelpText(env)) |
| 61 | |
Chia-I Wu | bb770af | 2011-01-14 17:50:29 +0800 | [diff] [blame] | 62 | # fail early for a common error on windows |
| 63 | if env['gles']: |
| 64 | try: |
| 65 | import libxml2 |
| 66 | except ImportError: |
| 67 | raise SCons.Errors.UserError, "GLES requires libxml2-python to build" |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 68 | |
| 69 | ####################################################################### |
| 70 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 71 | |
| 72 | # Includes |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 73 | env.Prepend(CPPPATH = [ |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 74 | '#/include', |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 75 | ]) |
| 76 | env.Append(CPPPATH = [ |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 77 | '#/src/gallium/include', |
| 78 | '#/src/gallium/auxiliary', |
| 79 | '#/src/gallium/drivers', |
José Fonseca | 601bfb5 | 2010-03-10 10:34:29 +0000 | [diff] [blame] | 80 | '#/src/gallium/winsys', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 81 | ]) |
| 82 | |
José Fonseca | dc6bcc9 | 2010-01-10 10:36:35 +0000 | [diff] [blame] | 83 | if env['msvc']: |
| 84 | env.Append(CPPPATH = ['#include/c99']) |
| 85 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 86 | # for debugging |
| 87 | #print env.Dump() |
| 88 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 89 | |
| 90 | ####################################################################### |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 91 | # Invoke host SConscripts |
| 92 | # |
| 93 | # For things that are meant to be run on the native host build machine, instead |
| 94 | # of the target machine. |
| 95 | # |
| 96 | |
| 97 | # Create host environent |
José Fonseca | 4175010 | 2011-06-17 14:48:28 +0100 | [diff] [blame] | 98 | if env['crosscompile'] and not env['embedded']: |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 99 | host_env = Environment( |
| 100 | options = opts, |
| 101 | # no tool used |
| 102 | tools = [], |
| 103 | toolpath = ['#scons'], |
| 104 | ENV = os.environ, |
| 105 | ) |
| 106 | |
| 107 | # Override options |
| 108 | host_env['platform'] = common.host_platform |
| 109 | host_env['machine'] = common.host_machine |
| 110 | host_env['toolchain'] = 'default' |
| 111 | host_env['llvm'] = False |
| 112 | |
| 113 | host_env.Tool('gallium') |
| 114 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 115 | host_env['hostonly'] = True |
| 116 | assert host_env['crosscompile'] == False |
| 117 | |
José Fonseca | 6826d58 | 2011-02-11 17:59:36 +0000 | [diff] [blame] | 118 | if host_env['msvc']: |
| 119 | host_env.Append(CPPPATH = ['#include/c99']) |
| 120 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 121 | target_env = env |
| 122 | env = host_env |
| 123 | Export('env') |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 124 | |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 125 | SConscript( |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 126 | 'src/SConscript', |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 127 | variant_dir = host_env['build_dir'], |
| 128 | duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 129 | ) |
| 130 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 131 | env = target_env |
| 132 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 133 | Export('env') |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 134 | |
| 135 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 136 | # Invoke SConscripts |
| 137 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 138 | # TODO: Build several variants at the same time? |
| 139 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 140 | |
| 141 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 142 | 'src/SConscript', |
José Fonseca | 67450f0 | 2010-09-29 14:08:53 +0100 | [diff] [blame] | 143 | variant_dir = env['build_dir'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 144 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 145 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 146 | |
José Fonseca | 10562fb | 2011-06-17 20:11:50 +0100 | [diff] [blame] | 147 | |
| 148 | ######################################################################## |
| 149 | # List all aliases |
| 150 | |
| 151 | try: |
| 152 | from SCons.Node.Alias import default_ans |
| 153 | except ImportError: |
| 154 | pass |
| 155 | else: |
| 156 | aliases = default_ans.keys() |
| 157 | aliases.sort() |
| 158 | env.Help('\n') |
| 159 | env.Help('Recognized targets:\n') |
| 160 | for alias in aliases: |
| 161 | env.Help(' %s\n' % alias) |