diff options
author | José Fonseca <jfonseca@vmware.com> | 2011-01-13 20:52:01 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2011-01-13 20:53:42 +0000 |
commit | e1bc68b0140fef465cda26b74602aeb1cbcfdafc (patch) | |
tree | ed3527b8a77b7304494abde1f7ea8eb1edc53e06 | |
parent | 0448f73f06b92dfd04e553147cac0e240dbabbdd (diff) |
scons: Fix cross-compilation.
Hairy stuff. Don't know how to do it better though.
-rw-r--r-- | SConstruct | 33 | ||||
-rw-r--r-- | common.py | 26 | ||||
-rw-r--r-- | src/SConscript | 3 | ||||
-rw-r--r-- | src/glsl/SConscript | 69 |
4 files changed, 89 insertions, 42 deletions
diff --git a/SConstruct b/SConstruct index 8880d851e6..368ad83edf 100644 --- a/SConstruct +++ b/SConstruct @@ -119,6 +119,39 @@ Export('env') ####################################################################### +# Invoke host SConscripts +# +# For things that are meant to be run on the native host build machine, instead +# of the target machine. +# + +# Create host environent +if env['platform'] != common.host_platform: + host_env = Environment( + options = opts, + # no tool used + tools = [], + toolpath = ['#scons'], + ENV = os.environ, + ) + + # Override options + host_env['platform'] = common.host_platform + host_env['machine'] = common.host_machine + host_env['toolchain'] = 'default' + host_env['llvm'] = False + + host_env.Tool('gallium') + + SConscript( + 'src/glsl/SConscript', + variant_dir = host_env['build_dir'], + duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html + exports={'env':host_env}, + ) + + +####################################################################### # Invoke SConscripts # TODO: Build several variants at the same time? @@ -19,17 +19,17 @@ _platform_map = { 'win32': 'windows', } -default_platform = sys.platform -default_platform = _platform_map.get(default_platform, default_platform) +host_platform = sys.platform +host_platform = _platform_map.get(host_platform, host_platform) # Search sys.argv[] for a "platform=foo" argument since we don't have # an 'env' variable at this point. if 'platform' in SCons.Script.ARGUMENTS: - selected_platform = SCons.Script.ARGUMENTS['platform'] + target_platform = SCons.Script.ARGUMENTS['platform'] else: - selected_platform = default_platform + target_platform = host_platform -cross_compiling = selected_platform != default_platform +cross_compiling = target_platform != host_platform _machine_map = { 'x86': 'x86', @@ -42,15 +42,17 @@ _machine_map = { } -# find default_machine value +# find host_machine value if 'PROCESSOR_ARCHITECTURE' in os.environ: - default_machine = os.environ['PROCESSOR_ARCHITECTURE'] + host_machine = os.environ['PROCESSOR_ARCHITECTURE'] else: - default_machine = _platform.machine() -default_machine = _machine_map.get(default_machine, 'generic') + host_machine = _platform.machine() +host_machine = _machine_map.get(host_machine, 'generic') + +default_machine = host_machine default_toolchain = 'default' -if selected_platform == 'windows' and cross_compiling: +if target_platform == 'windows' and cross_compiling: default_machine = 'x86' default_toolchain = 'crossmingw' @@ -61,7 +63,7 @@ if 'LLVM' in os.environ: else: default_llvm = 'no' try: - if selected_platform != 'windows' and \ + if target_platform != 'windows' and \ subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: default_llvm = 'yes' except: @@ -85,7 +87,7 @@ def AddOptions(opts): opts.Add(BoolOption('quiet', 'quiet command lines', 'yes')) opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) - opts.Add(EnumOption('platform', 'target platform', default_platform, + opts.Add(EnumOption('platform', 'target platform', host_platform, allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin', 'sunos5', 'freebsd8'))) opts.Add('toolchain', 'compiler toolchain', default_toolchain) opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) diff --git a/src/SConscript b/src/SConscript index 38137ee902..201812c5ac 100644 --- a/src/SConscript +++ b/src/SConscript @@ -3,6 +3,9 @@ Import('*') if env['platform'] == 'windows': SConscript('getopt/SConscript') SConscript('talloc/SConscript') +else: + talloc = 'talloc' + Export('talloc') SConscript('glsl/SConscript') SConscript('mapi/glapi/SConscript') diff --git a/src/glsl/SConscript b/src/glsl/SConscript index a22fceb75c..88a83fdb6f 100644 --- a/src/glsl/SConscript +++ b/src/glsl/SConscript @@ -9,6 +9,7 @@ env = env.Clone() env.Prepend(CPPPATH = [ '#src/mapi', '#src/mesa', + '#src/glsl', ]) if env['platform'] == 'windows': @@ -78,46 +79,54 @@ sources = [ 'opt_tree_grafting.cpp', 's_expression.cpp', 'strtod.c', -] +] -if env['msvc']: - env.Prepend(CPPPATH = ['#/src/getopt']) - env.PrependUnique(LIBS = [getopt]) -if env['platform'] == 'windows': - env.Prepend(LIBS = [talloc]) -else: - env.Prepend(LIBS = ['talloc']) +if env['platform'] == common.host_platform: + if env['msvc']: + env.Prepend(CPPPATH = ['#/src/getopt']) + env.PrependUnique(LIBS = [getopt]) -env.Append(CPPPATH = ['#/src/glsl']) + if env['platform'] == 'windows': + env.Prepend(CPPPATH = ['#src/talloc']) + env.Prepend(LIBS = [talloc]) + else: + env.Prepend(LIBS = ['talloc']) -builtin_compiler = env.Program( - target = 'builtin_compiler', - source = sources + ['main.cpp', 'builtin_stubs.cpp', - '#src/mesa/program/hash_table.c', - '#src/mesa/program/symbol_table.c'], -) + builtin_compiler = env.Program( + target = 'builtin_compiler', + source = sources + ['main.cpp', 'builtin_stubs.cpp', + '#src/mesa/program/hash_table.c', + '#src/mesa/program/symbol_table.c'], + ) -env.CodeGenerate( - target = 'builtin_function.cpp', - script = 'builtins/tools/generate_builtins.py', - source = builtin_compiler, - command = python_cmd + ' $SCRIPT $SOURCE > $TARGET' -) + 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/*')) + + if env['msvc']: + # There is no LD_LIBRARY_PATH equivalent on Windows. We need to ensure + # talloc.dll is on the same dir as builtin_function. + talloc_dll_src = talloc.dir.File('talloc.dll') + talloc_dll_dst = builtin_compiler[0].dir.File('talloc.dll') + talloc_dll = env.Command(talloc_dll_dst, talloc_dll_src, Copy(talloc_dll_dst, talloc_dll_src)) + env.Depends('builtin_function.cpp', talloc_dll) + + Export('builtin_glsl_function') -env.Depends('builtin_function.cpp', ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*')) + if common.cross_compiling: + Return() -if env['msvc']: - # There is no LD_LIBRARY_PATH equivalent on Windows. We need to ensure - # talloc.dll is on the same dir as builtin_function. - talloc_dll_src = talloc.dir.File('talloc.dll') - talloc_dll_dst = builtin_compiler[0].dir.File('talloc.dll') - talloc_dll = env.Command(talloc_dll_dst, talloc_dll_src, Copy(talloc_dll_dst, talloc_dll_src)) - env.Depends('builtin_function.cpp', talloc_dll) +sources += builtin_glsl_function glsl = env.ConvenienceLibrary( target = 'glsl', - source = sources + [ 'builtin_function.cpp' ], + source = sources, ) Export('glsl') |