mail[Wesnoth-commits] r25248 - /trunk/SConstruct


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by esr on March 28, 2008 - 17:14:
Author: esr
Date: Fri Mar 28 17:14:09 2008
New Revision: 25248

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25248&view=rev
Log:
Fold in loonycyborg's boost check code, not used yet.

Modified:
    trunk/SConstruct

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=25248&r1=25247&r2=25248&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Fri Mar 28 17:14:09 2008
@@ -78,7 +78,7 @@
 env.TargetSignatures('content')
 
 #
-# Most of our required runtime support is from SDL.
+# Most of our required runtime support is from Boost SDL.
 #
 
 def CheckPKGConfig(context, version):
@@ -86,6 +86,69 @@
      ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % 
version)[0]
      context.Result( ret )
      return ret
+
+def backup_env(env, vars):
+    backup = dict()
+    for var in vars:
+        backup[var] = env.get(var, [])
+    return backup
+
+def restore_env(env, backup):
+    for var in backup.keys():
+        env[var] = backup[var]
+
+def CheckBoostLib(context, boost_lib, require_version = None):
+    env = context.env
+    backup = backup_env(env, ["CPPPATH", "LIBPATH", "LIBS"])
+    env.AppendUnique(CPPPATH = [env["BOOSTDIR"]], LIBPATH = 
[env["BOOSTLIBS"]])
+
+    boost_headers = { "regex" : "regex/config.hpp" }
+    header_name = boost_headers.get(boost_lib, boost_lib + ".hpp")
+    libname = "boost_" + boost_lib + env.get("BOOST_SUFFIX", "")
+
+    env.AppendUnique(CPPPATH = [env["BOOSTDIR"]], LIBPATH = 
[env["BOOSTLIBS"]])
+    env.AppendUnique(LIBS = [libname])
+
+    test_program = """
+        #include <boost/%s>
+        \n""" % header_name
+    if require_version:
+        version = require_version.split(".", 2)
+        major = int(version[0])
+        minor = int(version[1])
+        try:
+            sub_minor = int(version[2])
+        except (ValueError, IndexError):
+            sub_minor = 0
+        test_program += "#include <boost/version.hpp>\n"
+        test_program += \
+            "#if BOOST_VERSION < %d\n#error Boost version is too 
old!\n#endif\n" \
+            % (major * 100000 + minor * 100 + sub_minor)
+    test_program += """
+        int main()
+        {
+        }
+        \n"""
+    if context.TryLink(test_program, ".cpp"):
+        return True
+    else:
+        restore_env(env, 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["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
 
 def CheckPKG(context, name):
      context.Message( 'Checking for %s... ' % name )




Related Messages


Powered by MHonArc, Updated Fri Mar 28 17:21:21 2008