2009-12-10 16:29:04 +00:00
|
|
|
import common
|
|
|
|
|
|
|
|
Import('*')
|
|
|
|
|
2011-01-07 22:30:14 +00:00
|
|
|
from sys import executable as python_cmd
|
|
|
|
|
2009-12-10 16:29:04 +00:00
|
|
|
env = env.Clone()
|
|
|
|
|
2010-08-13 13:55:34 +01:00
|
|
|
env.Prepend(CPPPATH = [
|
2011-01-31 21:07:12 +00:00
|
|
|
'#include',
|
2010-08-13 13:55:34 +01:00
|
|
|
'#src/mapi',
|
|
|
|
'#src/mesa',
|
2011-01-13 20:52:01 +00:00
|
|
|
'#src/glsl',
|
2011-03-01 23:04:04 +00:00
|
|
|
'#src/glsl/glcpp',
|
2010-08-13 13:55:34 +01:00
|
|
|
])
|
|
|
|
|
2012-06-19 08:02:53 +01:00
|
|
|
# Make glcpp-parse.h and glsl_parser.h reachable from the include path.
|
|
|
|
env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath])
|
2011-03-03 16:57:38 +00:00
|
|
|
|
2011-03-01 23:04:04 +00:00
|
|
|
env.Append(YACCFLAGS = '-d')
|
|
|
|
|
2011-03-03 16:57:38 +00:00
|
|
|
parser_env = env.Clone()
|
|
|
|
parser_env.Append(YACCFLAGS = [
|
|
|
|
'--defines=%s' % File('glsl_parser.h').abspath,
|
|
|
|
'-p', '_mesa_glsl_',
|
|
|
|
])
|
2011-03-01 23:04:04 +00:00
|
|
|
|
|
|
|
glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
|
|
|
|
glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
|
|
|
|
glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
|
|
|
|
glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
|
|
|
|
|
2011-10-30 11:32:25 +00:00
|
|
|
# common generated sources
|
2011-03-04 13:11:49 +00:00
|
|
|
glsl_sources = [
|
2011-03-01 23:04:04 +00:00
|
|
|
glcpp_lexer,
|
|
|
|
glcpp_parser[0],
|
|
|
|
glsl_lexer,
|
|
|
|
glsl_parser[0],
|
2011-01-13 20:52:01 +00:00
|
|
|
]
|
2009-12-10 16:29:04 +00:00
|
|
|
|
2011-10-30 11:32:25 +00:00
|
|
|
# parse Makefile.sources
|
|
|
|
source_lists = env.ParseSourceList('Makefile.sources')
|
|
|
|
|
|
|
|
# add non-generated sources
|
2012-01-29 01:13:51 +00:00
|
|
|
for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES', 'LIBGLSL_CXX_FILES'):
|
2011-10-30 11:32:25 +00:00
|
|
|
glsl_sources += source_lists[l]
|
|
|
|
|
2011-03-04 13:11:49 +00:00
|
|
|
if env['msvc']:
|
|
|
|
env.Prepend(CPPPATH = ['#/src/getopt'])
|
|
|
|
env.PrependUnique(LIBS = [getopt])
|
|
|
|
|
2011-06-17 14:48:28 +01:00
|
|
|
if env['crosscompile'] and not env['embedded']:
|
2011-02-11 17:38:54 +00:00
|
|
|
Import('builtin_glsl_function')
|
|
|
|
else:
|
2011-03-11 23:33:18 +00:00
|
|
|
# Copy these files to avoid generation object files into src/mesa/program
|
|
|
|
env.Prepend(CPPPATH = ['#src/mesa/program'])
|
|
|
|
env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
|
|
|
|
env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
|
|
|
|
|
2012-01-29 01:13:51 +00:00
|
|
|
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
|
2011-03-04 14:29:06 +00:00
|
|
|
|
|
|
|
mesa_objs = env.StaticObject([
|
2011-03-11 23:33:18 +00:00
|
|
|
'hash_table.c',
|
|
|
|
'symbol_table.c',
|
2011-03-04 14:29:06 +00:00
|
|
|
])
|
|
|
|
|
2011-10-30 11:32:25 +00:00
|
|
|
compiler_objs += mesa_objs
|
|
|
|
|
2011-01-13 20:52:01 +00:00
|
|
|
builtin_compiler = env.Program(
|
|
|
|
target = 'builtin_compiler',
|
2011-10-30 11:32:25 +00:00
|
|
|
source = compiler_objs + glsl_sources + \
|
2012-01-29 01:13:51 +00:00
|
|
|
source_lists['BUILTIN_COMPILER_CXX_FILES'],
|
2011-01-13 20:52:01 +00:00
|
|
|
)
|
2011-01-07 22:30:14 +00:00
|
|
|
|
2011-03-03 16:57:38 +00:00
|
|
|
# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll
|
|
|
|
# depends on glsl_parser.h
|
|
|
|
env.Depends(builtin_compiler, glsl_parser)
|
|
|
|
|
2011-01-13 20:52:01 +00:00
|
|
|
builtin_glsl_function = env.CodeGenerate(
|
|
|
|
target = 'builtin_function.cpp',
|
|
|
|
script = 'builtins/tools/generate_builtins.py',
|
|
|
|
source = builtin_compiler,
|
|
|
|
command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
|
|
|
|
)
|
|
|
|
|
|
|
|
env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
|
|
|
|
|
|
|
|
Export('builtin_glsl_function')
|
2011-01-07 22:30:14 +00:00
|
|
|
|
2011-02-11 17:38:54 +00:00
|
|
|
if env['hostonly']:
|
|
|
|
Return()
|
|
|
|
|
|
|
|
|
2011-03-04 13:11:49 +00:00
|
|
|
glsl_sources += builtin_glsl_function
|
2011-01-12 16:58:37 +00:00
|
|
|
|
2009-12-28 15:22:17 +00:00
|
|
|
glsl = env.ConvenienceLibrary(
|
2009-12-10 16:29:04 +00:00
|
|
|
target = 'glsl',
|
2011-03-04 13:11:49 +00:00
|
|
|
source = glsl_sources,
|
2009-12-10 16:29:04 +00:00
|
|
|
)
|
|
|
|
|
2011-03-03 16:57:38 +00:00
|
|
|
# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
|
|
|
|
# glsl_parser.h
|
|
|
|
env.Depends(glsl, glsl_parser)
|
|
|
|
|
2009-12-10 16:29:04 +00:00
|
|
|
Export('glsl')
|
|
|
|
|
2011-03-04 14:29:06 +00:00
|
|
|
# Skip building these programs as they will cause SCons error "Two environments
|
|
|
|
# with different actions were specified for the same target"
|
2011-06-17 14:48:28 +01:00
|
|
|
if env['crosscompile'] or env['embedded']:
|
2011-03-04 14:29:06 +00:00
|
|
|
Return()
|
|
|
|
|
2009-12-10 16:29:04 +00:00
|
|
|
env = env.Clone()
|
|
|
|
|
|
|
|
if env['platform'] == 'windows':
|
|
|
|
env.PrependUnique(LIBS = [
|
|
|
|
'user32',
|
|
|
|
])
|
|
|
|
|
2011-01-24 18:35:48 +00:00
|
|
|
env.Prepend(LIBS = [glsl])
|
2009-12-10 16:29:04 +00:00
|
|
|
|
2011-03-04 13:11:49 +00:00
|
|
|
glsl2 = env.Program(
|
2010-08-13 13:55:34 +01:00
|
|
|
target = 'glsl2',
|
2011-10-30 11:32:25 +00:00
|
|
|
source = compiler_objs,
|
2009-12-10 16:29:04 +00:00
|
|
|
)
|
2011-03-04 13:11:49 +00:00
|
|
|
env.Alias('glsl2', glsl2)
|
2009-12-10 16:29:04 +00:00
|
|
|
|
2011-03-04 13:11:49 +00:00
|
|
|
glcpp = env.Program(
|
|
|
|
target = 'glcpp/glcpp',
|
|
|
|
source = ['glcpp/glcpp.c'] + mesa_objs,
|
2009-12-10 16:29:04 +00:00
|
|
|
)
|
2011-03-04 13:11:49 +00:00
|
|
|
env.Alias('glcpp', glcpp)
|