diff options
author | Kevin Smith <git@kismith.co.uk> | 2014-07-15 14:45:28 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-10-01 12:15:02 (GMT) |
commit | a2296b00c88df201b0eb58e867aeb17a87e6332c (patch) | |
tree | 9fdebba1b5e9202ca669786a41dd94f080ba5807 /BuildTools/SCons | |
parent | a24d8c0e93d70312fc90d5fdf6214ade9a475e92 (diff) | |
download | swift-contrib-a2296b00c88df201b0eb58e867aeb17a87e6332c.zip swift-contrib-a2296b00c88df201b0eb58e867aeb17a87e6332c.tar.bz2 |
Port many of Isode's local fixes upstream
Includes fixes to:
Build with new Visual Studio and Boost
Avoid error caused when Avahi is present but Qt is not
Make declaration of XMPPRosterImpl::addContact consistent with implementation
Includes enhancements to:
Allow user-configurable mt.exe
Allow splitting openssl paths
Allow disabling gconf lookup
Make idn support optional
Allow disabling various library detections
Remove use of non-Python2.4 features in sconscripts
Test-Information:
Builds
Change-Id: Iee91ee80291a8bdf87cc169c915e4dad1cc1055b
Diffstat (limited to 'BuildTools/SCons')
-rw-r--r-- | BuildTools/SCons/SConscript.boot | 83 | ||||
-rw-r--r-- | BuildTools/SCons/SConstruct | 100 | ||||
-rw-r--r-- | BuildTools/SCons/Tools/Test.py | 11 | ||||
-rw-r--r-- | BuildTools/SCons/Version.py | 11 |
4 files changed, 145 insertions, 60 deletions
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot index 767c326..51be9ab 100644 --- a/BuildTools/SCons/SConscript.boot +++ b/BuildTools/SCons/SConscript.boot @@ -6,18 +6,21 @@ 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/C++/ObjC compiler flags") vars.Add('cxxflags', "Extra C++ compiler flags") vars.Add('link', "Linker") vars.Add('linkflags', "Extra linker flags") +vars.Add('ar', "Archiver (ar or lib)") +if os.name == "nt": + vars.Add('mt', "manifest tool") vars.Add(BoolVariable("ccache", "Use CCache", "no")) 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", "android"])) vars.Add('android_toolchain', "Path to Android toolchain") @@ -33,75 +36,91 @@ if os.name == "mac" or (os.name == "posix" and os.uname()[0] == "Darwin"): vars.Add(BoolVariable("mac105", "Link against the 10.5 frameworks", "no")) vars.Add(BoolVariable("mac106", "Link against the 10.6 frameworks", "no")) if os.name == "nt" : vars.Add(PathVariable("vcredist", "MSVC redistributable dir", None, PathVariable.PathAccept)) if os.name == "nt" : vars.Add(PathVariable("wix_bindir", "Path to WiX binaries", "", PathVariable.PathAccept)) if os.name == "nt" : vars.Add(PackageVariable("bonjour", "Bonjour SDK location", "yes")) vars.Add(PackageVariable("openssl", "OpenSSL location", "yes")) +vars.Add("openssl_libnames", "Comma-separated openssl library names to override defaults", None) vars.Add(BoolVariable("openssl_force_bundled", "Force use of the bundled OpenSSL", "no")) +vars.Add("openssl_include", "Location of OpenSSL include files (if not under (openssl)/include)", None) +vars.Add("openssl_libdir", "Location of OpenSSL library files (if not under (openssl)/lib)", None) 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(BoolVariable("boost_bundled_enable", "Allow use of bundled Boost as last resort", "true")) +vars.Add(PathVariable("zlib_includedir", "Zlib headers location", None, PathVariable.PathAccept)) +vars.Add(PathVariable("zlib_libdir", "Zlib library location", None, PathVariable.PathAccept)) +vars.Add(PathVariable("zlib_libfile", "Zlib library file (full path to file)", None, PathVariable.PathAccept)) +vars.Add(BoolVariable("zlib_bundled_enable", "Allow use of bundled Zlib as last resort", "true")) +vars.Add(BoolVariable("try_gconf", "Try configuring for GConf?", "true")) +vars.Add(BoolVariable("try_libxml", "Try configuring for libXML?", "true")) +vars.Add(BoolVariable("try_expat", "Try configuring for expat?", "true")) vars.Add(PathVariable("expat_includedir", "Expat headers location", None, PathVariable.PathAccept)) vars.Add(PathVariable("expat_libdir", "Expat library location", None, PathVariable.PathAccept)) -vars.Add("expat_libname", "Expat library name", "libexpat" if os.name == "nt" else "expat") +vars.Add("expat_libname", "Expat library name", os.name == "nt" and "libexpat" or "expat") vars.Add(PackageVariable("icu", "ICU library location", "no")) +vars.Add(BoolVariable("libidn_bundled_enable", "Allow use of bunded Expat", "true")) +vars.Add(BoolVariable("try_libidn", "Try configuring for LibIDN?", "true")) 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("libidn_libname", "LibIDN library name", os.name == "nt" and "libidn" or "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_libname", "SQLite library name", os.name == "nt" and "libsqlite3" or "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("editline_includedir", "Readline headers location", None, PathVariable.PathAccept)) vars.Add(PathVariable("editline_libdir", "Readline library location", None, PathVariable.PathAccept)) vars.Add("editline_libname", "Readline library name", "libedit" if os.name == "nt" else "edit") +vars.Add(BoolVariable("try_avahi", "Try configuring for avahi?", "true")) 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_ft", "Build experimental file transfer", "yes")) vars.Add(BoolVariable("experimental", "Build experimental features", "no")) 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")) +vars.Add(BoolVariable("install_git_hooks", "Install git hooks", "true")) + ################################################################################ # Set up default build & configure environment ################################################################################ - env_ENV = { - 'PATH' : os.environ['PATH'], + '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"]) + env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"], platform = ARGUMENTS.get("PLATFORM", None)) else : - env = Environment(ENV = env_ENV, variables = vars) + env = Environment(ENV = env_ENV, variables = vars, platform = ARGUMENTS.get("PLATFORM", None)) 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"] @@ -118,19 +137,19 @@ env.Tool("WriteVal", toolpath = ["#/BuildTools/SCons/Tools"]) env.Tool("BuildVersion", toolpath = ["#/BuildTools/SCons/Tools"]) env.Tool("Flags", toolpath = ["#/BuildTools/SCons/Tools"]) if env["PLATFORM"] == "darwin" : env.Tool("Nib", toolpath = ["#/BuildTools/SCons/Tools"]) env.Tool("AppBundle", toolpath = ["#/BuildTools/SCons/Tools"]) if env["PLATFORM"] == "win32" : env.Tool("WindowsBundle", toolpath = ["#/BuildTools/SCons/Tools"]) #So we don't need to escalate with UAC if "TMP" in os.environ.keys() : - env['ENV']['TMP'] = os.environ['TMP'] + env['ENV']['TMP'] = os.environ['TMP'] env.Tool("SLOCCount", toolpath = ["#/BuildTools/SCons/Tools"]) # Max out the number of jobs if env["max_jobs"] : try : import multiprocessing SetOption("num_jobs", multiprocessing.cpu_count()) except NotImplementedError : pass @@ -165,18 +184,21 @@ if "CCC_ANALYZER_HTML" in os.environ : 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"] +if "ar" in env : + env["AR"] = env["ar"] + if "link" in env : env["SHLINK"] = env["link"] env["LINK"] = env["link"] 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 : @@ -207,47 +229,47 @@ if env["debug"] : env.Append(CCFLAGS = ["/MDd"]) else : env.Append(CCFLAGS = ["-g"]) elif env["PLATFORM"] == "win32" : env.Append(CCFLAGS = ["/MD"]) if env.get("universal", 0) : assert(env["PLATFORM"] == "darwin") env.Append(CCFLAGS = [ - "-isysroot", "/Developer/SDKs/MacOSX10.4u.sdk", - "-arch", "i386", + "-isysroot", "/Developer/SDKs/MacOSX10.4u.sdk", + "-arch", "i386", "-arch", "ppc"]) env.Append(LINKFLAGS = [ - "-mmacosx-version-min=10.4", - "-isysroot", "/Developer/SDKs/MacOSX10.4u.sdk", - "-arch", "i386", + "-mmacosx-version-min=10.4", + "-isysroot", "/Developer/SDKs/MacOSX10.4u.sdk", + "-arch", "i386", "-arch", "ppc"]) # Link against other versions of the OS X SDKs. # FIXME: This method does not work anymore, we need to set deployment targets. if env.get("mac105", 0) : assert(env["PLATFORM"] == "darwin") env.Append(CCFLAGS = [ - "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk", + "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk", "-arch", "i386"]) env.Append(LINKFLAGS = [ - "-mmacosx-version-min=10.5", - "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk", + "-mmacosx-version-min=10.5", + "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk", "-arch", "i386"]) if env.get("mac106", 0) : assert(env["PLATFORM"] == "darwin") env.Append(CCFLAGS = [ - "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk", + "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk", "-arch", "i386"]) env.Append(LINKFLAGS = [ - "-mmacosx-version-min=10.6", - "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk", + "-mmacosx-version-min=10.6", + "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk", "-arch", "i386"]) if not env["assertions"] : env.Append(CPPDEFINES = ["NDEBUG"]) if env["experimental_ft"] : env.Append(CPPDEFINES = ["SWIFT_EXPERIMENTAL_FT"]) if env["experimental"] : @@ -255,18 +277,25 @@ if env["experimental"] : # If we build shared libs on AMD64, we need -fPIC. # This should have no performance impact om AMD64 if env["PLATFORM"] == "posix" and platform.machine() == "x86_64" : env.Append(CCFLAGS = ["-fPIC"]) # Warnings if env["PLATFORM"] == "win32" : env.Append(CXXFLAGS = ["/wd4068"]) +elif env["PLATFORM"] == "hpux" : + # HP-UX gives a flood of minor warnings if this is enabled + #env.Append(CXXFLAGS = ["+w"]) + pass +elif env["PLATFORM"] == "sunos" : + #env.Append(CXXFLAGS = ["-z verbose"]) + pass else : 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 @@ -292,24 +321,34 @@ if env.get("coverage", 0) : assert(env["PLATFORM"] != "win32") env.Append(CCFLAGS = ["-fprofile-arcs", "-ftest-coverage"]) env.Append(LINKFLAGS = ["-fprofile-arcs", "-ftest-coverage"]) if env["PLATFORM"] == "win32" : env.Append(LIBS = ["user32", "crypt32", "dnsapi", "iphlpapi", "ws2_32", "wsock32", "Advapi32"]) 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'] + mt = env.get('mt') + if not mt: + mt = 'mt.exe' + env["LINKCOM"] = [env["LINKCOM"], '%s -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1' % mt] + env["SHLINKCOM"] = [env["SHLINKCOM"], '%s -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2' % mt] if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphone-simulator", "xcode", "android"] : env["PLATFORM_FLAGS"]["FRAMEWORKS"] += ["IOKit", "AppKit", "SystemConfiguration", "Security", "SecurityInterface"] +# Required by boost headers on HP-UX +if env["PLATFORM"] == "hpux" : + env.Append(CXXFLAGS = ["+hpxstd98", "-mt", "-AA"]) + # FIXME: Need -AA for linking C++ but not C + #env.Append(LINKFLAGS = ["-AA"]) + + # Testing env["TEST_TYPE"] = env["test"] if "check" in ARGUMENTS : env["TEST_TYPE"] = "unit" env["checker_report"] = ARGUMENTS.get("checker_report", False) env["TEST"] = (env["TEST_TYPE"] != "none") or env.GetOption("clean") if env.get("valgrind", 0) : env["TEST_RUNNER"] = "valgrind --suppressions=QA/valgrind.supp -q --leak-check=full --track-origins=yes " env["TEST_IGNORE_RESULT"] = "ignore_test_result" in ARGUMENTS @@ -361,19 +400,19 @@ if target in ["iphone-device", "iphone-simulator", "xcode"] : env.Append(CCFLAGS = env["XCODE_ARCH_FLAGS"] + ["-fvisibility=hidden", "-miphoneos-version-min=" + env["IPHONEOS_DEPLOYMENT_TARGET"]]) env.Append(LINKFLAGS = "-miphoneos-version-min=" + env["IPHONEOS_DEPLOYMENT_TARGET"]) if os.environ.get("GCC_THUMB_SUPPORT", False) : env.Append(CCFLAGS = ["-mthumb"]) env.Append(LINKFLAGS = env["XCODE_ARCH_FLAGS"]) env.Append(CPPFLAGS = ["-isysroot", "$XCODE_SDKROOT"]) env.Append(FRAMEWORKS = ["CoreFoundation", "Foundation", "UIKit", "CoreGraphics"]) env.Append(LINKFLAGS = env["XCODE_ARCH_FLAGS"] + ["-isysroot", "$XCODE_SDKROOT", "-L\"$XCODE_SDKROOT/usr/lib\"", "-F\"$XCODE_SDKROOT/System/Library/Frameworks\"", "-F\"$XCODE_SDKROOT/System/Library/PrivateFrameworks\""]) # Bit of a hack, because BOOST doesn't know the endianness for ARM - env.Append(CPPDEFINES = ["_LITTLE_ENDIAN"]) + 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" diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index 25a1ad3..7bda9c1 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -5,19 +5,19 @@ 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) 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) ################################################################################ #if env["PLATFORM"] == "win32" : @@ -105,20 +105,39 @@ int main(int argc, char* argv[]) { conf = Configure(conf_env) if not conf.CheckCXX() or not conf.CheckCC() : print "Error: You need a working compiler" Exit(1) env["HAVE_ZLIB"] = True -if conf.CheckLib("z") : - env["ZLIB_FLAGS"] = {"LIBS": ["z"]} +zlib_flags = {} +zlib_okay = False +if env.get("zlib_libdir", None) : + zlib_flags["LIBPATH"] = [env["zlib_libdir"]] + zlib_okay = True +if env.get("zlib_includedir", None) : + zlib_flags["CPPPATH"] = [env["zlib_includedir"]] + zlib_okay = True +if env.get("zlib_libfile", None) : + zlib_flags["LIBS"] = [File(env["zlib_libfile"])] + 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" + 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") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["pthread"] @@ -126,64 +145,68 @@ if env["PLATFORM"] != "win32" : if conf.CheckLib("dl") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["dl"] if conf.CheckLib("m") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["m"] if conf.CheckLib("c") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["c"] -if conf.CheckLib("stdc++") : - env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["stdc++"] - +# Even if you find stdc++ on HP-UX, it is the wrong one for aCC +if env["PLATFORM"] != "hpux" : + if conf.CheckLib("stdc++", language='CXX') : + env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["stdc++"] conf.Finish() # Boost boost_conf_env = conf_env.Clone() boost_flags = {} if env.get("boost_libdir", None) : boost_flags["LIBPATH"] = [env["boost_libdir"]] if env.get("boost_includedir", None) : - if env["PLATFORM"] == "win32" : + if env["PLATFORM"] == "win32" or env["PLATFORM"] == "hpux" or env["PLATFORM"] == "sunos" : boost_flags["CPPPATH"] = [env["boost_includedir"]] else : # Using isystem to avoid getting warnings from a system boost # Unfortunately, this also disables dependency tracking 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), ("serialization", "archive/text_oarchive.hpp"), ("system", "system/system_error.hpp"), ("date_time", "date_time/date.hpp")] +boostLibs = [("signals", None), ("system", "system/system_error.hpp"), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("serialization", "archive/text_oarchive.hpp"), ("date_time", "date_time/date.hpp")] allLibsPresent = True libNames = [] for (lib, header) in boostLibs : if header : header = "boost/" + header else : header = "boost/" + lib + ".hpp" if not conf.CheckCXXHeader(header) : allLibsPresent = False break if env["PLATFORM"] != "win32" : libName = "boost_" + lib - if not conf.CheckLib(libName) : + if not conf.CheckLib(libName, language='CXX') : libName += "-mt" - if not conf.CheckLib(libName) : + if not conf.CheckLib(libName, language='CXX') : allLibsPresent = False break libNames.append(libName) if 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 - env["BOOST_FLAGS"]["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"] + env["BOOST_FLAGS"]["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"] +elif not env.get("boost_bundled_enable", True) : + print "Error: Boost not found and boost_bundled_enable is false" + Exit(1) else : env["BOOST_BUNDLED"] = True conf.Finish() # Xss env["HAVE_XSS"] = 0 if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : xss_flags = { @@ -194,19 +217,19 @@ if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : xss_env.MergeFlags(xss_flags) conf = Configure(xss_env) if conf.CheckFunc("XScreenSaverQueryExtension") : env["HAVE_XSS"] = 1 env["XSS_FLAGS"] = xss_flags conf.Finish() # GConf env["HAVE_GCONF"] = 0 -if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : +if env.get("try_gconf", True) and env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : gconf_env = conf_env.Clone() conf = Configure(gconf_env, custom_tests = {"CheckPKG": CheckPKG}) if conf.CheckPKG("gconf-2.0") : gconf_bare_env = Environment() gconf_bare_env.ParseConfig('pkg-config --cflags gconf-2.0 gobject-2.0 --libs gconf-2.0 gobject-2.0') gconf_flags = { "LIBS": gconf_bare_env["LIBS"], "CCFLAGS": gconf_bare_env["CCFLAGS"], "CPPPATH": gconf_bare_env["CPPPATH"], @@ -255,36 +278,36 @@ if env["PLATFORM"] == "darwin" : env["GROWL_FRAMEWORK"] = "/Library/Frameworks/Growl.framework" conf.Finish() # Snarl if env["PLATFORM"] == "win32" : env["HAVE_SNARL"] = True # LibXML conf = Configure(conf_env, custom_tests = {"CheckVersion": CheckVersion}) -if conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : +if env.get("try_libxml", True) and conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : #and conf.CheckVersion("LibXML", "2.6.23", "LIBXML_VERSION", "libxml/xmlversion.h", 20623) : env["HAVE_LIBXML"] = 1 env["LIBXML_FLAGS"] = { "LIBS": ["xml2"] } conf.Finish() -if not env.get("HAVE_LIBXML", 0) : +if env.get("try_libxml", True) and not env.get("HAVE_LIBXML", 0) : libxml_env = conf_env.Clone() libxml_env.Append(CPPPATH = ["/usr/include/libxml2"]) conf = Configure(libxml_env, custom_tests = {"CheckVersion": CheckVersion}) if conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : # and conf.CheckVersion("LibXML", "2.6.23", "LIBXML_VERSION", "libxml/xmlversion.h", 20623): env["HAVE_LIBXML"] = 1 env["LIBXML_FLAGS"] = { "CPPPATH": ["/usr/include/libxml2"], "LIBS": ["xml2"] } conf.Finish() # Expat -if not env.get("HAVE_LIBXML",0) : +if env.get("try_expat", True) and not env.get("HAVE_LIBXML",0) : expat_conf_env = conf_env.Clone() expat_flags = {} if env.get("expat_libdir", None) : expat_flags["LIBPATH"] = [env["expat_libdir"]] if env.get("expat_includedir", None) : expat_flags["CPPPATH"] = [env["expat_includedir"]] expat_conf_env.MergeFlags(expat_flags) conf = Configure(expat_conf_env) if conf.CheckCHeader("expat.h") and conf.CheckLib(env["expat_libname"]) : @@ -302,19 +325,21 @@ if not env.get("HAVE_EXPAT", 0) and not env.get("HAVE_LIBXML", 0) : env["EXPAT_BUNDLED"] = True ################################################################################ # IDN library ################################################################################ # ICU icu_env = conf_env.Clone() use_icu = bool(env["icu"]) -icu_prefix = env["icu"] if isinstance(env["icu"], str) else "" +icu_prefix = "" +if isinstance(env["icu"], str) : + icu_prefix = env["icu"] icu_flags = {} if icu_prefix : icu_flags = { "CPPPATH": [os.path.join(icu_prefix, "include")] } icu_flags["LIBPATH"] = [os.path.join(icu_prefix, "lib")] icu_env.MergeFlags(icu_flags) icu_conf = Configure(icu_env) if use_icu and icu_conf.CheckCHeader("unicode/usprep.h") : env["HAVE_ICU"] = 1 @@ -325,28 +350,32 @@ icu_conf.Finish() # LibIDN libidn_conf_env = conf_env.Clone() libidn_flags = {} if env.get("libidn_libdir", None) : libidn_flags["LIBPATH"] = [env["libidn_libdir"]] if env.get("libidn_includedir", None) : libidn_flags["CPPPATH"] = [env["libidn_includedir"]] libidn_conf_env.MergeFlags(libidn_flags) conf = Configure(libidn_conf_env) -if not env.get("HAVE_ICU") and conf.CheckCHeader("idna.h") and conf.CheckLib(env["libidn_libname"]) : +if env.get("try_libidn", True) and not env.get("HAVE_ICU") and conf.CheckCHeader("idna.h") and conf.CheckLib(env["libidn_libname"]) : env["HAVE_LIBIDN"] = 1 env["LIBIDN_FLAGS"] = { "LIBS": [env["libidn_libname"]] } 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) : - env["HAVE_LIBIDN"] = 1 - env["LIBIDN_BUNDLED"] = 1 + if env.get("libidn_bundled_enable", True) : + env["HAVE_LIBIDN"] = 1 + env["LIBIDN_BUNDLED"] = 1 + else : + print "Error: ICU and LIBIDN not found, and libidn_bundled_enable is false" + Exit(1) # Unbound if env["unbound"] : env["LDNS_BUNDLED"] = 1 env["UNBOUND_BUNDLED"] = 1 else : env["LDNS_FLAGS"] = {} env["UNBOUND_FLAGS"] = {} @@ -453,60 +482,73 @@ conf.Finish() # Avahi avahi_conf_env = conf_env.Clone() avahi_flags = {} if env.get("avahi_libdir", None) : avahi_flags["LIBPATH"] = [env["avahi_libdir"]] if env.get("avahi_includedir", None) : avahi_flags["CPPPATH"] = [env["avahi_includedir"]] avahi_conf_env.MergeFlags(avahi_flags) conf = Configure(avahi_conf_env) -if conf.CheckCHeader("avahi-client/client.h") and conf.CheckLib("avahi-client") and conf.CheckLib("avahi-common") : +if env.get("try_avahi", True) and conf.CheckCHeader("avahi-client/client.h") and conf.CheckLib("avahi-client") and conf.CheckLib("avahi-common") : 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"] # OpenSSL openssl_env = conf_env.Clone() 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 : use_openssl = bool(env["openssl"]) - openssl_prefix = env["openssl"] if isinstance(env["openssl"], str) else "" + openssl_prefix = "" + if isinstance(env["openssl"], str) : + openssl_prefix = env["openssl"] openssl_flags = {} if openssl_prefix : - openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] } - if env["PLATFORM"] == "win32" : + openssl_include = env.get("openssl_include", None) + openssl_libdir = env.get("openssl_libdir", None) + if openssl_include: + openssl_flags = {"CPPPATH":[openssl_include]} + else: + openssl_flags = { "CPPPATH": [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) 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" : + openssl_libnames = env.get("openssl_libnames", None) + if openssl_libnames: + env["OPENSSL_FLAGS"]["LIBS"] = openssl_libnames.split(',') + elif 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" : + 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 "" @@ -524,19 +566,19 @@ if hunspell_conf.CheckCXXHeader("hunspell/hunspell.hxx") and hunspell_conf.Check hunspell_conf.Finish() # Bonjour if env["PLATFORM"] == "darwin" and env["target"] == "native" : env["HAVE_BONJOUR"] = 1 elif env.get("bonjour", False) : bonjour_env = conf_env.Clone() bonjour_conf = Configure(bonjour_env) bonjour_flags = {} - if env.get("bonjour") != True : + if env.get("bonjour") != True : bonjour_prefix = env["bonjour"] bonjour_flags["CPPPATH"] = [os.path.join(bonjour_prefix, "include")] bonjour_flags["LIBPATH"] = [os.path.join(bonjour_prefix, "lib", "win32")] bonjour_env.MergeFlags(bonjour_flags) if bonjour_conf.CheckCHeader("dns_sd.h") and bonjour_conf.CheckLib("dnssd") : env["HAVE_BONJOUR"] = 1 env["BONJOUR_FLAGS"] = bonjour_flags env["BONJOUR_FLAGS"]["LIBS"] = ["dnssd"] bonjour_conf.Finish() @@ -566,19 +608,19 @@ if env.get("docbook_xsl") : env["DOCBOOK_XSL_DIR"] = env["docbook_xsl"] ################################################################################ # Set up git hooks ################################################################################ try: if env.Dir("#/.git").exists() : - if not env.GetOption("clean") : + 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." ################################################################################ # Replace #pragma once with proper guards on platforms that require it ################################################################################ @@ -660,12 +702,12 @@ 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 " TLS Support: " + ("OpenSSL" if env.get("HAVE_OPENSSL",0) else ("Schannel" if env.get("HAVE_SCHANNEL", 0) else "Disabled")) -print " DNSSD Support: " + ("Bonjour" if env.get("HAVE_BONJOUR") else ("Avahi" if env.get("HAVE_AVAHI") else "Disabled")) +print " TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" 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 diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py index 95fcce9..7e4609d 100644 --- a/BuildTools/SCons/Tools/Test.py +++ b/BuildTools/SCons/Tools/Test.py @@ -1,21 +1,24 @@ import SCons.Util, os def generate(env) : def registerTest(env, target, type = "unit", is_checker = False) : if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type : - cmd = target[0].abspath if SCons.Util.is_List(target) else target.abspath + if SCons.Util.is_List(target) : + cmd = target[0].abspath + else : + cmd = target.abspath params = "" # Special support for unittest checker if is_checker and env.get("checker_report", False) : params = " --xml > " + os.path.join(target[0].dir.path, "checker-report.xml") - + ignore_prefix = "" if env.get("TEST_IGNORE_RESULT", False) : ignore_prefix = "-" # Set environment variables for running the test test_env = env.Clone() for i in ["HOME", "USERPROFILE", "APPDATA"]: if os.environ.get(i, "") : test_env["ENV"][i] = os.environ[i] @@ -27,22 +30,22 @@ def generate(env) : 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 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 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, + test_env.Command("**dummy**", target, SCons.Action.Action(ignore_prefix + env.get("TEST_RUNNER", "") + cmd + " " + params, cmdstr = "$TESTCOMSTR")) def registerScriptTests(env, scripts, name, type) : if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type : pass env.AddMethod(registerTest, "Test") env.AddMethod(registerScriptTests, "ScriptTests") diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py index f98a8b9..2f3b5a5 100644 --- a/BuildTools/SCons/Version.py +++ b/BuildTools/SCons/Version.py @@ -4,38 +4,40 @@ def getGitBuildVersion(root, project) : tag = git("describe --tags --exact --match \"" + project + "-*\"", root) if tag : return tag.rstrip()[len(project)+1:] tag = git("describe --tags --match \"" + project + "-*\"", root) if tag : m = re.match(project + "-(.*)-(.*)-(.*)", tag) if m : return m.group(1) + "-dev" + m.group(2) return None - + def git(cmd, root) : full_cmd = "git " + cmd p = subprocess.Popen(full_cmd, cwd=root, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt")) gitVersion = p.stdout.read() # error = p.stderr.read() # if error: # print "Git error: " + error p.stdin.close() - return gitVersion if p.wait() == 0 else None + if p.wait() == 0 : + return gitVersion + return None def getBuildVersion(root, project) : versionFilename = os.path.join(root, "VERSION." + project) if os.path.isfile(versionFilename) : f = open(versionFilename) version = f.read().strip() f.close() return version - gitVersion = getGitBuildVersion(root, project) + gitVersion = getGitBuildVersion(root, project) if gitVersion : return gitVersion return datetime.date.today().strftime("%Y%m%d") def convertToWindowsVersion(version) : version_match = re.match("(\d+)\.(\d+)(.*)", version) major = int(version_match.group(1)) if version_match else 0 minor = int(version_match.group(2)) if version_match else 0 @@ -53,15 +55,14 @@ def convertToWindowsVersion(version) : patch = 10000*int(rc_match.group(1)) build_string = rc_match.group(2) else : patch = 0 alpha_match = re.match("^alpha(.*)", version_match.group(3)) if alpha_match : build_string = alpha_match.group(1) if len(build_string) > 0 : - build_match = re.match("^-dev(\d+)", build_string) + build_match = re.match("^-dev(\d+)", build_string) if build_match : patch += int(build_match.group(1)) return (major, minor, patch) - |