scons: Take indirect gl_and_es_API.xml dependencies in consideration.
[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 '#/src',
15 Dir('../mapi'), # src/mapi build path
16 '#/src/mapi',
17 Dir('.'), # src/mesa build path
18 '#/src/mesa',
19 Dir('main'), # src/mesa/main/ build path
20 '#/src/mesa/main',
21 '#/src/gallium/include',
22 '#/src/gallium/auxiliary',
23 ])
24
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
29 ])
30 if not env['gles']:
31 # prevent _glapi_* from being declared __declspec(dllimport)
32 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
33 else:
34 env.Append(CPPDEFINES = [
35 ('HAVE_DLOPEN', '1'),
36 ])
37
38 # parse Makefile.sources
39 source_lists = env.ParseSourceList('Makefile.sources')
40
41 env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
42 env.CFile('program/lex.yy.c', 'program/program_lexer.l')
43 env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
44
45 mesa_sources = (
46 source_lists['MESA_FILES'] +
47 source_lists['PROGRAM_FILES'] +
48 source_lists['STATETRACKER_FILES']
49 )
50
51 GLAPI = '#src/mapi/glapi/'
52
53 get_hash_header = env.CodeGenerate(
54 target = 'main/get_hash.h',
55 script = 'main/get_hash_generator.py',
56 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
57 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
58 )
59
60 format_info = env.CodeGenerate(
61 target = 'main/format_info.h',
62 script = 'main/format_info.py',
63 source = 'main/formats.csv',
64 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
65 )
66
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
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
81 #
82 # Assembly sources
83 #
84 if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
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 ])
92 mesa_sources += source_lists['X86_FILES']
93 elif env['machine'] == 'x86_64':
94 env.Append(CPPDEFINES = [
95 'USE_X86_64_ASM',
96 ])
97 mesa_sources += source_lists['X86_64_FILES']
98 elif env['machine'] == 'sparc':
99 mesa_sources += source_lists['SPARC_FILES']
100 else:
101 pass
102
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
117 env.Prepend(CPPPATH = [matypes[0].dir])
118
119
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')
132
133 SConscript('drivers/SConscript')