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 | |
Dylan Baker | 79e7388 | 2019-10-21 09:24:12 -0700 | [diff] [blame] | 23 | from __future__ import print_function |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 24 | import os |
| 25 | import os.path |
| 26 | import sys |
Alan Hourihane | 550fc19 | 2010-01-26 19:57:34 +0000 | [diff] [blame] | 27 | import SCons.Util |
José Fonseca | d710a7c | 2008-02-19 18:53:16 +0900 | [diff] [blame] | 28 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 29 | import common |
José Fonseca | 58a3d7d | 2008-02-23 19:49:08 +0900 | [diff] [blame] | 30 | |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 31 | ####################################################################### |
Juan A. Suarez Romero | 810c9a4 | 2018-08-01 17:48:11 +0200 | [diff] [blame] | 32 | # Minimal scons version |
| 33 | |
| 34 | EnsureSConsVersion(2, 4) |
Dylan Baker | 64e4638 | 2018-08-14 10:24:29 -0700 | [diff] [blame] | 35 | EnsurePythonVersion(2, 7) |
Juan A. Suarez Romero | 810c9a4 | 2018-08-01 17:48:11 +0200 | [diff] [blame] | 36 | |
| 37 | |
| 38 | ####################################################################### |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 39 | # Configuration options |
| 40 | |
José Fonseca | e9fb90a | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 41 | opts = Variables('config.py') |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 42 | common.AddOptions(opts) |
Jonathan White | 3c81992 | 2008-08-29 11:30:32 -0600 | [diff] [blame] | 43 | |
José Fonseca | 81b6a80 | 2008-02-06 14:36:50 +0900 | [diff] [blame] | 44 | env = Environment( |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 45 | options = opts, |
| 46 | tools = ['gallium'], |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 47 | toolpath = ['#scons'], |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 48 | ENV = os.environ, |
| 49 | ) |
| 50 | |
José Fonseca | b115662 | 2011-07-01 19:04:57 +0100 | [diff] [blame] | 51 | # XXX: This creates a many problems as it saves... |
| 52 | #opts.Save('config.py', env) |
José Fonseca | ef4bf40 | 2011-06-17 20:11:35 +0100 | [diff] [blame] | 53 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 54 | # Backwards compatability with old target configuration variable |
| 55 | try: |
| 56 | targets = ARGUMENTS['targets'] |
| 57 | except KeyError: |
| 58 | pass |
| 59 | else: |
| 60 | targets = targets.split(',') |
Eric Engestrom | 7d48219 | 2017-09-19 13:56:34 +0100 | [diff] [blame] | 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() |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 65 | COMMAND_LINE_TARGETS.append(targets) |
| 66 | |
Alan Hourihane | 6544be6 | 2010-01-26 19:14:16 +0000 | [diff] [blame] | 67 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 68 | Help(opts.GenerateHelpText(env)) |
| 69 | |
Dylan Baker | 54053bc | 2019-10-21 09:29:23 -0700 | [diff] [blame] | 70 | |
| 71 | ####################################################################### |
| 72 | # Print a deprecation warning for using scons on non-windows |
| 73 | |
Jose Fonseca | ace5138 | 2019-10-25 22:09:34 +0100 | [diff] [blame] | 74 | if common.host_platform != 'windows' and env['platform'] != 'windows': |
| 75 | if env['force_scons']: |
Dylan Baker | 54053bc | 2019-10-21 09:29:23 -0700 | [diff] [blame] | 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) |
Dylan Baker | 61ed989 | 2019-10-21 10:18:50 -0700 | [diff] [blame] | 83 | else: |
| 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 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 90 | ####################################################################### |
| 91 | # Environment setup |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 92 | |
Emil Velikov | 488b3ed | 2013-07-25 23:45:45 +0100 | [diff] [blame] | 93 | with open("VERSION") as f: |
| 94 | mesa_version = f.read().strip() |
José Fonseca | cff70dc | 2013-03-13 13:13:08 +0000 | [diff] [blame] | 95 | env.Append(CPPDEFINES = [ |
Emil Velikov | 488b3ed | 2013-07-25 23:45:45 +0100 | [diff] [blame] | 96 | ('PACKAGE_VERSION', '\\"%s\\"' % mesa_version), |
Adam Jackson | 5b5c5bf | 2019-09-18 15:59:41 -0400 | [diff] [blame] | 97 | ('PACKAGE_BUGREPORT', '\\"https://gitlab.freedesktop.org/mesa/mesa/issues\\"'), |
José Fonseca | cff70dc | 2013-03-13 13:13:08 +0000 | [diff] [blame] | 98 | ]) |
| 99 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 100 | # Includes |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 101 | env.Prepend(CPPPATH = [ |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 102 | '#/include', |
Vinson Lee | 5fd9757 | 2010-04-26 01:08:34 -0700 | [diff] [blame] | 103 | ]) |
| 104 | env.Append(CPPPATH = [ |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 105 | '#/src/gallium/include', |
| 106 | '#/src/gallium/auxiliary', |
| 107 | '#/src/gallium/drivers', |
José Fonseca | 601bfb5 | 2010-03-10 10:34:29 +0000 | [diff] [blame] | 108 | '#/src/gallium/winsys', |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 109 | ]) |
| 110 | |
José Fonseca | 4f17bd2 | 2008-03-12 13:34:30 +0000 | [diff] [blame] | 111 | # for debugging |
| 112 | #print env.Dump() |
| 113 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 114 | |
Jose Fonseca | 50ddf03 | 2016-04-13 13:31:04 +0100 | [diff] [blame] | 115 | # Add a check target for running tests |
| 116 | check = env.Alias('check') |
| 117 | env.AlwaysBuild(check) |
| 118 | |
| 119 | |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 120 | ####################################################################### |
Giuseppe Bilotta | 8c00fe3 | 2016-05-25 07:30:06 -0600 | [diff] [blame] | 121 | # Invoke host SConscripts |
| 122 | # |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 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 |
José Fonseca | 4175010 | 2011-06-17 14:48:28 +0100 | [diff] [blame] | 128 | if env['crosscompile'] and not env['embedded']: |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 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 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 145 | host_env['hostonly'] = True |
| 146 | assert host_env['crosscompile'] == False |
| 147 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 148 | target_env = env |
| 149 | env = host_env |
| 150 | Export('env') |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 151 | |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 152 | SConscript( |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 153 | 'src/SConscript', |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 154 | variant_dir = host_env['build_dir'], |
| 155 | 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] | 156 | ) |
| 157 | |
José Fonseca | 9f9d648 | 2011-02-15 15:31:19 +0000 | [diff] [blame] | 158 | env = target_env |
| 159 | |
José Fonseca | 982609f | 2011-02-11 17:38:54 +0000 | [diff] [blame] | 160 | Export('env') |
José Fonseca | e1bc68b | 2011-01-13 20:52:01 +0000 | [diff] [blame] | 161 | |
| 162 | ####################################################################### |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 163 | # Invoke SConscripts |
| 164 | |
José Fonseca | f4192cb4 | 2008-01-31 14:21:49 +0900 | [diff] [blame] | 165 | # TODO: Build several variants at the same time? |
| 166 | # http://www.scons.org/wiki/SimultaneousVariantBuilds |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 167 | |
| 168 | SConscript( |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 169 | 'src/SConscript', |
José Fonseca | 67450f0 | 2010-09-29 14:08:53 +0100 | [diff] [blame] | 170 | variant_dir = env['build_dir'], |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 171 | duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html |
| 172 | ) |
José Fonseca | 7bbf7f9 | 2009-12-31 21:10:25 +0000 | [diff] [blame] | 173 | |
José Fonseca | 10562fb | 2011-06-17 20:11:50 +0100 | [diff] [blame] | 174 | |
| 175 | ######################################################################## |
| 176 | # List all aliases |
| 177 | |
| 178 | try: |
| 179 | from SCons.Node.Alias import default_ans |
| 180 | except ImportError: |
| 181 | pass |
| 182 | else: |
Eric Engestrom | e361047 | 2017-09-19 13:56:56 +0100 | [diff] [blame] | 183 | aliases = sorted(default_ans.keys()) |
José Fonseca | 10562fb | 2011-06-17 20:11:50 +0100 | [diff] [blame] | 184 | env.Help('\n') |
| 185 | env.Help('Recognized targets:\n') |
| 186 | for alias in aliases: |
| 187 | env.Help(' %s\n' % alias) |