summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-09-14 08:17:09 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-09-15 12:23:48 (GMT)
commit211a59d837e0260456931f4b6a4d030afa07ea0c (patch)
treeeed70b106a684dd25bccd199785ee4475f07c54a /BuildTools/SCons/SConstruct
parentab2f797871abd688df5f393e3e75417facfb1bb0 (diff)
downloadswift-211a59d837e0260456931f4b6a4d030afa07ea0c.zip
swift-211a59d837e0260456931f4b6a4d030afa07ea0c.tar.bz2
Use system Lua if present
Change-Id: I665a603b1afa1e24e1b73618e976113a87be2001
Diffstat (limited to 'BuildTools/SCons/SConstruct')
-rw-r--r--BuildTools/SCons/SConstruct37
1 files changed, 32 insertions, 5 deletions
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index f3c4e5e..ae58bd9 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -83,6 +83,12 @@ def CheckPKG(context, name):
def CheckVersion(context, library, version, define, header, value) :
context.Message("Checking " + library + " version (>= " + version + ") ...")
+ version = GetVersion(context, define, header)
+ ok = version >= value
+ context.Result(ok)
+ return ok
+
+def GetVersion(context, define, header, extension = ".c") :
ret = context.TryRun("""
#include <%(header)s>
#include <stdio.h>
@@ -91,10 +97,12 @@ int main(int argc, char* argv[]) {
printf("%%d\\n", %(define)s);
return 0;
}
-""" % { "header" : header, "define": define }, ".c")
- ok = ret[0] and int(ret[1]) >= value
- context.Result(ok)
- return ok
+""" % { "header" : header, "define": define }, extension)
+ if ret[0] :
+ return int(ret[1])
+ else :
+ return -1
+
conf = Configure(conf_env)
@@ -405,7 +413,26 @@ else :
# Lua
-env["LUA_BUNDLED"] = 1
+lua_conf_env = conf_env.Clone()
+lua_flags = {}
+if env.get("lua_libdir", None) :
+ lua_flags["LIBPATH"] = [env["lua_libdir"]]
+if env.get("lua_includedir", None) :
+ lua_flags["CPPPATH"] = [env["lua_includedir"]]
+lua_conf_env.MergeFlags(lua_flags)
+conf = Configure(lua_conf_env)
+if not env.get("lua_force_bundled", False) and conf.CheckCXXHeader("lua.hpp") and conf.CheckLib(env["lua_libname"]) :
+ env["HAVE_LUA"] = 1
+ env["LUA_FLAGS"] = { "LIBS": [env["lua_libname"]] }
+ lua_version = GetVersion(conf, "LUA_VERSION_NUM", "lua.h")
+ if lua_version > 0 :
+ env["LUA_FLAGS"]["LUA_VERSION"] = str(lua_version // 100) + "." + str(lua_version % 100)
+ else :
+ print "Warning: Unable to determine Lua version. Not installing Lua libraries."
+ env["LUA_FLAGS"].update(lua_flags)
+else :
+ env["LUA_BUNDLED"] = 1
+conf.Finish()
# Readline
conf = Configure(conf_env)