summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools/SCons')
-rw-r--r--BuildTools/SCons/SConscript.boot165
-rw-r--r--BuildTools/SCons/SConstruct208
-rw-r--r--BuildTools/SCons/Tools/Flags.py5
-rw-r--r--BuildTools/SCons/Tools/Test.py21
-rw-r--r--BuildTools/SCons/Tools/WindowsBundle.py8
-rw-r--r--BuildTools/SCons/Tools/qt4.py36
6 files changed, 309 insertions, 134 deletions
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 361004f..4e7e037 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -8,19 +8,20 @@ sys.path.append(Dir("#/BuildTools/SCons").abspath)
vars = Variables(os.path.join(Dir("#").abspath, "config.py"))
vars.Add('cc', "C compiler")
vars.Add('cxx', "C++ compiler")
-vars.Add('ccflags', "Extra C(++) compiler flags")
+vars.Add('ccflags', "Extra C/C++/ObjC compiler flags")
+vars.Add('cxxflags', "Extra C++ compiler flags")
vars.Add('link', "Linker")
vars.Add('linkflags', "Extra linker flags")
vars.Add(BoolVariable("ccache", "Use CCache", "no"))
-vars.Add(BoolVariable("distcc", "Use DistCC", "no"))
-vars.Add('distcc_hosts', "DistCC hosts (overrides DISTCC_HOSTS)")
vars.Add(EnumVariable("test", "Compile and run tests", "none", ["none", "all", "unit", "system"]))
vars.Add(BoolVariable("optimize", "Compile with optimizations turned on", "no"))
vars.Add(BoolVariable("debug", "Compile with debug information", "yes"))
vars.Add(BoolVariable("allow_warnings", "Allow compilation warnings during compilation", "yes"))
vars.Add(BoolVariable("assertions", "Compile with assertions", "yes"))
vars.Add(BoolVariable("max_jobs", "Build with maximum number of parallel jobs", "no"))
-vars.Add(EnumVariable("target", "Choose a target platform for compilation", "native", ["native", "iphone-simulator", "iphone-device", "xcode"]))
+vars.Add(EnumVariable("target", "Choose a target platform for compilation", "native", ["native", "iphone-simulator", "iphone-device", "xcode", "android"]))
+vars.Add('android_toolchain', "Path to Android toolchain")
+vars.Add('android_sdk_bin', "Path to Android SDK's tools directory")
vars.Add(BoolVariable("swift_mobile", "Build mobile Swift", "no"))
vars.Add(BoolVariable("swiften_dll", "Build Swiften as dynamically linked library", "no"))
if os.name != "nt" :
@@ -38,6 +39,8 @@ if os.name == "nt" :
if os.name == "nt" :
vars.Add(PackageVariable("bonjour", "Bonjour SDK location", "yes"))
vars.Add(PackageVariable("openssl", "OpenSSL location", "yes"))
+vars.Add(BoolVariable("openssl_force_bundled", "Force use of the bundled OpenSSL", "no"))
+vars.Add(PackageVariable("hunspell", "Hunspell location", False))
vars.Add(PathVariable("boost_includedir", "Boost headers location", None, PathVariable.PathAccept))
vars.Add(PathVariable("boost_libdir", "Boost library location", None, PathVariable.PathAccept))
vars.Add(PathVariable("expat_includedir", "Expat headers location", None, PathVariable.PathAccept))
@@ -47,27 +50,41 @@ vars.Add(PackageVariable("icu", "ICU library location", "no"))
vars.Add(PathVariable("libidn_includedir", "LibIDN headers location", None, PathVariable.PathAccept))
vars.Add(PathVariable("libidn_libdir", "LibIDN library location", None, PathVariable.PathAccept))
vars.Add("libidn_libname", "LibIDN library name", "libidn" if os.name == "nt" else "idn")
+vars.Add(PathVariable("libminiupnpc_includedir", "LibMiniUPNPC headers location", None, PathVariable.PathAccept))
+vars.Add(PathVariable("libminiupnpc_libdir", "LibMiniUPNPC library location", None, PathVariable.PathAccept))
+vars.Add("libminiupnpc_libname", "LibMiniUPNPC library name", "libminiupnpc" if os.name == "nt" else "miniupnpc")
+vars.Add(PathVariable("libnatpmp_includedir", "LibNATPMP headers location", None, PathVariable.PathAccept))
+vars.Add(PathVariable("libnatpmp_libdir", "LibNATPMP library location", None, PathVariable.PathAccept))
+vars.Add("libnatpmp_libname", "LibNATPMP library name", "libnatpmp" if os.name == "nt" else "natpmp")
vars.Add(PathVariable("sqlite_includedir", "SQLite headers location", None, PathVariable.PathAccept))
vars.Add(PathVariable("sqlite_libdir", "SQLite library location", None, PathVariable.PathAccept))
vars.Add("sqlite_libname", "SQLite library name", "libsqlite3" if os.name == "nt" else "sqlite3")
vars.Add("sqlite_force_bundled", "Force use of the bundled SQLite", None)
+vars.Add(PathVariable("lua_includedir", "Lua headers location", None, PathVariable.PathAccept))
+vars.Add(PathVariable("lua_libdir", "Lua library location", None, PathVariable.PathAccept))
+vars.Add("lua_libname", "Lua library name", "liblua" if os.name == "nt" else "lua")
+vars.Add("lua_force_bundled", "Force use of the bundled Lua", None)
vars.Add(PathVariable("avahi_includedir", "Avahi headers location", None, PathVariable.PathAccept))
vars.Add(PathVariable("avahi_libdir", "Avahi library location", None, PathVariable.PathAccept))
vars.Add(PathVariable("qt", "Qt location", "", PathVariable.PathAccept))
+vars.Add(BoolVariable("qt5", "Compile in Qt5 mode", "no")) # TODO: auto-detect this
vars.Add(PathVariable("docbook_xml", "DocBook XML", None, PathVariable.PathAccept))
vars.Add(PathVariable("docbook_xsl", "DocBook XSL", None, PathVariable.PathAccept))
vars.Add(BoolVariable("build_examples", "Build example programs", "yes"))
vars.Add(BoolVariable("enable_variants", "Build in a separate dir under build/, depending on compile flags", "no"))
-vars.Add(BoolVariable("experimental", "Build experimental features", "no"))
+vars.Add(BoolVariable("experimental", "Build experimental features", "yes"))
vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0", "yes"))
+vars.Add(BoolVariable("unbound", "Build bundled ldns and unbound. Use them for DNS lookup.", "no"))
################################################################################
# Set up default build & configure environment
################################################################################
+
env_ENV = {
'PATH' : os.environ['PATH'],
'LD_LIBRARY_PATH' : os.environ.get("LD_LIBRARY_PATH", ""),
+ 'TERM' : os.environ.get("TERM", ""),
}
if "MSVC_VERSION" in ARGUMENTS :
env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"])
@@ -76,8 +93,18 @@ else :
Help(vars.GenerateHelpText(env))
+# Workaround for missing Visual Studio 2012 support in SCons
+# Requires scons to be run from a VS2012 console
+if env.get("MSVC_VERSION", "").startswith("11.0") :
+ env["ENV"]["LIB"] = os.environ["LIB"]
+ env["ENV"]["INCLUDE"] = os.environ["INCLUDE"]
+
# Default environment variables
-env["PLATFORM_FLAGS"] = {}
+env["PLATFORM_FLAGS"] = {
+ "LIBPATH": [],
+ "LIBS": [],
+ "FRAMEWORKS": [],
+}
# Default custom tools
env.Tool("Test", toolpath = ["#/BuildTools/SCons/Tools"])
@@ -104,33 +131,50 @@ if env["max_jobs"] :
except ImportError :
pass
-# Default compiler flags
-if env.get("distcc", False) :
- env["ENV"]["HOME"] = os.environ["HOME"]
- env["ENV"]["DISTCC_HOSTS"] = os.environ.get("DISTCC_HOSTS", "")
- if "distcc_hosts" in env :
- env["ENV"]["DISTCC_HOSTS"] = env["distcc_hosts"]
- env["CC"] = "distcc gcc"
- env["CXX"] = "distcc g++"
+# Set speed options
+env.Decider("MD5-timestamp")
+env.SetOption("max_drift", 1)
+env.SetOption("implicit_cache", True)
+
+# Set the default compiler to CLang on OS X, and set the necessary flags
+if env["PLATFORM"] == "darwin" and env["target"] == "native" :
+ if "cc" not in env :
+ env["CC"] = "clang"
+ if platform.machine() == "x86_64" :
+ env["CCFLAGS"] = ["-arch", "x86_64"]
+ if "cxx" not in env :
+ env["CXX"] = "clang++"
+ # Compiling Qt5 in C++0x mode includes headers that we don't have
+ if not env["qt5"] :
+ env["CXXFLAGS"] = ["-std=c++11"]
+ if "link" not in env :
+ env["LINK"] = "clang"
+ if platform.machine() == "x86_64" :
+ env.Append(LINKFLAGS = ["-arch", "x86_64"])
+
+# Check whether we are running inside scan-build, and override compiler if so
+if "CCC_ANALYZER_HTML" in os.environ :
+ for key, value in os.environ.items() :
+ if key.startswith("CCC_") or key.startswith("CLANG") :
+ env["ENV"][key] = value
+ env["CC"] = os.environ["CC"]
+ env["CXX"] = os.environ["CXX"]
+
+# Override the compiler with custom variables set at config time
if "cc" in env :
env["CC"] = env["cc"]
if "cxx" in env :
env["CXX"] = env["cxx"]
-ccflags = env.get("ccflags", [])
-if isinstance(ccflags, str) :
- # FIXME: Make the splitting more robust
- env["CCFLAGS"] = ccflags.split(" ")
-else :
- env["CCFLAGS"] = ccflags
if "link" in env :
env["SHLINK"] = env["link"]
env["LINK"] = env["link"]
-linkflags = env.get("linkflags", [])
-if isinstance(linkflags, str) :
- # FIXME: Make the splitting more robust
- env["LINKFLAGS"] = linkflags.split(" ")
-else :
- env["LINKFLAGS"] = linkflags
+for flags_type in ["ccflags", "cxxflags", "linkflags"] :
+ if flags_type in env :
+ if isinstance(env[flags_type], str) :
+ # FIXME: Make the splitting more robust
+ env[flags_type.upper()] = env[flags_type].split(" ")
+ else :
+ env[flags_type.upper()] = env[flags_type]
# This isn't a real flag (yet) AFAIK. Be sure to append it to the CXXFLAGS
# where you need it
env["OBJCCFLAGS"] = []
@@ -146,7 +190,7 @@ if env["target"] == "xcode" and os.environ["CONFIGURATION"] == "Release" :
if env["debug"] :
if env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/Z7"])
+ env.Append(CCFLAGS = ["/Zi"])
env.Append(LINKFLAGS = ["/DEBUG"])
if env["set_iterator_debug_level"] :
env.Append(CPPDEFINES = ["_ITERATOR_DEBUG_LEVEL=0"])
@@ -184,7 +228,6 @@ if env.get("mac105", 0) :
"-mmacosx-version-min=10.5",
"-isysroot", "/Developer/SDKs/MacOSX10.5.sdk",
"-arch", "i386"])
- env.Append(FRAMEWORKS = ["Security"])
if env.get("mac106", 0) :
assert(env["PLATFORM"] == "darwin")
env.Append(CCFLAGS = [
@@ -194,7 +237,6 @@ if env.get("mac106", 0) :
"-mmacosx-version-min=10.6",
"-isysroot", "/Developer/SDKs/MacOSX10.6.sdk",
"-arch", "i386"])
- env.Append(FRAMEWORKS = ["Security"])
if not env["assertions"] :
env.Append(CPPDEFINES = ["NDEBUG"])
@@ -209,24 +251,33 @@ if env["PLATFORM"] == "posix" and platform.machine() == "x86_64" :
# Warnings
if env["PLATFORM"] == "win32" :
- # TODO: Find the ideal set of warnings
- #env.Append(CCFLAGS = ["/Wall"])
- pass
+ env.Append(CXXFLAGS = ["/wd4068"])
else :
- env.Append(CXXFLAGS = ["-Wextra", "-Wall", "-Wnon-virtual-dtor", "-Wundef", "-Wold-style-cast", "-Wno-long-long", "-Woverloaded-virtual", "-Wfloat-equal", "-Wredundant-decls"])
+ if "clang" in env["CXX"] :
+ env.Append(CXXFLAGS = [
+ "-Weverything",
+ "-Wno-unknown-warning-option", # To stay compatible between CLang versions
+ "-Wno-unknown-pragmas", # To stay compatible between CLang versions
+ "-Wno-weak-vtables", # Virtually none of our elements have outlined methods. This also seems to affect classes in .cpp files, which in turn affects all our tests, which may need fixing in CLang
+ "-Wno-shadow", # Also warns for shadowing on constructor arguments, which we do a lot
+ "-Wno-documentation", # We don't care about documentation warnings
+ "-Wno-exit-time-destructors", # Used a lot in e.g. CPPUnit
+ "-Wno-c++98-compat-pedantic", # We do different things that violate this, but they could be fixed
+ "-Wno-global-constructors", # We depend on this for e.g. string constants
+ "-Wno-disabled-macro-expansion", # Caused due to system headers
+ "-Wno-c++11-extensions", # We use C++11; turn this off when we use -std=c++11
+ "-Wno-long-long", # We use long long
+ "-Wno-padded",
+ "-Wno-missing-variable-declarations", # Getting rid of CPPUnit warnings
+ "-Wno-direct-ivar-access", # Obj-C code warning
+ ])
+ else :
+ env.Append(CXXFLAGS = ["-Wextra", "-Wall", "-Wnon-virtual-dtor", "-Wundef", "-Wold-style-cast", "-Wno-long-long", "-Woverloaded-virtual", "-Wfloat-equal", "-Wredundant-decls", "-Wno-unknown-pragmas"])
+ gccVersion = env.get("CCVERSION", "0.0.0").split(".")
+ if gccVersion >= ["4", "5", "0"] and not "clang" in env["CC"] :
+ env.Append(CXXFLAGS = ["-Wlogical-op"])
if not env.get("allow_warnings", False) :
env.Append(CXXFLAGS = ["-Werror"])
- gccVersion = env.get("CCVERSION", "0.0.0").split(".")
- if gccVersion >= ["4", "5", "0"] and not "clang" in env["CC"] :
- env.Append(CXXFLAGS = ["-Wlogical-op"])
- if "clang" in env["CC"] :
- env.Append(CXXFLAGS = ["-W#warnings", "-Wc++0x-compat", "-Waddress-of-temporary", "-Wambiguous-member-template", "-Warray-bounds", "-Watomic-properties", "-Wbind-to-temporary-copy", "-Wbuiltin-macro-redefined", "-Wc++-compat", "-Wc++0x-extensions", "-Wcomments", "-Wconditional-uninitialized", "-Wconstant-logical-operand", "-Wdeclaration-after-statement", "-Wdeprecated", "-Wdeprecated-implementations", "-Wdeprecated-writable-strings", "-Wduplicate-method-arg", "-Wempty-body", "-Wendif-labels", "-Wenum-compare", "-Wformat=2", "-Wfour-char-constants", "-Wgnu", "-Wincomplete-implementation", "-Winvalid-noreturn", "-Winvalid-offsetof", "-Winvalid-token-paste", "-Wlocal-type-template-args", "-Wmethod-signatures", "-Wmicrosoft", "-Wmissing-declarations", "-Wnon-pod-varargs", "-Wnull-dereference", "-Wout-of-line-declaration", "-Woverlength-strings", "-Wpacked", "-Wpointer-arith", "-Wpointer-sign", "-Wprotocol", "-Wreadonly-setter-attrs", "-Wselector", "-Wshift-overflow", "-Wshift-sign-overflow", "-Wstrict-selector-match", "-Wsuper-class-method-mismatch", "-Wtautological-compare", "-Wtypedef-redefinition", "-Wundeclared-selector", "-Wunknown-warning-option", "-Wunnamed-type-template-args", "-Wunused-exception-parameter", "-Wunused-member-function", "-Wused-but-marked-unused", "-Wvariadic-macros", "-Wno-c++11-extensions"])
-# To enable:
-# "-Wnonfragile-abi2" -> deprecated, is now -Warc-abi i think
-# "-Wheader-hygiene"
-# "-Wnon-gcc",
-# "-Wweak-vtables",
-# "-Wlarge-by-value-copy",
if env.get("coverage", 0) :
assert(env["PLATFORM"] != "win32")
@@ -235,14 +286,14 @@ if env.get("coverage", 0) :
if env["PLATFORM"] == "win32" :
env.Append(LIBS = ["user32", "crypt32", "dnsapi", "iphlpapi", "ws2_32", "wsock32", "Advapi32"])
- env.Append(CCFLAGS = ["/EHsc", "/nologo"])
+ env.Append(CCFLAGS = ["/EHsc", "/nologo", "/Zm256"])
env.Append(LINKFLAGS = ["/INCREMENTAL:no", "/NOLOGO"])
if int(env["MSVS_VERSION"].split(".")[0]) < 10 :
env["LINKCOM"] = [env["LINKCOM"], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1']
env["SHLINKCOM"] = [env["SHLINKCOM"], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2']
-if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphone-simulator", "xcode"] :
- env.Append(FRAMEWORKS = ["IOKit", "AppKit", "SystemConfiguration", "Security", "SecurityInterface"])
+if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphone-simulator", "xcode", "android"] :
+ env["PLATFORM_FLAGS"]["FRAMEWORKS"] += ["IOKit", "AppKit", "SystemConfiguration", "Security", "SecurityInterface"]
# Testing
env["TEST_TYPE"] = env["test"]
@@ -257,13 +308,14 @@ env["TEST_CREATE_LIBRARIES"] = "create_test_libraries" in ARGUMENTS
# Packaging
env["DIST"] = "dist" in ARGUMENTS or env.GetOption("clean")
-for path in ["SWIFT_INSTALLDIR", "SWIFTEN_INSTALLDIR"] :
+for path in ["SWIFT_INSTALLDIR", "SWIFTEN_INSTALLDIR", "SLUIFT_INSTALLDIR"] :
if ARGUMENTS.get(path, "") :
if os.path.isabs(ARGUMENTS[path]) :
env[path] = Dir(ARGUMENTS[path]).abspath
else :
env[path] = Dir("#/" + ARGUMENTS[path]).abspath
+
################################################################################
# XCode / iPhone / ...
################################################################################
@@ -281,15 +333,15 @@ if target in ["iphone-device", "iphone-simulator", "xcode"] :
env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM ${SOURCES.abspath}'
else :
# Hard code values
- env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"
+ env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"
if target == "iphone-device":
env["XCODE_ARCH_FLAGS"] = ["-arch", "armv6", "-arch", "armv7"]
sdkPart = "iPhoneOS"
else :
env["XCODE_ARCH_FLAGS"] = ["-arch", "i386"]
sdkPart = "iPhoneSimulator"
- sdkVer = "4.3"
- env["XCODE_SDKROOT"] = "/Developer/Platforms/" + sdkPart + ".platform/Developer/SDKs/" + sdkPart + sdkVer + ".sdk"
+ sdkVer = "6.0"
+ env["XCODE_SDKROOT"] = "/Applications/Xcode.app/Contents/Developer/Platforms/" + sdkPart + ".platform/Developer/SDKs/" + sdkPart + sdkVer + ".sdk"
env["IPHONEOS_DEPLOYMENT_TARGET"] = "4.1"
# Set the build flags
@@ -307,6 +359,17 @@ if target in ["iphone-device", "iphone-simulator", "xcode"] :
# Bit of a hack, because BOOST doesn't know the endianness for ARM
env.Append(CPPDEFINES = ["_LITTLE_ENDIAN"])
+################################################################################
+# Android
+################################################################################
+if target in ["android"] :
+ env["ENV"]["PATH"] = env["android_toolchain"] + "/bin:" + env["ENV"]["PATH"]
+ env["CC"] = "arm-linux-androideabi-gcc"
+ env["CXX"] = "arm-linux-androideabi-g++"
+ env["RANLIB"] = "arm-linux-androideabi-ranlib"
+ env.Append(CPPDEFINES = ["ANDROID"])
+ env.Append(CPPDEFINES = ["_REENTRANT", "_GLIBCXX__PTHREADS"])
+
# CCache
if env.get("ccache", False) :
env["ENV"]["HOME"] = os.environ["HOME"]
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index a0a6e8d..ce78d03 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -33,7 +33,7 @@ def colorize(command, target, color) :
suffix = "\033[0m"
return " " + prefix + command + suffix + " " + target
-if int(ARGUMENTS.get("V", 0)) == 0:
+if int(ARGUMENTS.get("V", 0)) == 0 and not ARGUMENTS.get("dump_trace", False) :
env["CCCOMSTR"] = colorize("CC", "$TARGET", "green")
env["SHCCCOMSTR"] = colorize("CC", "$TARGET", "green")
env["CXXCOMSTR"] = colorize("CXX", "$TARGET", "green")
@@ -42,6 +42,7 @@ if int(ARGUMENTS.get("V", 0)) == 0:
env["SHLINKCOMSTR"] = colorize("LINK", "$TARGET", "red")
env["ARCOMSTR"] = colorize("AR", "$TARGET", "red")
env["RANLIBCOMSTR"] = colorize("RANLIB", "$TARGET", "red")
+ env["PCHCOMSTR"] = colorize("PCH", "$TARGET", "blue")
env["QT4_RCCCOMSTR"] = colorize("RCC", "$TARGET", "blue")
env["QT4_UICCOMSTR"] = colorize("UIC", "$TARGET", "blue")
env["QT4_MOCFROMHCOMSTR"] = colorize("MOC", "$TARGET", "blue")
@@ -82,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>
@@ -90,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)
@@ -142,7 +151,7 @@ if env.get("boost_includedir", None) :
boost_flags["CPPFLAGS"] = [("-isystem", env["boost_includedir"])]
boost_conf_env.MergeFlags(boost_flags)
conf = Configure(boost_conf_env)
-boostLibs = [("signals", None), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("system", "system/system_error.hpp"), ("date_time", "date_time/date.hpp")]
+boostLibs = [("signals", None), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("serialization", "archive/text_oarchive.hpp"), ("system", "system/system_error.hpp"), ("date_time", "date_time/date.hpp")]
allLibsPresent = True
libNames = []
for (lib, header) in boostLibs :
@@ -168,6 +177,7 @@ if allLibsPresent :
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
+ env["BOOST_FLAGS"]["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"]
else :
env["BOOST_BUNDLED"] = True
conf.Finish()
@@ -332,27 +342,53 @@ if not env.get("HAVE_ICU", False) and not env.get("HAVE_LIBIDN", False) :
env["HAVE_LIBIDN"] = 1
env["LIBIDN_BUNDLED"] = 1
+# Unbound
+if env["unbound"] :
+ env["LDNS_BUNDLED"] = 1
+ env["UNBOUND_BUNDLED"] = 1
+else :
+ env["LDNS_FLAGS"] = {}
+ env["UNBOUND_FLAGS"] = {}
+
# LibMiniUPnPc
if env["experimental"] :
- #libminiupnpc_conf_env = conf_env.Clone()
- #conf = Configure(libminiupnpc_conf_env)
- #if conf.CheckCHeader("miniupnpc.h") and conf.CheckLib(env["libminiupnpc_libname"]) :
- # print "NOT IMPLEMENTED YET"
- #else :
- env["LIBMINIUPNPC_BUNDLED"] = 1
- #conf.Finish()
+ libminiupnpc_flags = {"CPPPATH": ["/usr/include/miniupnpc/"]}
+ libminiupnpc_conf_env = conf_env.Clone()
+ if env.get("libminiupnpc_libdir", None) :
+ libminiupnpc_flags["LIBPATH"] = [env["libminiupnpc_libdir"]]
+ if env.get("libminiupnpc_includedir", None) :
+ libminiupnpc_flags["CPPPATH"] = [env["libminiupnpc_includedir"]]
+ libminiupnpc_conf_env.MergeFlags(libminiupnpc_flags)
+ conf = Configure(libminiupnpc_conf_env)
+ if conf.CheckCHeader("miniupnpc.h") and conf.CheckLib(env["libminiupnpc_libname"]) and False :
+ # ^ False because APIs aren't stable
+ env["HAVE_LIBMINIUPNPC"] = 1
+ env["LIBMINIUPNPC_FLAGS"] = { "LIBS": ["miniupnpc"] }
+ env["LIBMINIUPNPC_FLAGS"].update(libminiupnpc_flags)
+ else :
+ env["LIBMINIUPNPC_BUNDLED"] = 1
+ conf.Finish()
else :
env["LIBMINIUPNPC_FLAGS"] = {}
# LibNATPMP
if env["experimental"] :
- #libnatpmp_conf_env = conf_env.Clone()
- #conf = Configure(libnatpmp_conf_env)
- #if conf.CheckCHeader("natpmp.h") and conf.CheckLib(env["libnatpmp_libname"]) :
- # print "NOT IMPLEMENTED YET"
- #else :
- env["LIBNATPMP_BUNDLED"] = 1
- #conf.Finish()
+ libnatpmp_flags = {}
+ libnatpmp_conf_env = conf_env.Clone()
+ if env.get("libnatpmp_libdir", None) :
+ libnatpmp_flags["LIBPATH"] = [env["libnatpmp_libdir"]]
+ if env.get("libnatpmp_includedir", None) :
+ libnatpmp_flags["CPPPATH"] = [env["libnatpmp_includedir"]]
+ libnatpmp_conf_env.MergeFlags(libnatpmp_flags)
+ conf = Configure(libnatpmp_conf_env)
+ if conf.CheckCHeader("natpmp.h") and conf.CheckLib(env["libnatpmp_libname"]) and False:
+ # ^ False because APIs aren't stable
+ env["HAVE_LIBNATPMP"] = 1
+ env["LIBNATPMP_FLAGS"] = { "LIBS": ["natpmp"] }
+ env["LIBNATPMP_FLAGS"].update(libnatpmp_flags)
+ else :
+ env["LIBNATPMP_BUNDLED"] = 1
+ conf.Finish()
else :
env["LIBNATPMP_FLAGS"] = {}
@@ -372,14 +408,32 @@ if env["experimental"] :
env["SQLITE_FLAGS"].update(sqlite_flags)
else :
env["SQLITE_BUNDLED"] = 1
- env["SQLITE_ASYNC_BUNDLED"] = 1
conf.Finish()
else :
env["SQLITE_FLAGS"] = {}
# 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)
@@ -409,43 +463,60 @@ if env["qt"] :
# OpenSSL
openssl_env = conf_env.Clone()
-use_openssl = bool(env["openssl"])
-openssl_prefix = env["openssl"] if isinstance(env["openssl"], str) else ""
-openssl_flags = {}
-if openssl_prefix :
- openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] }
- if 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)
-
-openssl_conf = Configure(openssl_env)
-if use_openssl and openssl_conf.CheckCHeader("openssl/ssl.h") :
- env["HAVE_OPENSSL"] = 1
- env["OPENSSL_FLAGS"] = openssl_flags
- if env["PLATFORM"] == "win32" :
- env["OPENSSL_FLAGS"]["LIBS"] = ["libeay32MD", "ssleay32MD"]
- else:
- env["OPENSSL_FLAGS"]["LIBS"] = ["ssl", "crypto"]
- if env["PLATFORM"] == "darwin" :
- if platform.mac_ver()[0].startswith("10.5") :
- env["OPENSSL_FLAGS"]["FRAMEWORKS"] = ["Security"]
-elif env["target"] in ("iphone-device", "iphone-simulator", "xcode") :
+if env.get("openssl_force_bundled", False) or env["target"] in ("iphone-device", "iphone-simulator", "xcode", "android") :
env["OPENSSL_BUNDLED"] = True
env["HAVE_OPENSSL"] = True
else :
- env["OPENSSL_FLAGS"] = {}
- if env["PLATFORM"] == "win32" :
- env["HAVE_SCHANNEL"] = True
- # If we're compiling for Windows and OpenSSL isn't being used, use Schannel
- env.Append(LIBS = ["secur32"])
-
-openssl_conf.Finish()
+ use_openssl = bool(env["openssl"])
+ openssl_prefix = env["openssl"] if isinstance(env["openssl"], str) else ""
+ openssl_flags = {}
+ if openssl_prefix :
+ openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] }
+ if 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)
+
+ openssl_conf = Configure(openssl_env)
+ if use_openssl and openssl_conf.CheckCHeader("openssl/ssl.h") :
+ env["HAVE_OPENSSL"] = 1
+ env["OPENSSL_FLAGS"] = openssl_flags
+ if env["PLATFORM"] == "win32" :
+ env["OPENSSL_FLAGS"]["LIBS"] = ["libeay32MD", "ssleay32MD"]
+ else:
+ env["OPENSSL_FLAGS"]["LIBS"] = ["ssl", "crypto"]
+ if env["PLATFORM"] == "darwin" :
+ if platform.mac_ver()[0].startswith("10.5") :
+ env["OPENSSL_FLAGS"]["FRAMEWORKS"] = ["Security"]
+ else :
+ env["OPENSSL_FLAGS"] = {}
+ if env["PLATFORM"] == "win32" :
+ env["HAVE_SCHANNEL"] = True
+ # If we're compiling for Windows and OpenSSL isn't being used, use Schannel
+ env.Append(LIBS = ["secur32"])
+
+ openssl_conf.Finish()
+
+#Hunspell
+hunspell_env = conf_env.Clone()
+hunspell_prefix = env["hunspell"] if isinstance(env.get("hunspell", False), str) else ""
+hunspell_flags = {}
+if hunspell_prefix :
+ hunspell_flags = {"CPPPATH":[os.path.join(hunspell_prefix, "include")], "LIBPATH":[os.path.join(hunspell_prefix, "lib")]}
+hunspell_env.MergeFlags(hunspell_flags)
+
+env["HAVE_HUNSPELL"] = 0;
+hunspell_conf = Configure(hunspell_env)
+if hunspell_conf.CheckCXXHeader("hunspell/hunspell.hxx") and hunspell_conf.CheckLib("hunspell") :
+ env["HAVE_HUNSPELL"] = 1
+ hunspell_flags["LIBS"] = ["hunspell"]
+ env["HUNSPELL_FLAGS"] = hunspell_flags
+hunspell_conf.Finish()
# Bonjour
-if env["PLATFORM"] == "darwin" :
+if env["PLATFORM"] == "darwin" and env["target"] == "native" :
env["HAVE_BONJOUR"] = 1
elif env.get("bonjour", False) :
bonjour_env = conf_env.Clone()
@@ -524,18 +595,23 @@ else :
# Project files
################################################################################
-# Build tools
-env.SConscript(dirs = ["#/BuildTools/CLang"])
+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 = []
-for dir in 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)
+if os.path.isdir(Dir("#/3rdParty").abspath) :
+ for dir in 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) :
full_dir = os.path.join(Dir("#").abspath, dir)
if not os.path.isdir(full_dir) :
@@ -544,9 +620,13 @@ for dir in os.listdir(Dir("#").abspath) :
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", "test"] :
+for stage in ["flags", "build"] :
env["SCONS_STAGE"] = stage
SConscript(dirs = map(lambda x : root + "/" + x, modules))
diff --git a/BuildTools/SCons/Tools/Flags.py b/BuildTools/SCons/Tools/Flags.py
index 13fbb32..c130faf 100644
--- a/BuildTools/SCons/Tools/Flags.py
+++ b/BuildTools/SCons/Tools/Flags.py
@@ -3,7 +3,10 @@ import SCons.Util
def generate(env) :
def useFlags(env, flags) :
for flag in flags :
- env[flag] = env.get(flag, []) + flags[flag]
+ if flag in env :
+ env[flag] = env[flag] + flags[flag]
+ else :
+ env[flag] = flags[flag]
env.AddMethod(useFlags, "UseFlags")
def exists(env) :
diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py
index c52f448..95fcce9 100644
--- a/BuildTools/SCons/Tools/Test.py
+++ b/BuildTools/SCons/Tools/Test.py
@@ -19,13 +19,24 @@ def generate(env) :
for i in ["HOME", "USERPROFILE", "APPDATA"]:
if os.environ.get(i, "") :
test_env["ENV"][i] = os.environ[i]
- if test_env["PLATFORM"] == "darwin" :
- test_env["ENV"]["DYLD_FALLBACK_LIBRARY_PATH"] = ":".join(map(lambda x : str(x), test_env.get("LIBPATH", [])))
- elif test_env["PLATFORM"] == "win32" :
- test_env["ENV"]["PATH"] = ";".join(map(lambda x : str(x), test_env.get("LIBRUNPATH", []))) + ";" + test_env["ENV"]["PATH"]
+ if env["target"] == "android" :
+ test_env["ENV"]["PATH"] = env["android_sdk_bin"] + ";" + test_env["ENV"]["PATH"]
+ else :
+ if test_env["PLATFORM"] == "darwin" :
+ test_env["ENV"]["DYLD_FALLBACK_LIBRARY_PATH"] = ":".join(map(lambda x : str(x), test_env.get("LIBPATH", [])))
+ elif test_env["PLATFORM"] == "win32" :
+ test_env["ENV"]["PATH"] = ";".join(map(lambda x : str(x), test_env.get("LIBRUNPATH", []))) + ";" + test_env["ENV"]["PATH"]
+
# Run the test
- test_env.Command("**dummy**", target,
+ if env["target"] == "android":
+ exec_name = os.path.basename(cmd)
+ test_env.Command("**dummy**", target, SCons.Action.Action(
+ ["adb shell mount -o rw,remount /system",
+ "adb push " + cmd + " /system/bin/" + exec_name,
+ "adb shell SWIFT_CLIENTTEST_JID=\"" + os.getenv("SWIFT_CLIENTTEST_JID") + "\" SWIFT_CLIENTTEST_PASS=\"" + os.getenv("SWIFT_CLIENTTEST_PASS") + "\" " + env.get("TEST_RUNNER", "") + "/system/bin/" + exec_name], cmdstr = "$TESTCOMSTR"))
+ else :
+ test_env.Command("**dummy**", target,
SCons.Action.Action(ignore_prefix + env.get("TEST_RUNNER", "") + cmd + " " + params, cmdstr = "$TESTCOMSTR"))
def registerScriptTests(env, scripts, name, type) :
diff --git a/BuildTools/SCons/Tools/WindowsBundle.py b/BuildTools/SCons/Tools/WindowsBundle.py
index c3c77aa..2915141 100644
--- a/BuildTools/SCons/Tools/WindowsBundle.py
+++ b/BuildTools/SCons/Tools/WindowsBundle.py
@@ -1,12 +1,16 @@
import SCons.Util, os
def generate(env) :
- def createWindowsBundle(env, bundle, resources = {}, qtimageformats = [], qtlibs = []) :
+ def createWindowsBundle(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4') :
all_files = []
all_files += env.Install(bundle, bundle + ".exe")
for lib in qtlibs :
all_files += env.Install(bundle, os.path.join(env["QTDIR"], "bin", lib + ".dll"))
- all_files += env.Install(os.path.join(bundle, "imageformats"), [os.path.join(env["QTDIR"], "plugins", "imageformats", "q" + codec + "4.dll") for codec in qtimageformats])
+ plugins_suffix = '4'
+ if qtversion == '5' :
+ plugins_suffix = ''
+ for plugin_type in qtplugins:
+ all_files += env.Install(os.path.join(bundle, plugin_type), [os.path.join(env["QTDIR"], "plugins", plugin_type, "q" + plugin + plugins_suffix + ".dll") for plugin in qtplugins[plugin_type]])
for dir, resourceFiles in resources.items() :
for resource in resourceFiles :
diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py
index 671fd08..02701e7 100644
--- a/BuildTools/SCons/Tools/qt4.py
+++ b/BuildTools/SCons/Tools/qt4.py
@@ -286,9 +286,9 @@ def generate(env):
# Commands for the qt support ...
QT4_UICCOM = '$QT4_UIC $QT4_UICFLAGS -o $TARGET $SOURCE',
- # FIXME: The -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED flag is a hack to work
- # around an issue in Qt
- # See https://bugreports.qt-project.org/browse/QTBUG-22829
+ # FIXME: The -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED flag is a hack to work
+ # around an issue in Qt
+ # See https://bugreports.qt-project.org/browse/QTBUG-22829
QT4_MOCFROMHCOM = '$QT4_MOC -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED $QT4_MOCFROMHFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE',
QT4_MOCFROMCXXCOM = [
'$QT4_MOC -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED $QT4_MOCFROMCXXFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE',
@@ -395,7 +395,7 @@ def generate(env):
# TODO: Does dbusxml2cpp need an adapter
env.AddMethod(enable_modules, "EnableQt4Modules")
-def enable_modules(self, modules, debug=False, crosscompiling=False) :
+def enable_modules(self, modules, debug=False, crosscompiling=False, version='4') :
import sys
validModules = [
@@ -420,6 +420,11 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
'QtWebKit',
'QtHelp',
'QtScript',
+
+ # Qt5 modules
+ 'QtWidgets',
+ 'QtMultimedia',
+ 'QtWebKitWidgets',
]
staticModules = [
'QtUiTools',
@@ -440,6 +445,8 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
'QtXml' : ['QT_XML_LIB'],
'QtOpenGL' : ['QT_OPENGL_LIB'],
'QtGui' : ['QT_GUI_LIB'],
+ 'QtWidgets' : ['QT_WIDGETS_LIB'],
+ 'QtWebKitWidgets' : [],
'QtNetwork' : ['QT_NETWORK_LIB'],
'QtCore' : ['QT_CORE_LIB'],
}
@@ -450,7 +457,8 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
if sys.platform.startswith("linux") and not crosscompiling :
if debug : debugSuffix = '_debug'
- self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include", "phonon")])
+ if version == '4' :
+ self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include", "phonon")])
for module in modules :
self.AppendUnique(LIBS=[module+debugSuffix])
self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
@@ -471,12 +479,17 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include","QtAssistant")])
modules.remove("QtAssistant")
modules.append("QtAssistantClient")
- # FIXME: Phonon Hack
- self.AppendUnique(LIBS=['phonon'+debugSuffix+'4'])
- self.AppendUnique(LIBS=[lib+debugSuffix+'4' for lib in modules if lib not in staticModules])
+ if version == '4' :
+ # FIXME: Phonon Hack
+ self.AppendUnique(LIBS=['phonon'+debugSuffix+version])
+ self.AppendUnique(LIBS=[lib+debugSuffix+version for lib in modules if lib not in staticModules])
+ else :
+ self.AppendUnique(LIBS=[lib.replace('Qt', 'Qt5') + debugSuffix for lib in modules if lib not in staticModules])
self.PrependUnique(LIBS=[lib+debugSuffix for lib in modules if lib in staticModules])
if 'QtOpenGL' in modules:
self.AppendUnique(LIBS=['opengl32'])
+ elif version == '5' :
+ self.Append(CPPDEFINES = ["QT_NO_OPENGL"])
self.AppendUnique(CPPPATH=[ '$QTDIR/include/'])
self.AppendUnique(CPPPATH=[ '$QTDIR/include/'+module for module in modules])
if crosscompiling :
@@ -498,7 +511,8 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
self.AppendUnique(LINKFLAGS="-L$QTDIR/lib") #TODO clean!
# FIXME: Phonon Hack
- self.Append(LINKFLAGS=['-framework', "phonon"])
+ if version == '4' :
+ self.Append(LINKFLAGS=['-framework', "phonon"])
for module in modules :
if module in staticModules :
@@ -506,9 +520,9 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) :
self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
else :
if len(self["QTDIR"]) > 0 :
- self.Append(CPPFLAGS = ["-I" + os.path.join("$QTDIR", "lib", module + ".framework", "Versions", "4", "Headers")])
+ self.Append(CPPFLAGS = ["-I" + os.path.join("$QTDIR", "lib", module + ".framework", "Versions", version, "Headers")])
else :
- self.Append(CPPFLAGS = ["-I" + os.path.join("/Library/Frameworks", module + ".framework", "Versions", "4", "Headers")])
+ self.Append(CPPFLAGS = ["-I" + os.path.join("/Library/Frameworks", module + ".framework", "Versions", version, "Headers")])
self.Append(LINKFLAGS=['-framework', module])
if 'QtOpenGL' in modules:
self.AppendUnique(LINKFLAGS="-F/System/Library/Frameworks")