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