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 |
Ian Romanick | 7d6af9e | 2015-04-15 16:59:43 -0700 | [diff] [blame] | 14 | '../compiler/glsl', # for generated headers |
Kenneth Graunke | 1e0da62 | 2014-02-24 23:39:14 -0800 | [diff] [blame] | 15 | '#/src', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 16 | Dir('../mapi'), # src/mapi build path |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 17 | '#/src/mapi', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 18 | Dir('.'), # src/mesa build path |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 19 | '#/src/mesa', |
Emil Velikov | 1c7c0d7 | 2016-07-18 19:23:02 +0100 | [diff] [blame] | 20 | Dir('main'), # src/mesa/main/ build path |
Brian Paul | ace3124 | 2016-06-15 10:42:34 -0600 | [diff] [blame] | 21 | '#/src/mesa/main', |
Eric Anholt | e8c5cbf | 2015-02-11 14:18:50 -0800 | [diff] [blame] | 22 | '#/src/gallium/include', |
| 23 | '#/src/gallium/auxiliary', |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 24 | ]) |
José Fonseca | 2105b61 | 2009-01-06 16:20:12 +0000 | [diff] [blame] | 25 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 26 | if env['platform'] == 'windows': |
| 27 | env.Append(CPPDEFINES = [ |
| 28 | '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers |
| 29 | 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers |
Jose Fonseca | 45bacc4 | 2018-10-18 15:04:49 +0100 | [diff] [blame] | 30 | '_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport) |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 31 | ]) |
José Fonseca | 5c9c6b0 | 2008-06-04 23:56:57 +0900 | [diff] [blame] | 32 | |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 33 | # parse Makefile.sources |
| 34 | source_lists = env.ParseSourceList('Makefile.sources') |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 35 | |
Jose Fonseca | 31e47a5 | 2015-03-19 13:35:18 +0000 | [diff] [blame] | 36 | env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_']) |
Jose Fonseca | d3e9aa8 | 2015-03-18 14:22:41 +0000 | [diff] [blame] | 37 | env.CFile('program/lex.yy.c', 'program/program_lexer.l') |
| 38 | env.CFile('program/program_parse.tab.c', 'program/program_parse.y') |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 39 | |
| 40 | mesa_sources = ( |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 41 | source_lists['MESA_FILES'] + |
Jose Fonseca | d3e9aa8 | 2015-03-18 14:22:41 +0000 | [diff] [blame] | 42 | source_lists['PROGRAM_FILES'] + |
Vinson Lee | 26ddc4f | 2018-05-12 00:27:52 -0700 | [diff] [blame] | 43 | source_lists['PROGRAM_NIR_FILES'] + |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 44 | source_lists['STATETRACKER_FILES'] |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 45 | ) |
| 46 | |
Brian Paul | dff36e9 | 2012-05-30 10:08:11 -0600 | [diff] [blame] | 47 | GLAPI = '#src/mapi/glapi/' |
| 48 | |
Imre Deak | 98f880e | 2012-09-10 08:46:13 +0300 | [diff] [blame] | 49 | get_hash_header = env.CodeGenerate( |
| 50 | target = 'main/get_hash.h', |
| 51 | script = 'main/get_hash_generator.py', |
Jose Fonseca | 09dafb9 | 2016-08-27 21:30:38 +0100 | [diff] [blame] | 52 | 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] | 53 | command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET' |
Imre Deak | 98f880e | 2012-09-10 08:46:13 +0300 | [diff] [blame] | 54 | ) |
| 55 | |
Jason Ekstrand | 12610ff | 2014-06-20 15:52:10 -0700 | [diff] [blame] | 56 | format_info = env.CodeGenerate( |
Emil Velikov | 3f6c28f | 2015-03-02 15:58:17 +0000 | [diff] [blame] | 57 | target = 'main/format_info.h', |
Jason Ekstrand | 12610ff | 2014-06-20 15:52:10 -0700 | [diff] [blame] | 58 | script = 'main/format_info.py', |
| 59 | source = 'main/formats.csv', |
| 60 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 61 | ) |
| 62 | |
Jason Ekstrand | e0439f7 | 2014-08-21 12:38:05 -0700 | [diff] [blame] | 63 | format_pack = env.CodeGenerate( |
| 64 | target = 'main/format_pack.c', |
| 65 | script = 'main/format_pack.py', |
| 66 | source = 'main/formats.csv', |
| 67 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 68 | ) |
| 69 | |
Jason Ekstrand | e1fdcdd | 2014-08-22 09:49:09 -0700 | [diff] [blame] | 70 | format_unpack = env.CodeGenerate( |
| 71 | target = 'main/format_unpack.c', |
| 72 | script = 'main/format_unpack.py', |
| 73 | source = 'main/formats.csv', |
| 74 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' |
| 75 | ) |
| 76 | |
Brian Paul | 7bbcf3a | 2017-06-27 20:56:22 -0600 | [diff] [blame] | 77 | format_fallback = env.CodeGenerate( |
| 78 | target = 'main/format_fallback.c', |
| 79 | script = 'main/format_fallback.py', |
| 80 | source = 'main/formats.csv', |
| 81 | command = python_cmd + ' $SCRIPT ' + ' $SOURCE ' + ' $TARGET' |
| 82 | ) |
| 83 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 84 | # |
| 85 | # Assembly sources |
| 86 | # |
Jose Fonseca | 9a25c8a | 2016-04-18 11:47:07 +0100 | [diff] [blame] | 87 | if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'): |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 88 | if env['machine'] == 'x86': |
| 89 | env.Append(CPPDEFINES = [ |
| 90 | 'USE_X86_ASM', |
| 91 | 'USE_MMX_ASM', |
| 92 | 'USE_3DNOW_ASM', |
| 93 | 'USE_SSE_ASM', |
| 94 | ]) |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 95 | mesa_sources += source_lists['X86_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 96 | elif env['machine'] == 'x86_64': |
| 97 | env.Append(CPPDEFINES = [ |
| 98 | 'USE_X86_64_ASM', |
| 99 | ]) |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 100 | mesa_sources += source_lists['X86_64_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 101 | elif env['machine'] == 'sparc': |
Jason Ekstrand | dcc29c1 | 2014-07-23 17:20:12 -0700 | [diff] [blame] | 102 | mesa_sources += source_lists['SPARC_FILES'] |
José Fonseca | f9156eb | 2010-11-01 13:56:16 +0000 | [diff] [blame] | 103 | else: |
| 104 | pass |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 105 | |
Paul Berry | 05dd4a1 | 2012-11-07 13:03:13 -0800 | [diff] [blame] | 106 | # The marshal_generated.c file is generated from the GL/ES API.xml file |
Marek Olšák | 8a3e2cd | 2020-03-05 18:08:58 -0500 | [diff] [blame] | 107 | for i in range(8): |
| 108 | env.CodeGenerate( |
| 109 | target = 'main/marshal_generated{0}.c'.format(i), |
| 110 | script = GLAPI + 'gen/gl_marshal.py', |
| 111 | source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), |
| 112 | command = python_cmd + ' $SCRIPT -f $SOURCE -i {0} -n 8 > $TARGET'.format(i) |
| 113 | ) |
Paul Berry | 05dd4a1 | 2012-11-07 13:03:13 -0800 | [diff] [blame] | 114 | |
| 115 | # The marshal_generated.h file is generated from the GL/ES API.xml file |
| 116 | env.CodeGenerate( |
| 117 | target = 'main/marshal_generated.h', |
| 118 | script = GLAPI + 'gen/gl_marshal_h.py', |
Jose Fonseca | 2ba991c | 2017-03-26 21:28:29 +0100 | [diff] [blame] | 119 | source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), |
Paul Berry | 05dd4a1 | 2012-11-07 13:03:13 -0800 | [diff] [blame] | 120 | command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET' |
| 121 | ) |
| 122 | |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 123 | # |
| 124 | # Libraries |
| 125 | # |
| 126 | |
| 127 | mesa = env.ConvenienceLibrary( |
| 128 | target = 'mesa', |
| 129 | source = mesa_sources, |
| 130 | ) |
| 131 | |
| 132 | env.Alias('mesa', mesa) |
| 133 | |
| 134 | Export('mesa') |