5a21b64f561e477d561f7a238d2c416600364fea
[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
35 # parse Makefile.sources
36 source_lists = env.ParseSourceList('Makefile.sources')
37
38 env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
39 env.CFile('program/lex.yy.c', 'program/program_lexer.l')
40 env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
41
42 mesa_sources = (
43 source_lists['MESA_FILES'] +
44 source_lists['PROGRAM_FILES'] +
45 source_lists['PROGRAM_NIR_FILES'] +
46 source_lists['STATETRACKER_FILES']
47 )
48
49 GLAPI = '#src/mapi/glapi/'
50
51 get_hash_header = env.CodeGenerate(
52 target = 'main/get_hash.h',
53 script = 'main/get_hash_generator.py',
54 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
55 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
56 )
57
58 format_info = env.CodeGenerate(
59 target = 'main/format_info.h',
60 script = 'main/format_info.py',
61 source = 'main/formats.csv',
62 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
63 )
64
65 format_pack = env.CodeGenerate(
66 target = 'main/format_pack.c',
67 script = 'main/format_pack.py',
68 source = 'main/formats.csv',
69 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
70 )
71
72 format_unpack = env.CodeGenerate(
73 target = 'main/format_unpack.c',
74 script = 'main/format_unpack.py',
75 source = 'main/formats.csv',
76 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
77 )
78
79 format_fallback = env.CodeGenerate(
80 target = 'main/format_fallback.c',
81 script = 'main/format_fallback.py',
82 source = 'main/formats.csv',
83 command = python_cmd + ' $SCRIPT ' + ' $SOURCE ' + ' $TARGET'
84 )
85
86 #
87 # Assembly sources
88 #
89 if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
90 if env['machine'] == 'x86':
91 env.Append(CPPDEFINES = [
92 'USE_X86_ASM',
93 'USE_MMX_ASM',
94 'USE_3DNOW_ASM',
95 'USE_SSE_ASM',
96 ])
97 mesa_sources += source_lists['X86_FILES']
98 elif env['machine'] == 'x86_64':
99 env.Append(CPPDEFINES = [
100 'USE_X86_64_ASM',
101 ])
102 mesa_sources += source_lists['X86_64_FILES']
103 elif env['machine'] == 'sparc':
104 mesa_sources += source_lists['SPARC_FILES']
105 else:
106 pass
107
108 # Generate matypes.h
109 if env['machine'] in ('x86', 'x86_64'):
110 # See http://www.scons.org/wiki/UsingCodeGenerators
111 gen_matypes = env.Program(
112 target = 'gen_matypes',
113 source = 'x86/gen_matypes.c',
114 )
115 matypes = env.Command(
116 'matypes.h',
117 gen_matypes,
118 gen_matypes[0].abspath + ' > $TARGET',
119 )
120 # Add the dir containing the generated header (somewhere inside the
121 # build dir) to the include path
122 env.Prepend(CPPPATH = [matypes[0].dir])
123
124
125 # The marshal_generated.c file is generated from the GL/ES API.xml file
126 env.CodeGenerate(
127 target = 'main/marshal_generated.c',
128 script = GLAPI + 'gen/gl_marshal.py',
129 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
130 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
131 )
132
133 # The marshal_generated.h file is generated from the GL/ES API.xml file
134 env.CodeGenerate(
135 target = 'main/marshal_generated.h',
136 script = GLAPI + 'gen/gl_marshal_h.py',
137 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
138 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
139 )
140
141 #
142 # Libraries
143 #
144
145 mesa = env.ConvenienceLibrary(
146 target = 'mesa',
147 source = mesa_sources,
148 )
149
150 env.Alias('mesa', mesa)
151
152 Export('mesa')
153
154 SConscript('drivers/SConscript')