blob: bba4101ea58354960c1f005e14c97d18d5b38cdf [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
Jose Fonseca45bacc42018-10-18 15:04:49 +010030 '_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
José Fonseca601498a2010-11-01 13:30:22 +000031 ])
José Fonseca5c9c6b02008-06-04 23:56:57 +090032
Jason Ekstranddcc29c12014-07-23 17:20:12 -070033# parse Makefile.sources
34source_lists = env.ParseSourceList('Makefile.sources')
José Fonseca601498a2010-11-01 13:30:22 +000035
Jose Fonseca31e47a52015-03-19 13:35:18 +000036env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000037env.CFile('program/lex.yy.c', 'program/program_lexer.l')
38env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
José Fonseca601498a2010-11-01 13:30:22 +000039
40mesa_sources = (
Jason Ekstranddcc29c12014-07-23 17:20:12 -070041 source_lists['MESA_FILES'] +
Jose Fonsecad3e9aa82015-03-18 14:22:41 +000042 source_lists['PROGRAM_FILES'] +
Vinson Lee26ddc4f2018-05-12 00:27:52 -070043 source_lists['PROGRAM_NIR_FILES'] +
Jason Ekstranddcc29c12014-07-23 17:20:12 -070044 source_lists['STATETRACKER_FILES']
José Fonseca601498a2010-11-01 13:30:22 +000045)
46
Brian Pauldff36e92012-05-30 10:08:11 -060047GLAPI = '#src/mapi/glapi/'
48
Imre Deak98f880e2012-09-10 08:46:13 +030049get_hash_header = env.CodeGenerate(
50 target = 'main/get_hash.h',
51 script = 'main/get_hash_generator.py',
Jose Fonseca09dafb92016-08-27 21:30:38 +010052 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Brian Paul815ca0b2013-04-17 09:49:39 -060053 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
Imre Deak98f880e2012-09-10 08:46:13 +030054)
55
Jason Ekstrand12610ff2014-06-20 15:52:10 -070056format_info = env.CodeGenerate(
Emil Velikov3f6c28f2015-03-02 15:58:17 +000057 target = 'main/format_info.h',
Jason Ekstrand12610ff2014-06-20 15:52:10 -070058 script = 'main/format_info.py',
59 source = 'main/formats.csv',
60 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
61)
62
Jason Ekstrande0439f72014-08-21 12:38:05 -070063format_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 Ekstrande1fdcdd2014-08-22 09:49:09 -070070format_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 Paul7bbcf3a2017-06-27 20:56:22 -060077format_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é Fonseca601498a2010-11-01 13:30:22 +000084#
85# Assembly sources
86#
Jose Fonseca9a25c8a2016-04-18 11:47:07 +010087if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
José Fonsecaf9156eb2010-11-01 13:56:16 +000088 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 Ekstranddcc29c12014-07-23 17:20:12 -070095 mesa_sources += source_lists['X86_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +000096 elif env['machine'] == 'x86_64':
97 env.Append(CPPDEFINES = [
98 'USE_X86_64_ASM',
99 ])
Jason Ekstranddcc29c12014-07-23 17:20:12 -0700100 mesa_sources += source_lists['X86_64_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000101 elif env['machine'] == 'sparc':
Jason Ekstranddcc29c12014-07-23 17:20:12 -0700102 mesa_sources += source_lists['SPARC_FILES']
José Fonsecaf9156eb2010-11-01 13:56:16 +0000103 else:
104 pass
José Fonseca601498a2010-11-01 13:30:22 +0000105
Paul Berry05dd4a12012-11-07 13:03:13 -0800106# The marshal_generated.c file is generated from the GL/ES API.xml file
Marek Olšák8a3e2cd2020-03-05 18:08:58 -0500107for 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 Berry05dd4a12012-11-07 13:03:13 -0800114
115# The marshal_generated.h file is generated from the GL/ES API.xml file
116env.CodeGenerate(
117 target = 'main/marshal_generated.h',
118 script = GLAPI + 'gen/gl_marshal_h.py',
Jose Fonseca2ba991c2017-03-26 21:28:29 +0100119 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
Paul Berry05dd4a12012-11-07 13:03:13 -0800120 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
121 )
122
José Fonseca601498a2010-11-01 13:30:22 +0000123#
124# Libraries
125#
126
127mesa = env.ConvenienceLibrary(
128 target = 'mesa',
129 source = mesa_sources,
130)
131
132env.Alias('mesa', mesa)
133
134Export('mesa')