Author: loonycyborg
Date: Tue Jun 24 22:43:09 2008
New Revision: 27497
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27497&view=rev
Log:
Improved boost autodetection.
Modified:
trunk/SConstruct
trunk/scons/boost.py
trunk/scons/config_check_utils.py
Modified: trunk/SConstruct
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=27497&r1=27496&r2=27497&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Tue Jun 24 22:43:09 2008
@@ -25,6 +25,10 @@
#
opts = Options('.scons-option-cache')
+
+def OptionalPath(key, val, env):
+ if val:
+ PathOption.PathIsDir(key, val, env)
opts.AddOptions(
ListOption('default_targets', 'Targets that will be built if no target is
specified in command line.',
@@ -67,13 +71,13 @@
BoolOption('static', 'Set to enable static building of Wesnoth', False),
BoolOption('strict', 'Set to strict compilation', False),
BoolOption('verbose', 'Emit progress messages during data installation.',
False),
- PathOption('sdldir', 'Directory of SDL installation.', "",
PathOption.PathAccept),
- PathOption('boostdir', 'Directory of boost installation.', '/usr/include'),
- PathOption('boostlibdir', 'Directory where boost libraries are
installed.', '/usr/lib'),
+ PathOption('sdldir', 'Directory of SDL installation.', "", OptionalPath),
+ PathOption('boostdir', 'Directory of boost installation.', "",
OptionalPath),
+ PathOption('boostlibdir', 'Directory where boost libraries are
installed.', "", OptionalPath),
('boost_suffix', 'Suffix of boost libraries.'),
- PathOption('gettextdir', 'Root directory of Gettext\'s installation.', "",
PathOption.PathAccept),
+ PathOption('gettextdir', 'Root directory of Gettext\'s installation.', "",
OptionalPath),
('host', 'Cross-compile host.', ''),
- ('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
+ ('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
BoolOption("fast", "Make scons faster at cost of less precise dependency
tracking.", False)
)
Modified: trunk/scons/boost.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/scons/boost.py?rev=27497&r1=27496&r2=27497&view=diff
==============================================================================
--- trunk/scons/boost.py (original)
+++ trunk/scons/boost.py Tue Jun 24 22:43:09 2008
@@ -1,11 +1,33 @@
# vi: syntax=python:et:ts=4
from config_check_utils import *
+from os.path import join
+from glob import glob
-def CheckBoostLib(context, boost_lib, require_version = None):
+def find_boost(env):
+ include = find_include([env["prefix"]], "boost/config.hpp", "")
+ if include:
+ prefix, includefile = include[0]
+ env["boostdir"] = join(prefix, "include")
+ env["boostlibdir"] = join(prefix, "lib")
+ if not env["boost_suffix"]:
+ if glob(join(prefix, "lib", "libboost_*-mt.*")):
+ env["boost_suffix"] = "-mt"
+ else:
+ env["boost_suffix"] = ""
+ return
+
+def CheckBoost(context, boost_lib, require_version = None):
env = context.env
- boostdir = env.get("boostdir", "/usr/include")
- boostlibdir = env.get("boostlibdir", "/usr/lib")
- backup = backup_env(env, ["CPPPATH", "LIBPATH", "LIBS"])
+ if require_version:
+ context.Message("Checking for Boost %s library version >= %s... " %
(boost_lib, require_version))
+ else:
+ context.Message("Checking for Boost %s library... " % boost_lib)
+
+ if not env.get("boostdir", "") and not env.get("boostlibdir", ""):
+ find_boost(env)
+ boostdir = env.get("boostdir", "")
+ boostlibdir = env.get("boostlibdir", "")
+ backup = env.Clone().Dictionary()
boost_headers = { "regex" : "regex/config.hpp",
"iostreams" : "iostreams/constants.hpp",
@@ -40,24 +62,11 @@
}
\n"""
if context.TryLink(test_program, ".cpp"):
+ context.Result("yes")
return True
else:
- restore_env(env, backup)
+ context.Result("no")
+ env.Replace(**backup)
return False
-def CheckBoost(context, boost_lib, require_version = None):
- if require_version:
- context.Message("Checking for Boost %s library version >= %s... " %
(boost_lib, require_version))
- else:
- context.Message("Checking for Boost %s library... " % boost_lib)
- check_result = CheckBoostLib(context, boost_lib, require_version)
- if not check_result and not context.env.get("boost_suffix"):
- context.env["boost_suffix"] = "-mt"
- check_result = CheckBoostLib(context, boost_lib, require_version)
- if check_result:
- context.Result("yes")
- else:
- context.Result("no")
- return check_result
-
config_checks = { "CheckBoost" : CheckBoost }
Modified: trunk/scons/config_check_utils.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/scons/config_check_utils.py?rev=27497&r1=27496&r2=27497&view=diff
==============================================================================
--- trunk/scons/config_check_utils.py (original)
+++ trunk/scons/config_check_utils.py Tue Jun 24 22:43:09 2008
@@ -1,4 +1,6 @@
# vi: syntax=python:et:ts=4
+from glob import glob
+from os.path import join
def backup_env(env, vars):
backup = dict()
@@ -9,3 +11,7 @@
def restore_env(env, backup):
for var in backup.keys():
env[var] = backup[var]
+
+def find_include(prefixes, include_file, include_subdir):
+ prefixes.extend(["/usr", "/usr/local"])
+ return [(prefix, include) for prefix in prefixes for include in
glob(join(prefix, "include", include_subdir, include_file))]
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits