5 from sys import executable as python_cmd
9 env.Prepend(CPPPATH = [
17 # Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path
18 env.Append(CPPPATH = [Dir('.').abspath])
20 env.Append(YACCFLAGS = '-d')
22 parser_env = env.Clone()
23 parser_env.Append(YACCFLAGS = [
24 '--defines=%s' % File('glsl_parser.h').abspath,
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')
33 # common generated sources
41 # parse Makefile.sources
42 source_lists = env.ParseSourceList('Makefile.sources')
44 # add non-generated sources
45 for l in ('LIBGLCPP_SOURCES', 'LIBGLSL_SOURCES', 'LIBGLSL_CXX_SOURCES'):
46 glsl_sources += source_lists[l]
49 env.Prepend(CPPPATH = ['#/src/getopt'])
50 env.PrependUnique(LIBS = [getopt])
52 if env['crosscompile'] and not env['embedded']:
53 Import('builtin_glsl_function')
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'))
60 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_SOURCES'])
62 mesa_objs = env.StaticObject([
67 compiler_objs += mesa_objs
69 builtin_compiler = env.Program(
70 target = 'builtin_compiler',
71 source = compiler_objs + glsl_sources + \
72 source_lists['BUILTIN_COMPILER_CXX_SOURCES'],
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)
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'
86 env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
88 Export('builtin_glsl_function')
94 glsl_sources += builtin_glsl_function
96 glsl = env.ConvenienceLibrary(
98 source = glsl_sources,
101 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
103 env.Depends(glsl, glsl_parser)
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']:
114 if env['platform'] == 'windows':
115 env.PrependUnique(LIBS = [
119 env.Prepend(LIBS = [glsl])
123 source = compiler_objs,
125 env.Alias('glsl2', glsl2)
128 target = 'glcpp/glcpp',
129 source = ['glcpp/glcpp.c'] + mesa_objs,
131 env.Alias('glcpp', glcpp)