scons: add code to generate format_fallback.c file
[mesa.git] / src / mesa / SConscript
1 #######################################################################
2 # SConscript for Mesa
3
4
5 Import('*')
6 from sys import executable as python_cmd
7
8 env = env.Clone()
9
10 env.MSVC2013Compat()
11
12 env.Append(CPPPATH = [
13 '../compiler/nir', # for generated nir_opcodes.h, etc
14 '../compiler/glsl', # for generated headers
15 '#/src',
16 Dir('../mapi'), # src/mapi build path
17 '#/src/mapi',
18 Dir('.'), # src/mesa build path
19 '#/src/mesa',
20 Dir('main'), # src/mesa/main/ build path
21 '#/src/mesa/main',
22 '#/src/gallium/include',
23 '#/src/gallium/auxiliary',
24 ])
25
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
30 ])
31 if not env['gles']:
32 # prevent _glapi_* from being declared __declspec(dllimport)
33 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
34 else:
35 env.Append(CPPDEFINES = [
36 ('HAVE_DLOPEN', '1'),
37 ])
38
39 # parse Makefile.sources
40 source_lists = env.ParseSourceList('Makefile.sources')
41
42 env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
43 env.CFile('program/lex.yy.c', 'program/program_lexer.l')
44 env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
45
46 mesa_sources = (
47 source_lists['MESA_FILES'] +
48 source_lists['PROGRAM_FILES'] +
49 source_lists['STATETRACKER_FILES']
50 )
51
52 GLAPI = '#src/mapi/glapi/'
53
54 get_hash_header = env.CodeGenerate(
55 target = 'main/get_hash.h',
56 script = 'main/get_hash_generator.py',
57 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
58 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
59 )
60
61 format_info = env.CodeGenerate(
62 target = 'main/format_info.h',
63 script = 'main/format_info.py',
64 source = 'main/formats.csv',
65 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
66 )
67
68 format_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
75 format_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
82 format_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
89 #
90 # Assembly sources
91 #
92 if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
93 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 ])
100 mesa_sources += source_lists['X86_FILES']
101 elif env['machine'] == 'x86_64':
102 env.Append(CPPDEFINES = [
103 'USE_X86_64_ASM',
104 ])
105 mesa_sources += source_lists['X86_64_FILES']
106 elif env['machine'] == 'sparc':
107 mesa_sources += source_lists['SPARC_FILES']
108 else:
109 pass
110
111 # 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
125 env.Prepend(CPPPATH = [matypes[0].dir])
126
127
128 # The marshal_generated.c file is generated from the GL/ES API.xml file
129 env.CodeGenerate(
130 target = 'main/marshal_generated.c',
131 script = GLAPI + 'gen/gl_marshal.py',
132 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
133 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
134 )
135
136 # The marshal_generated.h file is generated from the GL/ES API.xml file
137 env.CodeGenerate(
138 target = 'main/marshal_generated.h',
139 script = GLAPI + 'gen/gl_marshal_h.py',
140 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
141 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
142 )
143
144 #
145 # Libraries
146 #
147
148 mesa = env.ConvenienceLibrary(
149 target = 'mesa',
150 source = mesa_sources,
151 )
152
153 env.Alias('mesa', mesa)
154
155 Export('mesa')
156
157 SConscript('drivers/SConscript')