blob: b63e15a3f054102821ab7937bbd75b6d83ceeda1 [file] [log] [blame]
José Fonsecac42e6252008-01-31 13:14:35 +09001#######################################################################
José Fonseca33ceb672008-02-18 10:52:44 +00002# SConscript for Mesa
José Fonsecac42e6252008-01-31 13:14:35 +09003
4
5Import('*')
Brian Pauldff36e92012-05-30 10:08:11 -06006from sys import executable as python_cmd
José Fonsecac42e6252008-01-31 13:14:35 +09007
José Fonseca601498a2010-11-01 13:30:22 +00008env = env.Clone()
José Fonsecab9da3792008-02-19 15:07:53 +09009
Jose Fonseca00faf9f2015-03-04 14:23:52 +000010env.MSVC2013Compat()
11
José Fonseca601498a2010-11-01 13:30:22 +000012env.Append(CPPPATH = [
Rob Clark1e93b0c2015-12-21 21:34:11 -050013 '../compiler/nir', # for generated nir_opcodes.h, etc
Ian Romanick7d6af9e2015-04-15 16:59:43 -070014 '../compiler/glsl', # for generated headers
Kenneth Graunke1e0da622014-02-24 23:39:14 -080015 '#/src',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010016 Dir('../mapi'), # src/mapi build path
José Fonseca601498a2010-11-01 13:30:22 +000017 '#/src/mapi',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010018 Dir('.'), # src/mesa build path
José Fonseca601498a2010-11-01 13:30:22 +000019 '#/src/mesa',
Emil Velikov1c7c0d72016-07-18 19:23:02 +010020 Dir('main'), # src/mesa/main/ build path
Brian Paulace31242016-06-15 10:42:34 -060021 '#/src/mesa/main',
Eric Anholte8c5cbf2015-02-11 14:18:50 -080022 '#/src/gallium/include',
23 '#/src/gallium/auxiliary',
José Fonseca601498a2010-11-01 13:30:22 +000024])
José Fonseca2105b612009-01-06 16:20:12 +000025
José Fonseca601498a2010-11-01 13:30:22 +000026if 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
José Fonseca601498a2010-11-01 13:30:22 +000030 ])
Chia-I Wubb770af2011-01-14 17:50:29 +080031 if not env['gles']:
32 # prevent _glapi_* from being declared __declspec(dllimport)
33 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
Chia-I Wubb045d32010-11-20 17:47:11 -080034else:
35 env.Append(CPPDEFINES = [
Tapani Pälli91214602012-08-28 14:01:51 +030036 ('HAVE_DLOPEN', '1'),
Chia-I Wubb045d32010-11-20 17:47:11 -080037 ])
José Fonseca5c9c6b02008-06-04 23:56:57 +090038
Jason Ekstranddcc29c12014-07-23 17:20:12 -070039# parse Makefile.sources
40source_lists = env.ParseSourceList('Makefile.sources')
José Fonseca601498a2010-11-01 13:30:22 +000041
Jose Fonseca31e47a52015-03-19 13:35:18 +000042env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000043env.CFile('program/lex.yy.c', 'program/program_lexer.l')
44env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
José Fonseca601498a2010-11-01 13:30:22 +000045
46mesa_sources = (
Jason Ekstranddcc29c12014-07-23 17:20:12 -070047 source_lists['MESA_FILES'] +
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000048 source_lists['PROGRAM_FILES'] +
Jason Ekstranddcc29c12014-07-23 17:20:12 -070049 source_lists['STATETRACKER_FILES']
José Fonseca601498a2010-11-01 13:30:22 +000050)
51
Brian Pauldff36e92012-05-30 10:08:11 -060052GLAPI = '#src/mapi/glapi/'
53
Imre Deak98f880e2012-09-10 08:46:13 +030054get_hash_header = env.CodeGenerate(
55 target = 'main/get_hash.h',
56 script = 'main/get_hash_generator.py',
Jose Fonseca09dafb92016-08-27 21:30:38 +010057 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Brian Paul815ca0b2013-04-17 09:49:39 -060058 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
Imre Deak98f880e2012-09-10 08:46:13 +030059)
60
Jason Ekstrand12610ff2014-06-20 15:52:10 -070061format_info = env.CodeGenerate(
Emil Velikov3f6c28f22015-03-02 15:58:17 +000062 target = 'main/format_info.h',
Jason Ekstrand12610ff2014-06-20 15:52:10 -070063 script = 'main/format_info.py',
64 source = 'main/formats.csv',
65 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
66)
67
Jason Ekstrande0439f72014-08-21 12:38:05 -070068format_pack = env.CodeGenerate(
69 target = 'main/format_pack.c',
70 script = 'main/format_pack.py',
71 source = 'main/formats.csv',
72 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
73)
74
Jason Ekstrande1fdcdd2014-08-22 09:49:09 -070075format_unpack = env.CodeGenerate(
76 target = 'main/format_unpack.c',
77 script = 'main/format_unpack.py',
78 source = 'main/formats.csv',
79 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
80)
81
Brian Paul7bbcf3a2017-06-27 20:56:22 -060082format_fallback = env.CodeGenerate(
83 target = 'main/format_fallback.c',
84 script = 'main/format_fallback.py',
85 source = 'main/formats.csv',
86 command = python_cmd + ' $SCRIPT ' + ' $SOURCE ' + ' $TARGET'
87)
88
José Fonseca601498a2010-11-01 13:30:22 +000089#
90# Assembly sources
91#
Jose Fonseca9a25c8a2016-04-18 11:47:07 +010092if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
José Fonsecaf9156eb2010-11-01 13:56:16 +000093 if env['machine'] == 'x86':
94 env.Append(CPPDEFINES = [
95 'USE_X86_ASM',
96 'USE_MMX_ASM',
97 'USE_3DNOW_ASM',
98 'USE_SSE_ASM',
99 ])
Jason Ekstranddcc29c12014-07-23 17:20:12 -0700100 mesa_sources += source_lists['X86_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000101 elif env['machine'] == 'x86_64':
102 env.Append(CPPDEFINES = [
103 'USE_X86_64_ASM',
104 ])
Jason Ekstranddcc29c12014-07-23 17:20:12 -0700105 mesa_sources += source_lists['X86_64_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000106 elif env['machine'] == 'sparc':
Jason Ekstranddcc29c12014-07-23 17:20:12 -0700107 mesa_sources += source_lists['SPARC_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000108 else:
109 pass
José Fonseca601498a2010-11-01 13:30:22 +0000110
José Fonsecaf9156eb2010-11-01 13:56:16 +0000111 # Generate matypes.h
112 if env['machine'] in ('x86', 'x86_64'):
113 # See http://www.scons.org/wiki/UsingCodeGenerators
114 gen_matypes = env.Program(
115 target = 'gen_matypes',
116 source = 'x86/gen_matypes.c',
117 )
118 matypes = env.Command(
119 'matypes.h',
120 gen_matypes,
121 gen_matypes[0].abspath + ' > $TARGET',
122 )
123 # Add the dir containing the generated header (somewhere inside the
124 # build dir) to the include path
Emil Velikov1c7c0d72016-07-18 19:23:02 +0100125 env.Prepend(CPPPATH = [matypes[0].dir])
José Fonseca601498a2010-11-01 13:30:22 +0000126
Brian Paul0c245502011-04-05 14:07:41 -0600127
Paul Berry05dd4a12012-11-07 13:03:13 -0800128# The marshal_generated.c file is generated from the GL/ES API.xml file
129env.CodeGenerate(
130 target = 'main/marshal_generated.c',
131 script = GLAPI + 'gen/gl_marshal.py',
Jose Fonseca2ba991c2017-03-26 21:28:29 +0100132 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Paul Berry05dd4a12012-11-07 13:03:13 -0800133 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
134 )
135
136# The marshal_generated.h file is generated from the GL/ES API.xml file
137env.CodeGenerate(
138 target = 'main/marshal_generated.h',
139 script = GLAPI + 'gen/gl_marshal_h.py',
Jose Fonseca2ba991c2017-03-26 21:28:29 +0100140 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Paul Berry05dd4a12012-11-07 13:03:13 -0800141 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
142 )
143
José Fonseca601498a2010-11-01 13:30:22 +0000144#
145# Libraries
146#
147
148mesa = env.ConvenienceLibrary(
149 target = 'mesa',
150 source = mesa_sources,
151)
152
153env.Alias('mesa', mesa)
154
155Export('mesa')
José Fonseca8e8a56e2011-04-23 12:22:59 +0100156
157SConscript('drivers/SConscript')