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 | # |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 4 | # For example, invoke scons as |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 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' |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 15 | # |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 16 | # Invoke |
| 17 | # |
| 18 | # scons -h |
| 19 | # |
| 20 | # to get the full list of options. See scons manpage for more info. |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 21 | # |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 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'], |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [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(',') |
Eric Engestrom | 7d48219 | 2017-09-19 13:56:34 +0100 | [diff] [blame] | 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() |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 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 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 62 | ####################################################################### |
| 63 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 64 | |
Emil Velikov | 488b3ed | 2013-07-25 23:45:45 +0100 | [diff] [blame] | 65 | with open("VERSION") as f: |
| 66 | mesa_version = f.read().strip() |
José Fonseca | cff70dc | 2013-03-13 13:13:08 +0000 | [diff] [blame] | 67 | env.Append(CPPDEFINES = [ |
Emil Velikov | 488b3ed | 2013-07-25 23:45:45 +0100 | [diff] [blame] | 68 | ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version), |
José Fonseca | cff70dc | 2013-03-13 13:13:08 +0000 | [diff] [blame] | 69 | ('PACKAGE_BUGREPORT', '\\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\\"'), |
| 70 | ]) |
| 71 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 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 | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 83 | # for debugging |
| 84 | #print env.Dump() |
| 85 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 86 | |
Jose Fonseca | 50ddf03 | 2016-04-13 13:31:04 +0100 | [diff] [blame] | 87 | # Add a check target for running tests |
| 88 | check = env.Alias('check') |
| 89 | env.AlwaysBuild(check) |
| 90 | |
| 91 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 92 | ####################################################################### |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 93 | # Invoke host SConscripts |
| 94 | # |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 95 | # For things that are meant to be run on the native host build machine, instead |
| 96 | # of the target machine. |
| 97 | # |
| 98 | |
| 99 | # Create host environent |
José Fonseca | 4175010 | 2011-06-17 14:48:28 +0100 | [diff] [blame] | 100 | if env['crosscompile'] and not env['embedded']: |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 101 | host_env = Environment( |
| 102 | options = opts, |
| 103 | # no tool used |
| 104 | tools = [], |
| 105 | toolpath = ['#scons'], |
| 106 | ENV = os.environ, |
| 107 | ) |
| 108 | |
| 109 | # Override options |
| 110 | host_env['platform'] = common.host_platform |
| 111 | host_env['machine'] = common.host_machine |
| 112 | host_env['toolchain'] = 'default' |
| 113 | host_env['llvm'] = False |
| 114 | |
| 115 | host_env.Tool('gallium') |
| 116 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 117 | host_env['hostonly'] = True |
| 118 | assert host_env['crosscompile'] == False |
| 119 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 120 | target_env = env |
| 121 | env = host_env |
| 122 | Export('env') |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 123 | |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 124 | SConscript( |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 125 | 'src/SConscript', |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 126 | variant_dir = host_env['build_dir'], |
| 127 | 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] | 128 | ) |
| 129 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 130 | env = target_env |
| 131 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 132 | Export('env') |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 133 | |
| 134 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 135 | # Invoke SConscripts |
| 136 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 137 | # TODO: Build several variants at the same time? |
| 138 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 139 | |
| 140 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 141 | 'src/SConscript', |
José Fonseca | 67450f0 | 2010-09-29 14:08:53 +0100 | [diff] [blame] | 142 | variant_dir = env['build_dir'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 143 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 144 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 145 | |
José Fonseca | 10562fb | 2011-06-17 20:11:50 +0100 | [diff] [blame] | 146 | |
| 147 | ######################################################################## |
| 148 | # List all aliases |
| 149 | |
| 150 | try: |
| 151 | from SCons.Node.Alias import default_ans |
| 152 | except ImportError: |
| 153 | pass |
| 154 | else: |
Eric Engestrom | e361047 | 2017-09-19 13:56:56 +0100 | [diff] [blame] | 155 | aliases = sorted(default_ans.keys()) |
José Fonseca | 10562fb | 2011-06-17 20:11:50 +0100 | [diff] [blame] | 156 | env.Help('\n') |
| 157 | env.Help('Recognized targets:\n') |
| 158 | for alias in aliases: |
| 159 | env.Help(' %s\n' % alias) |