5 from sys import executable as python_cmd
9 env.Prepend(CPPPATH = [
17 # Make glcpp-parse.h and glsl_parser.h reachable from the include path.
18 env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath])
20 env.Append(YACCFLAGS = '-d -p "glcpp_parser_"')
22 parser_env = env.Clone()
23 parser_env.Append(YACCFLAGS = [
24 '--defines=%s' % File('glsl_parser.h').abspath,
28 # without this line scons will expect "glsl_parser.hpp" instead of
29 # "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time
30 parser_env['YACCHXXFILESUFFIX'] = '.h'
32 glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
33 glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
34 glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
35 glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
37 # common generated sources
45 # parse Makefile.sources
46 source_lists = env.ParseSourceList('Makefile.sources')
48 # add non-generated sources
49 for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'):
50 glsl_sources += source_lists[l]
53 env.Prepend(CPPPATH = ['#/src/getopt'])
54 env.PrependUnique(LIBS = [getopt])
56 if env['crosscompile'] and not env['embedded']:
57 Import('builtin_glsl_function')
59 # Copy these files to avoid generation object files into src/mesa/program
60 env.Prepend(CPPPATH = ['#src/mesa/main'])
61 env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
62 env.Command('imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
63 # Copy these files to avoid generation object files into src/mesa/program
64 env.Prepend(CPPPATH = ['#src/mesa/program'])
65 env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
66 env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
68 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
70 mesa_objs = env.StaticObject([
77 compiler_objs += mesa_objs
79 builtin_compiler = env.Program(
80 target = 'builtin_compiler/builtin_compiler',
81 source = compiler_objs + glsl_sources + \
82 source_lists['BUILTIN_COMPILER_CXX_FILES'],
85 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll
86 # depends on glsl_parser.h
87 env.Depends(builtin_compiler, glsl_parser)
89 builtin_glsl_function = env.CodeGenerate(
90 target = 'builtin_function.cpp',
91 script = 'builtins/tools/generate_builtins.py',
92 source = builtin_compiler,
93 command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
96 env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', '#src/glsl/builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
98 Export('builtin_glsl_function')
104 glsl_sources += builtin_glsl_function
106 glsl = env.ConvenienceLibrary(
108 source = glsl_sources,
111 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
113 env.Depends(glsl, glsl_parser)
117 # Skip building these programs as they will cause SCons error "Two environments
118 # with different actions were specified for the same target"
119 if env['crosscompile'] or env['embedded']:
124 if env['platform'] == 'windows':
125 env.PrependUnique(LIBS = [
129 env.Prepend(LIBS = [glsl])
133 source = compiler_objs,
135 env.Alias('glsl2', glsl2)
138 target = 'glcpp/glcpp',
139 source = ['glcpp/glcpp.c'] + mesa_objs,
141 env.Alias('glcpp', glcpp)