summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools/SCons/SConstruct')
-rw-r--r--BuildTools/SCons/SConstruct62
1 files changed, 34 insertions, 28 deletions
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 6d63d5b..78f388b 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -1,21 +1,21 @@
import sys, os, re, platform
import SCons.SConf
Import("env", "conf_env")
root = Dir("../..").abspath
# Override SConscript to handle tests
oldSConscript = SConscript
-def SConscript(*arguments, **keywords) :
- if not keywords.get("test_only", False) or env["TEST"] :
- return apply(oldSConscript, arguments, keywords)
+def SConscript(*args, **kwargs) :
+ if not kwargs.get("test_only", False) or env["TEST"] :
+ return oldSConscript(*args, **kwargs)
env.SConscript = SConscript
################################################################################
# Extend the default build environment (not affecting the configure env)
#
# Keeping both environments separated mostly because of SCons Issue 2391,
# although it doesn't hurt to separate them (e.g. not have pretty printed
# strings in config.log)
################################################################################
@@ -136,23 +136,23 @@ int main(int argc, char* argv[]) {
return int(ret[1])
else :
return -1
conf = Configure(conf_env, custom_tests = {
'CheckCpp11Support' : checkForCpp11Support,
})
if not conf.CheckCXX() or not conf.CheckCC() :
- print "Error: You need a working compiler"
+ print("Error: You need a working compiler")
Exit(1)
if not conf.CheckCpp11Support() :
- print "Error: You need a compiler with support for the C++11 standard"
+ print("Error: You need a compiler with support for the C++11 standard")
Exit(1)
env["HAVE_ZLIB"] = True
zlib_flags = {}
zlib_okay = False
if env.get("zlib_libdir", None) :
zlib_flags["LIBPATH"] = [env["zlib_libdir"]]
zlib_okay = True
@@ -164,19 +164,19 @@ if env.get("zlib_libfile", None) :
zlib_okay = True
elif zlib_okay :
zlib_flags["LIBS"] = ["z"]
if (not zlib_okay) and conf.CheckLib("z") :
zlib_flags["LIBS"] = ["z"]
zlib_okay = True
if zlib_okay :
env["ZLIB_FLAGS"] = zlib_flags
elif not env.get("zlib_bundled_enable", True) :
- print "Error: Zlib not found and zlib_bundled_enable is false"
+ print("Error: Zlib not found and zlib_bundled_enable is false")
Exit(1)
else :
env["ZLIB_BUNDLED"] = True
if conf.CheckLib("resolv") :
env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["resolv"]
if env["PLATFORM"] != "win32" :
if conf.CheckLib("pthread") :
@@ -232,19 +232,19 @@ for (lib, header) in boostLibs :
libNames.append(libName)
if not env.get("boost_force_bundled") and allLibsPresent :
env["BOOST_FLAGS"] = boost_flags
if env["PLATFORM"] != "win32" :
env["BOOST_FLAGS"].update({"LIBS": libNames})
if not conf.CheckCXXHeader("boost/uuid/uuid.hpp") :
# FIXME: Remove this workaround when UUID is available in most distros
env["BOOST_BUNDLED_UUID_ONLY"] = True
elif not env.get("boost_bundled_enable", True) :
- print "Error: Boost not found and boost_bundled_enable is false"
+ print("Error: Boost not found and boost_bundled_enable is false")
Exit(1)
else :
env["BOOST_BUNDLED"] = True
boost_version = GetVersion(conf, "BOOST_VERSION", "boost/version.hpp")
if boost_version == 106400 :
#Version 1.64 has some issues with the serialization of boost::optional, see https://svn.boost.org/trac10/ticket/13050
env["BOOST_1_64_DETECTED"] = True
else:
env["BOOST_1_64_DETECTED"] = False
@@ -367,19 +367,19 @@ if env.get("try_expat", True) and not env.get("HAVE_LIBXML",0) :
if conf.CheckCHeader("expat.h") and conf.CheckLib(env["expat_libname"]) :
env["HAVE_EXPAT"] = 1
env["EXPAT_FLAGS"] = { "LIBS": [env["expat_libname"]] }
env["EXPAT_FLAGS"].update(expat_flags)
conf.Finish()
# Bundled expat
bundledExpat = False
if not env.get("HAVE_EXPAT", 0) and not env.get("HAVE_LIBXML", 0) :
- print "Expat or LibXML not found. Using bundled Expat"
+ print("Expat or LibXML not found. Using bundled Expat")
SConscript("#/3rdParty/Expat/SConscript")
env["HAVE_EXPAT"] = 1
env["EXPAT_BUNDLED"] = True
################################################################################
# IDN library
################################################################################
env["NEED_IDN"] = env.get("need_idn", True)
@@ -418,22 +418,22 @@ if env.get("try_libidn", True) and not env.get("HAVE_ICU") and conf.CheckCHeader
env["LIBIDN_FLAGS"].update(libidn_flags)
conf.Finish()
# Fallback to bundled LibIDN
if not env.get("HAVE_ICU", False) and not env.get("HAVE_LIBIDN", False) :
if env.get("libidn_bundled_enable", True) :
env["HAVE_LIBIDN"] = 1
env["LIBIDN_BUNDLED"] = 1
elif env.get("need_idn", True):
- print "Error: ICU and LIBIDN not found, and libidn_bundled_enable is false"
+ print("Error: ICU and LIBIDN not found, and libidn_bundled_enable is false")
Exit(1)
else:
- print "Proceeding without an IDN library because need_idn was false. This will break all internal binaries"
+ print("Proceeding without an IDN library because need_idn was false. This will break all internal binaries")
# Unbound
if env["unbound"] :
env["LDNS_BUNDLED"] = 1
env["UNBOUND_BUNDLED"] = 1
else :
env["LDNS_FLAGS"] = {}
env["UNBOUND_FLAGS"] = {}
@@ -508,19 +508,19 @@ if env.get("lua_includedir", None) :
lua_conf_env.MergeFlags(lua_flags)
conf = Configure(lua_conf_env)
if not env.get("lua_force_bundled", False) and conf.CheckLibWithHeader(env["lua_libname"], "lua.hpp", "cxx", autoadd = 0) :
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."
+ 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
editline_conf_env = conf_env.Clone()
editline_flags = {}
if env.get("editline_libdir", None) :
@@ -548,18 +548,22 @@ if env.get("try_avahi", True) and conf.CheckCHeader("avahi-client/client.h") and
env["HAVE_AVAHI"] = True
env["AVAHI_FLAGS"] = { "LIBS": ["avahi-client", "avahi-common"] }
env["AVAHI_FLAGS"].update(avahi_flags)
conf.Finish()
# Qt
if env["qt"] :
env["QTDIR"] = env["qt"]
+if env["PLATFORM"] == "win32" :
+ systemIncludeFlag = "/I"
+else:
+ systemIncludeFlag = "-isystem"
################################################################################
# TLS backend selection
################################################################################
env["OPENSSL_FLAGS"] = {}
if env.get("tls_backend") == "native" :
if env["PLATFORM"] == "win32" :
env["HAVE_SCHANNEL"] = True
elif env["PLATFORM"] == "darwin" and env["target"] == "native":
@@ -577,21 +581,21 @@ elif env.get("tls_backend") == "openssl" :
use_openssl = bool(env["openssl"])
openssl_prefix = ""
if isinstance(env["openssl"], str) :
openssl_prefix = env["openssl"]
openssl_flags = {}
if openssl_prefix :
openssl_include = env.get("openssl_include")
openssl_libdir = env.get("openssl_libdir")
if openssl_include:
- openssl_flags = {"CPPPATH":[openssl_include]}
+ openssl_flags = { "CPPFLAGS": [systemIncludeFlag + openssl_include]}
else:
- openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] }
+ openssl_flags = { "CPPFLAGS": [systemIncludeFlag + os.path.join(openssl_prefix, "include")] }
if openssl_libdir:
openssl_flags["LIBPATH"] = [openssl_libdir]
env["OPENSSL_DIR"] = openssl_prefix
elif env["PLATFORM"] == "win32" :
openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib", "VC")]
env["OPENSSL_DIR"] = openssl_prefix
else :
openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib")]
openssl_env.MergeFlags(openssl_flags)
@@ -660,19 +664,19 @@ if env["PLATFORM"] == "darwin" :
# Qt
try :
myenv = env.Clone()
myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
env["HAVE_QT"] = True
except SCons.Errors.StopError:
env["HAVE_QT"] = False
except Exception as e:
- print "Info: %s" % str(e)
+ print("Info: %s" % str(e))
env["HAVE_QT"] = False
################################################################################
# DocBook setup
################################################################################
if env.get("docbook_xml") :
env["DOCBOOK_XML_DIR"] = env["docbook_xml"]
if env.get("docbook_xsl") :
@@ -682,33 +686,35 @@ if env.get("docbook_xsl") :
################################################################################
# Set up git hooks
################################################################################
try:
if env.Dir("#/.git").exists() :
if not env.GetOption("clean") and env.get("install_git_hooks", True) :
env.Install("#/.git/hooks", Glob("#/BuildTools/Git/Hooks/*"))
except TypeError:
- print "You seem to be using Swift in a Git submodule. Not installing hooks."
+ print("You seem to be using Swift in a Git submodule. Not installing hooks.")
################################################################################
# Replace #pragma once with proper guards on platforms that require it
################################################################################
if ARGUMENTS.get("replace_pragma_once", False) :
env.Tool("ReplacePragmaOnce", toolpath = ["#/BuildTools/SCons/Tools"])
def relpath(path, start) :
i = len(os.path.commonprefix([path, start]))
return path[i+1:]
for actual_root, dirs, files in os.walk(root) :
+ dirs.sort()
+ files.sort()
if "3rdParty" in actual_root :
continue
for file in files :
if not file.endswith(".h") :
continue
include = relpath(os.path.join(actual_root, file), root)
env.ReplacePragmaOnce("#/include/" + include, "#/" + include)
env.Append(CPPPATH = ["#/include"])
else :
@@ -723,66 +729,66 @@ if ARGUMENTS.get("dump_trace", False) :
env.SetOption("no_exec", True)
env["TEST"] = True
env["BOOST_BUILD_BCP"] = True
env.Decider(lambda x, y, z : True)
SCons.Node.Python.Value.changed_since_last_build = (lambda x, y, z: True)
# Modules
modules = []
if os.path.isdir(Dir("#/3rdParty").abspath) :
- for dir in os.listdir(Dir("#/3rdParty").abspath) :
+ for dir in sorted(os.listdir(Dir("#/3rdParty").abspath)) :
full_dir = os.path.join(Dir("#/3rdParty").abspath, dir)
if not os.path.isdir(full_dir) :
continue
sconscript = os.path.join(full_dir, "SConscript")
if os.path.isfile(sconscript) :
modules.append("3rdParty/" + dir)
-for dir in os.listdir(Dir("#").abspath) :
+for dir in sorted(os.listdir(Dir("#").abspath)) :
full_dir = os.path.join(Dir("#").abspath, dir)
if not os.path.isdir(full_dir) :
continue
sconscript = os.path.join(full_dir, "SConscript")
if os.path.isfile(sconscript) :
modules.append(dir)
# QA comes last
modules.remove("QA")
modules.append("QA")
# Flags
env["PROJECTS"] = [m for m in modules if m not in ["Documentation", "QA", "SwifTools"] and not m.startswith("3rdParty")]
for stage in ["flags", "build"] :
env["SCONS_STAGE"] = stage
- SConscript(dirs = map(lambda x : root + "/" + x, modules))
+ SConscript(dirs = list(map(lambda x : root + "/" + x, modules)))
# SLOCCount
if ARGUMENTS.get("sloccount", False) :
for project in env["PROJECTS"] :
env.SLOCCount("#/" + project)
################################################################################
# Print summary
################################################################################
-print
-print " Build Configuration"
-print " -------------------"
+print("")
+print(" Build Configuration")
+print(" -------------------")
parsers = []
if env.get("HAVE_LIBXML", 0):
parsers.append("LibXML")
if env.get("HAVE_EXPAT", 0):
parsers.append("Expat")
if env.get("EXPAT_BUNDLED", False) :
parsers.append("(Bundled)")
-print " Projects: " + ' '.join(env["PROJECTS"])
-print ""
-print " XML Parsers: " + ' '.join(parsers)
+print(" Projects: " + ' '.join(env["PROJECTS"]))
+print("")
+print(" XML Parsers: " + ' '.join(parsers))
-print " TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" or env.get("HAVE_SECURETRANSPORT",0) and "Secure Transport" or env.get("HAVE_SCHANNEL", 0) and "Schannel" or "Disabled")
-print " DNSSD Support: " + (env.get("HAVE_BONJOUR") and "Bonjour" or (env.get("HAVE_AVAHI") and "Avahi" or "Disabled"))
-print
+print(" TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" or env.get("HAVE_SECURETRANSPORT",0) and "Secure Transport" or env.get("HAVE_SCHANNEL", 0) and "Schannel" or "Disabled"))
+print(" DNSSD Support: " + (env.get("HAVE_BONJOUR") and "Bonjour" or (env.get("HAVE_AVAHI") and "Avahi" or "Disabled")))
+print("")
if not GetOption("help") and not env.get("HAVE_OPENSSL", 0) and not env.get("HAVE_SCHANNEL", 0) and not env.get("HAVE_SECURETRANSPORT", 0):
- print "Error: A working TLS backend is required. Please check the documentation for more information."
+ print("Error: A working TLS backend is required. Please check the documentation for more information.")
Exit(1)