José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 1 | ####################################################################### |
José Fonseca | 33ceb67 | 2008-02-18 10:52:44 +0000 | [diff] [blame] | 2 | # SConscript for Mesa |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 3 | |
| 4 | |
| 5 | Import('*') |
Brian Paul | dff36e9 | 2012-05-30 10:08:11 -0600 | [diff] [blame] | 6 | from sys import executable as python_cmd |
José Fonseca | c42e625 | 2008-01-31 13:14:35 +0900 | [diff] [blame] | 7 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 8 | env = env.Clone() |
José Fonseca | b9da379 | 2008-02-19 15:07:53 +0900 | [diff] [blame] | 9 | |
Jose Fonseca | 00faf9f | 2015-03-04 14:23:52 +0000 | [diff] [blame] | 10 | env.MSVC2013Compat() |
| 11 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 12 | env.Append(CPPPATH = [ |
Rob Clark | 1e93b0c | 2015-12-21 21:34:11 -0500 | [diff] [blame] | 13 | '../compiler/nir', # for generated nir_opcodes.h, etc |
Kenneth Graunke | 1e0da62 | 2014-02-24 23:39:14 -0800 | [diff] [blame] | 14 | '#/src', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 15 | Dir('../mapi'), # src/mapi build path |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 16 | '#/src/mapi', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 17 | Dir('.'), # src/mesa build path |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 18 | '#/src/mesa', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 19 | Dir('main'), # src/mesa/main/ build path |
Brian Paul | ace3124 | 2016-06-15 10:42:34 -0600 | [diff] [blame] | 20 | '#/src/mesa/main', |
Eric Anholt | e8c5cbf | 2015-02-11 14:18:50 -0800 | [diff] [blame] | 21 | '#/src/gallium/include', |
| 22 | '#/src/gallium/auxiliary', |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 23 | ]) |
José Fonseca | 2105b61 | 2009-01-06 16:20:12 +0000 | [diff] [blame] | 24 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 25 | if env['platform'] == 'windows': |
| 26 | env.Append(CPPDEFINES = [ |
| 27 | '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers |
| 28 | 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 29 | ]) |
Chia-I Wu | bb770af | 2011-01-14 17:50:29 +0800 | [diff] [blame] | 30 | if not env['gles']: |
| 31 | # prevent _glapi_* from being declared __declspec(dllimport) |
| 32 | env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) |
Chia-I Wu | bb045d3 | 2010-11-20 17:47:11 -0800 | [diff] [blame] | 33 | else: |
| 34 | env.Append(CPPDEFINES = [ |
Tapani Pälli | 9121460 | 2012-08-28 14:01:51 +0300 | [diff] [blame] | 35 | ('HAVE_DLOPEN', '1'), |
Chia-I Wu | bb045d3 | 2010-11-20 17:47:11 -0800 | [diff] [blame] | 36 | ]) |
José Fonseca | 5c9c6b0 | 2008-06-04 23:56:57 +0900 | [diff] [blame] | 37 | |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 38 | # parse Makefile.sources |
| 39 | source_lists = env.ParseSourceList('Makefile.sources') |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 40 | |
Jose Fonseca | 31e47a5 | 2015-03-19 13:35:18 +0000 | [diff] [blame] | 41 | env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_']) |
Jose Fonseca | d3e9aa8 | 2015-03-18 14:22:41 +0000 | [diff] [blame] | 42 | env.CFile('program/lex.yy.c', 'program/program_lexer.l') |
| 43 | env.CFile('program/program_parse.tab.c', 'program/program_parse.y') |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 44 | |
| 45 | mesa_sources = ( |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 46 | source_lists['MESA_FILES'] + |
Jose Fonseca | d3e9aa8 | 2015-03-18 14:22:41 +0000 | [diff] [blame] | 47 | source_lists['PROGRAM_FILES'] + |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 48 | source_lists['STATETRACKER_FILES'] |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 49 | ) |
| 50 | |
Brian Paul | dff36e9 | 2012-05-30 10:08:11 -0600 | [diff] [blame] | 51 | GLAPI = '#src/mapi/glapi/' |
| 52 | |
Imre Deak | 98f880e | 2012-09-10 08:46:13 +0300 | [diff] [blame] | 53 | get_hash_header = env.CodeGenerate( |
| 54 | target = 'main/get_hash.h', |
| 55 | script = 'main/get_hash_generator.py', |
Jose Fonseca | 09dafb9 | 2016-08-27 21:30:38 +0100 | [diff] [blame] | 56 | source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), |
Brian Paul | 815ca0b | 2013-04-17 09:49:39 -0600 | [diff] [blame] | 57 | command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET' |
Imre Deak | 98f880e | 2012-09-10 08:46:13 +0300 | [diff] [blame] | 58 | ) |
| 59 | |
Jason Ekstrand | 12610ff | 2014-06-20 15:52:10 -0700 | [diff] [blame] | 60 | format_info = env.CodeGenerate( |
Emil Velikov | 3f6c28f | 2015-03-02 15:58:17 +0000 | [diff] [blame] | 61 | target = 'main/format_info.h', |
Jason Ekstrand | 12610ff | 2014-06-20 15:52:10 -0700 | [diff] [blame] | 62 | script = 'main/format_info.py', |
| 63 | source = 'main/formats.csv', |
| 64 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 65 | ) |
| 66 | |
Jason Ekstrand | e0439f7 | 2014-08-21 12:38:05 -0700 | [diff] [blame] | 67 | format_pack = env.CodeGenerate( |
| 68 | target = 'main/format_pack.c', |
| 69 | script = 'main/format_pack.py', |
| 70 | source = 'main/formats.csv', |
| 71 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 72 | ) |
| 73 | |
Jason Ekstrand | e1fdcdd | 2014-08-22 09:49:09 -0700 | [diff] [blame] | 74 | format_unpack = env.CodeGenerate( |
| 75 | target = 'main/format_unpack.c', |
| 76 | script = 'main/format_unpack.py', |
| 77 | source = 'main/formats.csv', |
| 78 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 79 | ) |
| 80 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 81 | # |
| 82 | # Assembly sources |
| 83 | # |
Jose Fonseca | 9a25c8a | 2016-04-18 11:47:07 +0100 | [diff] [blame] | 84 | if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'): |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 85 | if env['machine'] == 'x86': |
| 86 | env.Append(CPPDEFINES = [ |
| 87 | 'USE_X86_ASM', |
| 88 | 'USE_MMX_ASM', |
| 89 | 'USE_3DNOW_ASM', |
| 90 | 'USE_SSE_ASM', |
| 91 | ]) |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 92 | mesa_sources += source_lists['X86_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 93 | elif env['machine'] == 'x86_64': |
| 94 | env.Append(CPPDEFINES = [ |
| 95 | 'USE_X86_64_ASM', |
| 96 | ]) |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 97 | mesa_sources += source_lists['X86_64_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 98 | elif env['machine'] == 'sparc': |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 99 | mesa_sources += source_lists['SPARC_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 100 | else: |
| 101 | pass |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 102 | |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 103 | # Generate matypes.h |
| 104 | if env['machine'] in ('x86', 'x86_64'): |
| 105 | # See http://www.scons.org/wiki/UsingCodeGenerators |
| 106 | gen_matypes = env.Program( |
| 107 | target = 'gen_matypes', |
| 108 | source = 'x86/gen_matypes.c', |
| 109 | ) |
| 110 | matypes = env.Command( |
| 111 | 'matypes.h', |
| 112 | gen_matypes, |
| 113 | gen_matypes[0].abspath + ' > $TARGET', |
| 114 | ) |
| 115 | # Add the dir containing the generated header (somewhere inside the |
| 116 | # build dir) to the include path |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 117 | env.Prepend(CPPPATH = [matypes[0].dir]) |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 118 | |
Brian Paul | 0c24550 | 2011-04-05 14:07:41 -0600 | [diff] [blame] | 119 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 120 | # |
| 121 | # Libraries |
| 122 | # |
| 123 | |
| 124 | mesa = env.ConvenienceLibrary( |
| 125 | target = 'mesa', |
| 126 | source = mesa_sources, |
| 127 | ) |
| 128 | |
| 129 | env.Alias('mesa', mesa) |
| 130 | |
| 131 | Export('mesa') |
José Fonseca | 8e8a56e | 2011-04-23 12:22:59 +0100 | [diff] [blame] | 132 | |
| 133 | SConscript('drivers/SConscript') |