1#######################################################################
2# SConscript for Mesa
3
4
5Import('*')
6from sys import executable as python_cmd
7
8env = env.Clone()
9
10env.MSVC2013Compat()
11
12env.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
26if 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        '_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
31    ])
32
33# parse Makefile.sources
34source_lists = env.ParseSourceList('Makefile.sources')
35
36env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
37env.CFile('program/lex.yy.c', 'program/program_lexer.l')
38env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
39
40mesa_sources = (
41    source_lists['MESA_FILES'] +
42    source_lists['PROGRAM_FILES'] +
43    source_lists['PROGRAM_NIR_FILES'] +
44    source_lists['STATETRACKER_FILES']
45)
46
47GLAPI = '#src/mapi/glapi/'
48
49get_hash_header = env.CodeGenerate(
50      target = 'main/get_hash.h',
51      script = 'main/get_hash_generator.py',
52      source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
53      command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
54)
55
56format_info = env.CodeGenerate(
57      target = 'main/format_info.h',
58      script = 'main/format_info.py',
59      source = 'main/formats.csv',
60      command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
61)
62
63format_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
70format_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
77format_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
84#
85# Assembly sources
86#
87if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
88    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        ])
95        mesa_sources += source_lists['X86_FILES']
96    elif env['machine'] == 'x86_64':
97        env.Append(CPPDEFINES = [
98            'USE_X86_64_ASM',
99        ])
100        mesa_sources += source_lists['X86_64_FILES']
101    elif env['machine'] == 'sparc':
102        mesa_sources += source_lists['SPARC_FILES']
103    else:
104        pass
105
106# The marshal_generated.c file is generated from the GL/ES API.xml file
107for 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        )
114
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',
119    source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
120    command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
121    )
122
123#
124# Libraries
125#
126
127mesa = env.ConvenienceLibrary(
128    target = 'mesa',
129    source = mesa_sources,
130)
131
132env.Alias('mesa', mesa)
133
134Export('mesa')
135