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