Tizen 2.1 base
[sdk/emulator/qemu.git] / gl / mesa / 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/mapi',
12     '#src/mesa',
13     '#src/glsl',
14     '#src/glsl/glcpp',
15 ])
16
17 # Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path
18 env.Append(CPPPATH = [Dir('.').abspath])
19
20 env.Append(YACCFLAGS = '-d')
21
22 parser_env = env.Clone()
23 parser_env.Append(YACCFLAGS = [
24     '--defines=%s' % File('glsl_parser.h').abspath,
25     '-p', '_mesa_glsl_',
26 ])
27
28 glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
29 glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
30 glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
31 glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
32
33 # common generated sources
34 glsl_sources = [
35     glcpp_lexer,
36     glcpp_parser[0],
37     glsl_lexer,
38     glsl_parser[0],
39
40
41 # parse Makefile.sources
42 source_lists = env.ParseSourceList('Makefile.sources')
43
44 # add non-generated sources
45 for l in ('LIBGLCPP_SOURCES', 'LIBGLSL_SOURCES', 'LIBGLSL_CXX_SOURCES'):
46     glsl_sources += source_lists[l]
47
48 if env['msvc']:
49     env.Prepend(CPPPATH = ['#/src/getopt'])
50     env.PrependUnique(LIBS = [getopt])
51
52 if env['crosscompile'] and not env['embedded']:
53     Import('builtin_glsl_function')
54 else:
55     # Copy these files to avoid generation object files into src/mesa/program
56     env.Prepend(CPPPATH = ['#src/mesa/program'])
57     env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
58     env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
59
60     compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_SOURCES'])
61
62     mesa_objs = env.StaticObject([
63         'hash_table.c',
64         'symbol_table.c',
65     ])
66
67     compiler_objs += mesa_objs
68
69     builtin_compiler = env.Program(
70         target = 'builtin_compiler',
71         source = compiler_objs + glsl_sources + \
72             source_lists['BUILTIN_COMPILER_CXX_SOURCES'],
73     )
74
75     # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll
76     # depends on glsl_parser.h
77     env.Depends(builtin_compiler, glsl_parser)
78
79     builtin_glsl_function = env.CodeGenerate(
80         target = 'builtin_function.cpp',
81         script = 'builtins/tools/generate_builtins.py',
82         source = builtin_compiler,
83         command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
84     )
85
86     env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
87
88     Export('builtin_glsl_function')
89
90     if env['hostonly']:
91         Return()
92
93
94 glsl_sources += builtin_glsl_function
95
96 glsl = env.ConvenienceLibrary(
97     target = 'glsl',
98     source = glsl_sources,
99 )
100
101 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
102 # glsl_parser.h
103 env.Depends(glsl, glsl_parser)
104
105 Export('glsl')
106
107 # Skip building these programs as they will cause SCons error "Two environments
108 # with different actions were specified for the same target"
109 if env['crosscompile'] or env['embedded']:
110     Return()
111
112 env = env.Clone()
113
114 if env['platform'] == 'windows':
115     env.PrependUnique(LIBS = [
116         'user32',
117     ])
118
119 env.Prepend(LIBS = [glsl])
120
121 glsl2 = env.Program(
122     target = 'glsl2',
123     source = compiler_objs,
124 )
125 env.Alias('glsl2', glsl2)
126
127 glcpp = env.Program(
128     target = 'glcpp/glcpp',
129     source = ['glcpp/glcpp.c'] + mesa_objs,
130 )
131 env.Alias('glcpp', glcpp)