SCons recipe: added cross-compile support.

This commit is contained in:
Sergey Popov 2008-06-23 19:52:02 +00:00
parent 19b452540b
commit d41f1064ce
3 changed files with 34 additions and 4 deletions

View file

@ -72,6 +72,7 @@ opts.AddOptions(
PathOption('boostlibdir', 'Directory where boost libraries are installed.', '/usr/lib'),
('boost_suffix', 'Suffix of boost libraries.'),
PathOption('gettextdir', 'Root directory of Gettext\'s installation.', "", PathOption.PathAccept),
('host', 'Cross-compile host.', ''),
('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
BoolOption("fast", "Make scons faster at cost of less precise dependency tracking.", False)
)
@ -80,19 +81,21 @@ opts.AddOptions(
# Setup
#
sys.path.append("./scons")
env = Environment(tools=["tar", "gettext", "install"], options = opts, toolpath = ["scons"])
opts.Save('.scons-option-cache', env)
if env["PLATFORM"] == "win32":
env.Tool("mingw")
env['ENV']['PATH'] = os.environ["PATH"]
else:
env.Tool("default")
from cross_compile import *
setup_cross_compile(env)
if env.get('cxxtool',""):
env['CXX'] = env['cxxtool']
opts.Save('.scons-option-cache', env)
Help("""Arguments may be a mixture of switches and targets an any order.
Switches apply to the entire build regrdless of where they are in the order.
Important switches include:
@ -163,7 +166,6 @@ def Warning(message):
print message
return False
sys.path.append("./scons")
from metasconf import init_metasconf
conf = Configure(env, custom_tests = init_metasconf(env, ["cplusplus", "python_devel", "sdl", "boost"]), config_h = "config.h")

25
scons/cross_compile.py Normal file
View file

@ -0,0 +1,25 @@
# vi: syntax=python:et:ts=4
def setup_cross_compile(env):
if env["host"] == "mingw32":
env["PLATFORM"] = "win32"
env["PROGSUFFIX"] = ".exe"
env.Tool("mingw")
else:
env.Tool("default")
if env["host"]:
tools = [
"CXX",
"CC",
"AR",
"RANLIB",
"RC"
]
for tool in tools:
if env.has_key(tool):
env[tool] = env["host"] + "-" + env[tool]
env.PrependUnique(CPPPATH="$prefix/include", LIBPATH="$prefix/lib")
if not env["sdldir"] and env["PLATFORM"] == "win32":
env["sdldir"] = "$prefix"

View file

@ -84,6 +84,9 @@ def CheckOgg(context):
'''
#context.env.AppendUnique(LIBS = "SDL_mixer")
context.Message("Checking for Ogg Vorbis support in SDL... ")
if context.env["host"]:
context.Result("n/a (cross-compile)")
return True
(result, output) = context.TryRun(test_program, ".c")
if result:
context.Result("yes")