egl: Add Haiku code and support
[mesa.git] / src / glsl / SConscript
1 import common
2
3 Import('*')
4
5 from sys import executable as python_cmd
6
7 env = env.Clone()
8
9 env.Prepend(CPPPATH = [
10 '#include',
11 '#src',
12 '#src/mapi',
13 '#src/mesa',
14 '#src/glsl',
15 '#src/glsl/glcpp',
16 ])
17
18 env.Prepend(LIBS = [mesautil])
19
20 # Make glcpp-parse.h and glsl_parser.h reachable from the include path.
21 env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath])
22
23 env.Append(YACCFLAGS = '-d -p "glcpp_parser_"')
24
25 parser_env = env.Clone()
26 parser_env.Append(YACCFLAGS = [
27 '--defines=%s' % File('glsl_parser.h').abspath,
28 '-p', '_mesa_glsl_',
29 ])
30
31 # without this line scons will expect "glsl_parser.hpp" instead of
32 # "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time
33 parser_env['YACCHXXFILESUFFIX'] = '.h'
34
35 glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
36 glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
37 glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
38 glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
39
40 # common generated sources
41 glsl_sources = [
42 glcpp_lexer,
43 glcpp_parser[0],
44 glsl_lexer,
45 glsl_parser[0],
46 ]
47
48 # parse Makefile.sources
49 source_lists = env.ParseSourceList('Makefile.sources')
50
51 # add non-generated sources
52 for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'):
53 glsl_sources += source_lists[l]
54
55 if env['msvc']:
56 env.Prepend(CPPPATH = ['#/src/getopt'])
57 env.PrependUnique(LIBS = [getopt])
58
59 # Copy these files to avoid generation object files into src/mesa/program
60 env.Prepend(CPPPATH = ['#src/mesa/main'])
61 env.Command('imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
62 # Copy these files to avoid generation object files into src/mesa/program
63 env.Prepend(CPPPATH = ['#src/mesa/program'])
64 env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
65 env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
66
67 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
68
69 mesa_objs = env.StaticObject([
70 'imports.c',
71 'prog_hash_table.c',
72 'symbol_table.c',
73 ])
74
75 compiler_objs += mesa_objs
76
77 glsl = env.ConvenienceLibrary(
78 target = 'glsl',
79 source = glsl_sources,
80 )
81
82 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
83 # glsl_parser.h
84 env.Depends(glsl, glsl_parser)
85
86 Export('glsl')
87
88 # Skip building these programs as they will cause SCons error "Two environments
89 # with different actions were specified for the same target"
90 if env['crosscompile'] or env['embedded']:
91 Return()
92
93 env = env.Clone()
94
95 if env['platform'] == 'windows':
96 env.PrependUnique(LIBS = [
97 'user32',
98 ])
99
100 env.Prepend(LIBS = [glsl])
101
102 glsl_compiler = env.Program(
103 target = 'glsl_compiler',
104 source = compiler_objs,
105 )
106 env.Alias('glsl_compiler', glsl_compiler)
107
108 glcpp = env.Program(
109 target = 'glcpp/glcpp',
110 source = ['glcpp/glcpp.c', 'tests/common.c'] + mesa_objs,
111 )
112 env.Alias('glcpp', glcpp)