5 from sys import executable as python_cmd
11 env.Prepend(CPPPATH = [
16 '#src/gallium/include',
17 '#src/gallium/auxiliary',
19 '#src/compiler/glsl/glcpp',
23 env.Prepend(LIBS = [mesautil])
25 # Make glcpp-parse.h and glsl_parser.h reachable from the include path.
26 env.Prepend(CPPPATH = [Dir('.').abspath, Dir('glsl').abspath])
27 # Make NIR headers reachable from the include path.
28 env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
30 glcpp_env = env.Clone()
31 glcpp_env.Append(YACCFLAGS = [
36 glsl_env = env.Clone()
37 glsl_env.Append(YACCFLAGS = [
38 '--defines=%s' % File('glsl/glsl_parser.h').abspath,
42 # without this line scons will expect "glsl_parser.hpp" instead of
43 # "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time
44 glsl_env['YACCHXXFILESUFFIX'] = '.h'
46 glcpp_lexer = glcpp_env.CFile('glsl/glcpp/glcpp-lex.c', 'glsl/glcpp/glcpp-lex.l')
47 glcpp_parser = glcpp_env.CFile('glsl/glcpp/glcpp-parse.c', 'glsl/glcpp/glcpp-parse.y')
48 glsl_lexer = glsl_env.CXXFile('glsl/glsl_lexer.cpp', 'glsl/glsl_lexer.ll')
49 glsl_parser = glsl_env.CXXFile('glsl/glsl_parser.cpp', 'glsl/glsl_parser.yy')
51 # common generated sources
59 # parse Makefile.sources
60 source_lists = env.ParseSourceList('Makefile.sources')
62 # add non-generated sources
63 for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'):
64 glsl_sources += source_lists[l]
66 glsl_sources += env.StaticObject("glsl/glcpp/pp_standalone_scaffolding.c")
69 env.Prepend(CPPPATH = ['#/src/getopt'])
70 env.PrependUnique(LIBS = [getopt])
72 # Copy these files to avoid generation object files into src/mesa/program
73 env.Prepend(CPPPATH = ['#src/mesa/main'])
74 env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
75 env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
76 # Copy these files to avoid generation object files into src/mesa/program
77 env.Prepend(CPPPATH = ['#src/mesa/program'])
78 env.Command('glsl/symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
79 env.Command('glsl/dummy_errors.c', '#src/mesa/program/dummy_errors.c', Copy('$TARGET', '$SOURCE'))
81 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
83 mesa_objs = env.StaticObject([
84 'glsl/extensions_table.c',
86 'glsl/symbol_table.c',
87 'glsl/dummy_errors.c',
90 compiler_objs += mesa_objs
92 # GLSL generated sources
94 target = 'glsl/float64_glsl.h',
95 script = 'glsl/xxd.py',
96 source = ['glsl/float64.glsl'],
97 command = python_cmd + ' $SCRIPT $SOURCE $TARGET -n float64_source',
101 target = 'glsl/ir_expression_operation.h',
102 script = 'glsl/ir_expression_operation.py',
104 command = python_cmd + ' $SCRIPT enum > $TARGET'
107 target = 'glsl/ir_expression_operation_constant.h',
108 script = 'glsl/ir_expression_operation.py',
110 command = python_cmd + ' $SCRIPT constant > $TARGET'
113 target = 'glsl/ir_expression_operation_strings.h',
114 script = 'glsl/ir_expression_operation.py',
116 command = python_cmd + ' $SCRIPT strings > $TARGET'
119 glsl = env.ConvenienceLibrary(
121 source = glsl_sources,
124 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
126 env.Depends(glsl, glsl_parser)
131 # XXX: It's important to not add any generated source files after this point,
132 # or it will break MinGW cross-compilation.
135 # Skip building these programs as they will cause SCons error "Two environments
136 # with different actions were specified for the same target"
137 if env['crosscompile'] or env['embedded']:
142 if env['platform'] == 'windows':
143 env.PrependUnique(LIBS = [
147 env.Prepend(LIBS = [compiler, glsl])
149 compiler_objs += env.StaticObject("glsl/main.cpp")
151 glsl_compiler = env.Program(
152 target = 'glsl_compiler',
153 source = compiler_objs,
155 env.Alias('glsl_compiler', glsl_compiler)
158 target = 'glsl/glcpp/glcpp',
159 source = ['glsl/glcpp/glcpp.c'] + mesa_objs,
161 env.Alias('glcpp', glcpp)