summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools/SCons')
-rw-r--r--BuildTools/SCons/SConscript.boot511
-rw-r--r--BuildTools/SCons/SConstruct920
-rw-r--r--BuildTools/SCons/Tools/AppBundle.py108
-rw-r--r--BuildTools/SCons/Tools/BuildVersion.py10
-rw-r--r--BuildTools/SCons/Tools/DoxyGen.py38
-rw-r--r--BuildTools/SCons/Tools/Flags.py16
-rw-r--r--BuildTools/SCons/Tools/InstallWithSymLinks.py114
-rw-r--r--BuildTools/SCons/Tools/Nib.py14
-rw-r--r--BuildTools/SCons/Tools/ReplacePragmaOnce.py36
-rw-r--r--BuildTools/SCons/Tools/SLOCCount.py22
-rw-r--r--BuildTools/SCons/Tools/Test.py96
-rw-r--r--BuildTools/SCons/Tools/WindowsBundle.py222
-rw-r--r--BuildTools/SCons/Tools/WriteVal.py16
-rw-r--r--BuildTools/SCons/Tools/nsis.py48
-rw-r--r--BuildTools/SCons/Tools/qt4.py1015
-rw-r--r--BuildTools/SCons/Tools/textfile.py218
-rw-r--r--BuildTools/SCons/Tools/wix.py86
-rw-r--r--BuildTools/SCons/Version.py110
18 files changed, 1905 insertions, 1695 deletions
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 14f72c7..031c556 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -14,8 +14,9 @@ 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('mt', "manifest tool")
vars.Add(BoolVariable("ccache", "Use CCache", "no"))
+vars.Add(BoolVariable("distcc", "Use distcc", "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"))
@@ -28,29 +29,30 @@ 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" :
- vars.Add(BoolVariable("coverage", "Compile with coverage information", "no"))
+ vars.Add(BoolVariable("coverage", "Compile with coverage information", "no"))
if os.name == "posix" :
- vars.Add(BoolVariable("valgrind", "Run tests with valgrind", "no"))
+ vars.Add(BoolVariable("valgrind", "Run tests with valgrind", "no"))
if os.name == "mac" or (os.name == "posix" and os.uname()[0] == "Darwin"):
- vars.Add(BoolVariable("universal", "Create universal binaries", "no"))
- vars.Add(BoolVariable("mac105", "Link against the 10.5 frameworks", "no"))
- vars.Add(BoolVariable("mac106", "Link against the 10.6 frameworks", "no"))
+ vars.Add(BoolVariable("universal", "Create universal binaries", "no"))
+ 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))
+ 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))
+ 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("bonjour", "Bonjour SDK location", "yes"))
+vars.Add(EnumVariable("tls_backend", "Choose the TLS backend", "native", ["native", "openssl", "openssl_bundled"]))
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_prefix", "Hunspell location", False))
-vars.Add(BoolVariable("hunspell_enable", "Build with Hunspell support", False))
+vars.Add(BoolVariable("hunspell_enable", "Build with Hunspell support", True))
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(BoolVariable("boost_force_bundled", "Force use of bundled Boost.", False))
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))
@@ -68,12 +70,17 @@ vars.Add(PathVariable("libidn_includedir", "LibIDN headers location", None, Path
vars.Add(PathVariable("libidn_libdir", "LibIDN library location", None, PathVariable.PathAccept))
vars.Add("libidn_libname", "LibIDN library name", os.name == "nt" and "libidn" or "idn")
vars.Add(BoolVariable("need_idn", "Whether an IDN library is required. Without this, most internal binaries will fail", "true"))
+
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", os.name == "nt" and "libminiupnpc" or "miniupnpc")
+vars.Add(BoolVariable("libminiupnpc_force_bundled", "Force use of bundled LibMiniUPNPC", False))
+
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", os.name == "nt" and "libnatpmp" or "natpmp")
+vars.Add(BoolVariable("libnatpmp_force_bundled", "Force use of bundled LibNATPMP", False))
+
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", os.name == "nt" and "libsqlite3" or "sqlite3")
@@ -104,36 +111,45 @@ vars.Add(BoolVariable("check_headers", "Independently build compilation units fo
vars.Add("win_target_arch", "Target architecture for Windows builds. x86 for 32-bit (default) or x86_64 for 64-bit.", "x86")
vars.Add(BoolVariable("install_git_hooks", "Install git hooks", "true"))
+# Code Signing Options
+vars.Add("codesign_identity", "macOS code signing identity to be passed to codesign when building the distribution package. Must match the Commen Name of the Subject of the code signing certificate.", "")
+vars.Add("signtool_key_pfx", "The keyfile (.pfx) that will be used to sign the Windows installer.", None)
+vars.Add("signtool_timestamp_url", "The timestamp server that will be queried for a signed time stamp in the signing process.", None)
+
+# Automatic Software Update Options
+vars.Add(PathVariable("sparkle_public_dsa_key", "Optional path to a public DSA key used to verify Sparkle software updates. Without specifiying this option, the app needs to be code signed for Sparkle to work.", None, PathVariable.PathIsFile))
+
+
################################################################################
# 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", ""),
+ '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"], platform = ARGUMENTS.get("PLATFORM", None))
- env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"], platform = ARGUMENTS.get("PLATFORM", None), TARGET_ARCH=env["win_target_arch"])
+ env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"], platform = ARGUMENTS.get("PLATFORM", None))
+ env = Environment(ENV = env_ENV, variables = vars, MSVC_VERSION = ARGUMENTS["MSVC_VERSION"], platform = ARGUMENTS.get("PLATFORM", None), TARGET_ARCH=env["win_target_arch"])
else :
- env = Environment(ENV = env_ENV, variables = vars, platform = ARGUMENTS.get("PLATFORM", None))
- env = Environment(ENV = env_ENV, variables = vars, platform = ARGUMENTS.get("PLATFORM", None), TARGET_ARCH=env["win_target_arch"])
+ env = Environment(ENV = env_ENV, variables = vars, platform = ARGUMENTS.get("PLATFORM", None))
+ env = Environment(ENV = env_ENV, variables = vars, platform = ARGUMENTS.get("PLATFORM", None), TARGET_ARCH=env["win_target_arch"])
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"]
+ env["ENV"]["LIB"] = os.environ["LIB"]
+ env["ENV"]["INCLUDE"] = os.environ["INCLUDE"]
# Default environment variables
env["PLATFORM_FLAGS"] = {
- "LIBPATH": [],
- "LIBS": [],
- "FRAMEWORKS": [],
+ "LIBPATH": [],
+ "LIBS": [],
+ "FRAMEWORKS": [],
}
# Default custom tools
@@ -142,24 +158,24 @@ 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"])
+ 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.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.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
- except ImportError :
- pass
+ try :
+ import multiprocessing
+ SetOption("num_jobs", multiprocessing.cpu_count())
+ except NotImplementedError :
+ pass
+ except ImportError :
+ pass
# Set speed options
env.Decider("MD5-timestamp")
@@ -168,19 +184,24 @@ 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"])
+ 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++"
+ if "link" not in env :
+ # Use clang++ instead of clang, otherwise XCode's clang will cause linking errors due to missing C++ standard lib.
+ env["LINK"] = "clang++"
+ if platform.machine() == "x86_64" :
+ env.Append(LINKFLAGS = ["-arch", "x86_64"])
+
+# Set QT_SELECT variable to enable building on systems that have Qt4 and Qt5 installed and use qtselect
+if env["PLATFORM"] != "darwin" and env["PLATFORM"] != "win32" :
+ if env["qt5"] :
+ env["ENV"]["QT_SELECT"] = "qt5"
+ else:
+ env["ENV"]["QT_SELECT"] = "qt4"
# Set QT_SELECT variable to enable building on systems that have Qt4 and Qt5 installed and use qtselect
if env["PLATFORM"] != "darwin" and env["PLATFORM"] != "win32" :
@@ -191,198 +212,209 @@ if env["PLATFORM"] != "darwin" and env["PLATFORM"] != "win32" :
# 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"]
+ 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"]
+ env["CC"] = env["cc"]
if "cxx" in env :
- env["CXX"] = env["cxx"]
+ env["CXX"] = env["cxx"]
if "ar" in env :
- env["AR"] = env["ar"]
+ env["AR"] = env["ar"]
if "link" in env :
- env["SHLINK"] = env["link"]
- env["LINK"] = env["link"]
+ env["SHLINK"] = env["link"]
+ env["LINK"] = env["link"]
+
+# Process user-defined external flags
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]
+ 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"] = []
+# Compile code as C++11
+if env["PLATFORM"] != "win32" :
+ env.Append(CXXFLAGS = ["-std=c++11"])
+
if env["optimize"] :
- if env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/O2"])
- else :
- env.Append(CCFLAGS = ["-O2"])
+ if env["PLATFORM"] == "win32" :
+ env.Append(CCFLAGS = ["/O2"])
+ else :
+ env.Append(CCFLAGS = ["-O2"])
if env["target"] == "xcode" and os.environ["CONFIGURATION"] == "Release" :
- env.Append(CCFLAGS = ["-Os"])
+ env.Append(CCFLAGS = ["-Os"])
if env["debug"] :
- if env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/Zi"])
- env.Append(LINKFLAGS = ["/DEBUG"])
- if GetOption("num_jobs") > 1 :
- env["CCPDBFLAGS"] = '/Fd${TARGET}.pdb'
- env["PDB"] = '${TARGET.base}.pdb'
- if env["set_iterator_debug_level"] :
- env.Append(CPPDEFINES = ["_ITERATOR_DEBUG_LEVEL=0"])
- if env["optimize"] :
- env.Append(LINKFLAGS = ["/OPT:NOREF"])
- env.Append(CCFLAGS = ["/MD"])
- else :
- env.Append(CCFLAGS = ["/MDd"])
- else :
- env.Append(CCFLAGS = ["-g"])
+ if env["PLATFORM"] == "win32" :
+ env.Append(CCFLAGS = ["/Zi"])
+ env.Append(LINKFLAGS = ["/DEBUG"])
+ if GetOption("num_jobs") > 1 :
+ env["CCPDBFLAGS"] = '/Fd${TARGET}.pdb'
+ env["PDB"] = '${TARGET.base}.pdb'
+ if env["set_iterator_debug_level"] :
+ env.Append(CPPDEFINES = ["_ITERATOR_DEBUG_LEVEL=0"])
+ env.Append(LINKFLAGS = ["/OPT:NOREF"])
+ env.Append(CCFLAGS = ["/MD"])
+ else :
+ env.Append(CCFLAGS = ["-g"])
elif env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/MD"])
+ env.Append(CCFLAGS = ["/MD"])
if env.get("universal", 0) :
- assert(env["PLATFORM"] == "darwin")
- env.Append(CCFLAGS = [
- "-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",
- "-arch", "ppc"])
+ assert(env["PLATFORM"] == "darwin")
+ env.Append(CCFLAGS = [
+ "-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",
+ "-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",
- "-arch", "i386"])
- env.Append(LINKFLAGS = [
- "-mmacosx-version-min=10.5",
- "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk",
- "-arch", "i386"])
+ assert(env["PLATFORM"] == "darwin")
+ env.Append(CCFLAGS = [
+ "-isysroot", "/Developer/SDKs/MacOSX10.5.sdk",
+ "-arch", "i386"])
+ env.Append(LINKFLAGS = [
+ "-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",
- "-arch", "i386"])
- env.Append(LINKFLAGS = [
- "-mmacosx-version-min=10.6",
- "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk",
- "-arch", "i386"])
+ assert(env["PLATFORM"] == "darwin")
+ env.Append(CCFLAGS = [
+ "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk",
+ "-arch", "i386"])
+ env.Append(LINKFLAGS = [
+ "-mmacosx-version-min=10.6",
+ "-isysroot", "/Developer/SDKs/MacOSX10.6.sdk",
+ "-arch", "i386"])
if not env["assertions"] :
- env.Append(CPPDEFINES = ["NDEBUG"])
+ env.Append(CPPDEFINES = ["NDEBUG"])
# disable file-transfer support on iOS
if env["target"] in ["iphone-device", "iphone-simulator", "xcode"] :
- env["experimental_ft"] = False
+ env["experimental_ft"] = False
if env["experimental_ft"] :
- env.Append(CPPDEFINES = ["SWIFT_EXPERIMENTAL_FT"])
+ env.Append(CPPDEFINES = ["SWIFT_EXPERIMENTAL_FT"])
if env["experimental"] :
- env.Append(CPPDEFINES = ["SWIFT_EXPERIMENTAL_HISTORY", "SWIFT_EXPERIMENTAL_WB"])
+ env.Append(CPPDEFINES = ["SWIFT_EXPERIMENTAL_HISTORY", "SWIFT_EXPERIMENTAL_WB"])
# 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() in ["x86_64", "amd64"] :
- env.Append(CCFLAGS = ["-fPIC"])
+ env.Append(CCFLAGS = ["-fPIC"])
# Warnings
if env["PLATFORM"] == "win32" :
- env.Append(CXXFLAGS = ["/wd4068"])
+ env.Append(CXXFLAGS = ["/wd4068"])
+ env.Append(CXXFLAGS = ["/wd4503"]) # Disable 'decorated name length exceeded, name was truncated' warning
+ if not env.get("allow_warnings", "False") :
+ env.Append(CXXFLAGS = ["/WX"])
elif env["PLATFORM"] == "hpux" :
- # HP-UX gives a flood of minor warnings if this is enabled
- #env.Append(CXXFLAGS = ["+w"])
- pass
+ # 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
+ #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
- "-Wno-documentation-unknown-command", # 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
- "-Wno-potentially-evaluated-expression", # Caused due to calling shared_ptr::get() inside typeid()
- ])
- 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"])
+ if os.path.basename(env["CXX"]) in ["clang", "clang++"] :
+ 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-documentation-unknown-command", # 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-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
+ "-Wno-potentially-evaluated-expression", # Caused due to calling shared_ptr::get() inside typeid()
+ ])
+ 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"])
if env.get("coverage", 0) :
- assert(env["PLATFORM"] != "win32")
- env.Append(CCFLAGS = ["-fprofile-arcs", "-ftest-coverage"])
- env.Append(LINKFLAGS = ["-fprofile-arcs", "-ftest-coverage"])
+ 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", "ntdsapi"])
- env.Append(CCFLAGS = ["/EHsc", "/nologo", "/Zm256"])
- env.Append(LINKFLAGS = ["/INCREMENTAL:no", "/NOLOGO"])
- if int(env["MSVS_VERSION"].split(".")[0]) < 10 :
- 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]
+ env.Append(LIBS = ["user32", "crypt32", "dnsapi", "iphlpapi", "ws2_32", "wsock32", "Advapi32", "ntdsapi"])
+ env.Append(CCFLAGS = ["/EHsc", "/nologo", "/Zm256"])
+ env.Append(LINKFLAGS = ["/INCREMENTAL:no", "/NOLOGO"])
+ if int(env["MSVS_VERSION"].split(".")[0]) < 10 :
+ 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"]
+ 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"])
+ env.Append(CXXFLAGS = ["+hpxstd98", "-mt", "-AA"])
+ # FIXME: Need -AA for linking C++ but not C
+ #env.Append(LINKFLAGS = ["-AA"])
+# Code signing
+if env["PLATFORM"] == "darwin" :
+ env["CODE_SIGN_IDENTITY"] = env["codesign_identity"]
+if env["PLATFORM"] == "win32" :
+ env["SIGNTOOL_KEY_PFX"] = env.get("signtool_key_pfx", None)
+ env["SIGNTOOL_TIMESTAMP_URL"] = env.get("signtool_timestamp_url", None)
# Testing
env["TEST_TYPE"] = env["test"]
if "check" in ARGUMENTS :
- env["TEST_TYPE"] = "unit"
+ 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_RUNNER"] = "valgrind --suppressions=QA/valgrind.supp -q --leak-check=full --track-origins=yes "
env["TEST_IGNORE_RESULT"] = "ignore_test_result" in ARGUMENTS
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", "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
+ if ARGUMENTS.get(path, "") :
+ if os.path.isabs(ARGUMENTS[path]) :
+ env[path] = Dir(ARGUMENTS[path]).abspath
+ else :
+ env[path] = Dir("#/" + ARGUMENTS[path]).abspath
################################################################################
@@ -391,70 +423,77 @@ for path in ["SWIFT_INSTALLDIR", "SWIFTEN_INSTALLDIR", "SLUIFT_INSTALLDIR"] :
target = env["target"]
if target in ["iphone-device", "iphone-simulator", "xcode"] :
- # Extract/initialize all the information we need
- if target == "xcode" :
- # Get the information from the XCode environment
- env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = os.environ["PLATFORM_DEVELOPER_BIN_DIR"]
- env["XCODE_SDKROOT"] = os.environ["SDKROOT"]
- env["XCODE_ARCH_FLAGS"] = sum([["-arch", arch] for arch in os.environ["ARCHS"].split(" ")], [])
- env["IPHONEOS_DEPLOYMENT_TARGET"] = os.environ["IPHONEOS_DEPLOYMENT_TARGET"]
- # Use absolute path sources so Xcode can highlight compilation errors in swiften
- env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM ${SOURCES.abspath}'
- else :
- # Hard code values
- 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 = "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
- env["CC"] = os.environ["DEVELOPER_BIN_DIR"] + "/gcc"
- env["CXX"] = os.environ["DEVELOPER_BIN_DIR"] + "/g++"
- env["OBJCCFLAGS"] = ["-fobjc-abi-version=2", "-fobjc-legacy-dispatch"]
- env["LD"] = env["CC"]
- 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"])
+ # Extract/initialize all the information we need
+ if target == "xcode" :
+ # Get the information from the XCode environment
+ env["XCODE_PLATFORM_DEVELOPER_BIN_DIR"] = os.environ["PLATFORM_DEVELOPER_BIN_DIR"]
+ env["XCODE_SDKROOT"] = os.environ["SDKROOT"]
+ env["XCODE_ARCH_FLAGS"] = sum([["-arch", arch] for arch in os.environ["ARCHS"].split(" ")], [])
+ env["IPHONEOS_DEPLOYMENT_TARGET"] = os.environ["IPHONEOS_DEPLOYMENT_TARGET"]
+ # Use absolute path sources so Xcode can highlight compilation errors in swiften
+ env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM ${SOURCES.abspath}'
+ else :
+ # Hard code values
+ 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 = "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
+ env["CC"] = os.environ["DEVELOPER_BIN_DIR"] + "/gcc"
+ env["CXX"] = os.environ["DEVELOPER_BIN_DIR"] + "/g++"
+ env["OBJCCFLAGS"] = ["-fobjc-abi-version=2", "-fobjc-legacy-dispatch"]
+ env["LD"] = env["CC"]
+ 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"])
################################################################################
# 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["AR"] = "arm-linux-androideabi-ar"
- env["RANLIB"] = "arm-linux-androideabi-ranlib"
- env.Append(CPPDEFINES = ["ANDROID"])
- env.Append(CPPDEFINES = ["_REENTRANT", "_GLIBCXX__PTHREADS"])
+ env["ENV"]["PATH"] = env["android_toolchain"] + "/bin:" + env["ENV"]["PATH"]
+ env["CC"] = "arm-linux-androideabi-gcc"
+ env["CXX"] = "arm-linux-androideabi-g++"
+ env["AR"] = "arm-linux-androideabi-ar"
+ 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"]
- for var in os.environ :
- if var.startswith("CCACHE_") :
- env["ENV"][var] = os.environ[var]
- if env.get("CC", "") != "" :
- env["CC"] = "ccache " + env["CC"]
- else :
- env["CC"] = "ccache gcc"
- if env.get("CXX", "") != "" :
- env["CXX"] = "ccache " + env["CXX"]
- else :
- env["CC"] = "ccache g++"
+ env["ENV"]["HOME"] = os.environ["HOME"]
+ for var in os.environ :
+ if var.startswith("CCACHE_") :
+ env["ENV"][var] = os.environ[var]
+ if env.get("CC", "") != "" :
+ env["CC"] = "ccache " + env["CC"]
+ else :
+ env["CC"] = "ccache gcc"
+ if env.get("CXX", "") != "" :
+ env["CXX"] = "ccache " + env["CXX"]
+ else :
+ env["CC"] = "ccache g++"
+
+# distcc
+if env.get("distcc", False) :
+ env["ENV"]["HOME"] = os.environ["HOME"]
+ for var in os.environ :
+ if var.startswith("DISTCC_") :
+ env["ENV"][var] = os.environ[var]
conf_env = env.Clone()
@@ -463,12 +502,12 @@ Export("conf_env")
variant = ""
if env["enable_variants"] :
- fingerprint = ",".join([flag for flag in env["CXXFLAGS"] + env["CCFLAGS"] if not flag.startswith("-W") and not flag.startswith("-fvisibility")])
- variant = "build/" + fingerprint
- if not os.path.exists(Dir("#/build").abspath) :
- os.mkdir(Dir("#/build").abspath)
- if os.path.exists(Dir("#/build/current").abspath) :
- os.unlink(Dir("#/build/current").abspath)
- os.symlink(os.path.basename(variant), Dir("#/build/current").abspath)
+ fingerprint = ",".join([flag for flag in env["CXXFLAGS"] + env["CCFLAGS"] if not flag.startswith("-W") and not flag.startswith("-fvisibility")])
+ variant = "build/" + fingerprint
+ if not os.path.exists(Dir("#/build").abspath) :
+ os.mkdir(Dir("#/build").abspath)
+ if os.path.exists(Dir("#/build/current").abspath) :
+ os.unlink(Dir("#/build/current").abspath)
+ os.symlink(os.path.basename(variant), Dir("#/build/current").abspath)
Return("variant")
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index de24728..c084cff 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -8,8 +8,8 @@ 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)
+ if not keywords.get("test_only", False) or env["TEST"] :
+ return apply(oldSConscript, arguments, keywords)
env.SConscript = SConscript
################################################################################
@@ -21,313 +21,352 @@ env.SConscript = SConscript
################################################################################
#if env["PLATFORM"] == "win32" :
-# env["MSVC_BATCH"] = 1
+# env["MSVC_BATCH"] = 1
# Pretty output
def colorize(command, target, color) :
- colors = { "red": "31", "green": "32", "yellow": "33", "blue": "34" }
- prefix = ""
- suffix = ""
- if sys.stdout.isatty() and env["PLATFORM"] != "win32":
- prefix = "\033[0;" + colors[color] + ";140m"
- suffix = "\033[0m"
- return " " + prefix + command + suffix + " " + target
+ colors = { "red": "31", "green": "32", "yellow": "33", "blue": "34" }
+ prefix = ""
+ suffix = ""
+ if sys.stdout.isatty() and env["PLATFORM"] != "win32":
+ prefix = "\033[0;" + colors[color] + ";140m"
+ suffix = "\033[0m"
+ return " " + prefix + command + suffix + " " + target
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")
- env["SHCXXCOMSTR"] = colorize("CXX", "$TARGET", "green")
- env["LINKCOMSTR"] = colorize("LINK", "$TARGET", "red")
- 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")
- env["QT4_MOCFROMCXXCOMSTR"] = colorize("MOC", "$TARGET", "blue")
- env["QT4_LRELEASECOMSTR"] = colorize("LRELEASE", "$TARGET", "blue")
- env["QT4_LUPDATECOMSTR"] = colorize("LUPDATE", "$TARGET", "blue")
- env["GENCOMSTR"] = colorize("GEN", "$TARGET", "blue")
- env["RCCOMSTR"] = colorize("RC", "$TARGET", "blue")
- env["BUNDLECOMSTR"] = colorize("BUNDLE", "$TARGET", "blue")
- env["NIBCOMSTR"] = colorize("NIB", "$TARGET", "blue")
- env["NSISCOMSTR"] = colorize("NSIS", "$TARGET", "blue")
- env["INSTALLSTR"] = colorize("INSTALL", "$TARGET", "blue")
- env["TESTCOMSTR"] = colorize("TEST", "$SOURCE", "yellow")
- env["FOCOMSTR"] = colorize("FO", "$TARGET", "blue")
- env["XSLTCOMSTR"] = colorize("XSLT", "$TARGET", "blue")
- env["XMLLINTCOMSTR"] = colorize("XMLLINT", "$SOURCE", "blue")
- env["DOXYCOMSTR"] = colorize("DOXY", "$SOURCE", "blue")
- #Progress(colorize("DEP", "$TARGET", "red")
+ env["CCCOMSTR"] = colorize("CC", "$TARGET", "green")
+ env["SHCCCOMSTR"] = colorize("CC", "$TARGET", "green")
+ env["CXXCOMSTR"] = colorize("CXX", "$TARGET", "green")
+ env["SHCXXCOMSTR"] = colorize("CXX", "$TARGET", "green")
+ env["LINKCOMSTR"] = colorize("LINK", "$TARGET", "red")
+ 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")
+ env["QT4_MOCFROMCXXCOMSTR"] = colorize("MOC", "$TARGET", "blue")
+ env["QT4_LRELEASECOMSTR"] = colorize("LRELEASE", "$TARGET", "blue")
+ env["QT4_LUPDATECOMSTR"] = colorize("LUPDATE", "$TARGET", "blue")
+ env["GENCOMSTR"] = colorize("GEN", "$TARGET", "blue")
+ env["RCCOMSTR"] = colorize("RC", "$TARGET", "blue")
+ env["BUNDLECOMSTR"] = colorize("BUNDLE", "$TARGET", "blue")
+ env["NIBCOMSTR"] = colorize("NIB", "$TARGET", "blue")
+ env["NSISCOMSTR"] = colorize("NSIS", "$TARGET", "blue")
+ env["INSTALLSTR"] = colorize("INSTALL", "$TARGET", "blue")
+ env["TESTCOMSTR"] = colorize("TEST", "$SOURCE", "yellow")
+ env["FOCOMSTR"] = colorize("FO", "$TARGET", "blue")
+ env["XSLTCOMSTR"] = colorize("XSLT", "$TARGET", "blue")
+ env["XMLLINTCOMSTR"] = colorize("XMLLINT", "$SOURCE", "blue")
+ env["DOXYCOMSTR"] = colorize("DOXY", "$SOURCE", "blue")
+ #Progress(colorize("DEP", "$TARGET", "red")
def checkObjCHeader(context, header) :
- context.Message("Checking for Objective-C header " + header + " ... ")
- ret = context.TryCompile("#include <Cocoa/Cocoa.h>\n#include <" + header + ">", ".m")
- context.Result(ret)
- return ret
+ context.Message("Checking for Objective-C header " + header + " ... ")
+ ret = context.TryCompile("#include <Cocoa/Cocoa.h>\n#include <" + header + ">", ".m")
+ context.Result(ret)
+ return ret
+
+def checkForCpp11Support(context) :
+ context.Message('Checking whether the C++ compiler supports C++11... ')
+ result = context.TryLink(
+ """
+#include <memory>
+
+int main(int, char **) {
+ // shared_ptr test
+ std::shared_ptr<int> intPtr = std::make_shared<int>();
+
+ // unique_ptr test
+ std::unique_ptr<int> intPtrUnique = std::unique_ptr<int>(new int(1));
+
+ // auto test
+ auto otherIntPtr = intPtr;
+ std::shared_ptr<int> fooIntPtr = otherIntPtr;
+
+ // lambda test
+ auto someFunction = [](int i){ i = i * i; };
+ someFunction(2);
+
+ // nullptr test
+ double* fooDouble = nullptr;
+ double bazDouble = 8.0;
+ fooDouble = &bazDouble;
+ bazDouble = *fooDouble;
+
+ return 0;
+}
+""", '.cpp')
+ context.Result(result)
+ return result
+
################################################################################
# Platform configuration
################################################################################
if ARGUMENTS.get("force-configure", 0) :
- SCons.SConf.SetCacheMode("force")
+ SCons.SConf.SetCacheMode("force")
def CheckPKG(context, name):
- context.Message( 'Checking for package %s... ' % name )
- ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
- context.Result( ret )
- return ret
+ context.Message( 'Checking for package %s... ' % name )
+ ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
+ context.Result( ret )
+ return ret
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
+ 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("""
+ ret = context.TryRun("""
#include <%(header)s>
#include <stdio.h>
int main(int argc, char* argv[]) {
- printf("%%d\\n", %(define)s);
- return 0;
+ printf("%%d\\n", %(define)s);
+ return 0;
}
""" % { "header" : header, "define": define }, extension)
- if ret[0] :
- return int(ret[1])
- else :
- return -1
-
+ if ret[0] :
+ return int(ret[1])
+ else :
+ return -1
-conf = Configure(conf_env)
+conf = Configure(conf_env, custom_tests = {
+ 'CheckCpp11Support' : checkForCpp11Support,
+ })
if not conf.CheckCXX() or not conf.CheckCC() :
- print "Error: You need a working compiler"
- Exit(1)
+ 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"
+ 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
+ zlib_flags["LIBPATH"] = [env["zlib_libdir"]]
+ zlib_okay = True
if env.get("zlib_includedir", None) :
- zlib_flags["CPPPATH"] = [env["zlib_includedir"]]
- zlib_okay = True
+ 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
+ zlib_flags["LIBS"] = [File(env["zlib_libfile"])]
+ zlib_okay = True
elif zlib_okay :
- zlib_flags["LIBS"] = ["z"]
+ zlib_flags["LIBS"] = ["z"]
if (not zlib_okay) and conf.CheckLib("z") :
- zlib_flags["LIBS"] = ["z"]
- zlib_okay = True
+ zlib_flags["LIBS"] = ["z"]
+ zlib_okay = True
if zlib_okay :
- env["ZLIB_FLAGS"] = zlib_flags
+ 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)
+ print "Error: Zlib not found and zlib_bundled_enable is false"
+ Exit(1)
else :
- env["ZLIB_BUNDLED"] = True
+ env["ZLIB_BUNDLED"] = True
if conf.CheckLib("resolv") :
- env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["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"]
+ if conf.CheckLib("pthread") :
+ env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["pthread"]
if conf.CheckLib("dl") :
- env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["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"]
+ env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["m"]
if conf.CheckLib("c") :
- env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["c"]
+ env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["c"]
# 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++"]
+ 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"]]
+ boost_flags["LIBPATH"] = [env["boost_libdir"]]
if env.get("boost_includedir", None) :
- 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"])]
+ 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), ("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")]
+boostLibs = [(None, "signals2.hpp"), ("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, language='CXX') :
- libName += "-mt"
- if not conf.CheckLib(libName, language='CXX') :
- allLibsPresent = False
- break
- libNames.append(libName)
-if allLibsPresent :
- boost_flags["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"]
- 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"]
+ if header :
+ header = "boost/" + header
+ else :
+ header = "boost/" + lib + ".hpp"
+ if not conf.CheckCXXHeader(header) :
+ allLibsPresent = False
+ break
+ if lib and env["PLATFORM"] != "win32" :
+ libName = "boost_" + lib
+ if not conf.CheckLib(libName, language='CXX') :
+ libName += "-mt"
+ if not conf.CheckLib(libName, language='CXX') :
+ allLibsPresent = False
+ break
+ 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"
- Exit(1)
+ print "Error: Boost not found and boost_bundled_enable is false"
+ Exit(1)
else :
- env["BOOST_BUNDLED"] = True
+ env["BOOST_BUNDLED"] = True
conf.Finish()
# Xss
env["HAVE_XSS"] = 0
if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" :
- xss_flags = {
- "LIBPATH": ["/usr/X11R6/lib"],
- "LIBS": ["Xss"]
- }
- xss_env = conf_env.Clone()
- xss_env.MergeFlags(xss_flags)
- conf = Configure(xss_env)
- if conf.CheckFunc("XScreenSaverQueryExtension") :
- env["HAVE_XSS"] = 1
- env["XSS_FLAGS"] = xss_flags
- conf.Finish()
+ xss_flags = {
+ "LIBPATH": ["/usr/X11R6/lib"],
+ "LIBS": ["Xss"]
+ }
+ xss_env = conf_env.Clone()
+ 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.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"],
- "CPPDEFINES": gconf_bare_env.get("CPPDEFINES", []),
- }
- gconf_env.MergeFlags(gconf_flags)
- if conf.CheckCHeader("gconf/gconf-client.h") and conf.CheckLib("gconf-2") :
- env["HAVE_GCONF"] = 1
- env["GCONF_FLAGS"] = {
- "LIBS": gconf_env["LIBS"],
- "CCFLAGS": gconf_env["CCFLAGS"],
- "CPPPATH": gconf_env["CPPPATH"],
- "CPPDEFINES": gconf_env.get("CPPDEFINES", []),
- }
- conf.Finish()
+ 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"],
+ "CPPDEFINES": gconf_bare_env.get("CPPDEFINES", []),
+ }
+ gconf_env.MergeFlags(gconf_flags)
+ if conf.CheckCHeader("gconf/gconf-client.h") and conf.CheckLib("gconf-2") :
+ env["HAVE_GCONF"] = 1
+ env["GCONF_FLAGS"] = {
+ "LIBS": gconf_env["LIBS"],
+ "CCFLAGS": gconf_env["CCFLAGS"],
+ "CPPPATH": gconf_env["CPPPATH"],
+ "CPPDEFINES": gconf_env.get("CPPDEFINES", []),
+ }
+ conf.Finish()
# Sparkle
env["HAVE_SPARKLE"] = 0
if env["PLATFORM"] == "darwin" :
- sparkle_flags = {
- "FRAMEWORKPATH": ["/Library/Frameworks"],
- "FRAMEWORKS": ["Sparkle"]
- }
- sparkle_env = conf_env.Clone()
- sparkle_env.MergeFlags(sparkle_flags)
- conf = Configure(sparkle_env, custom_tests = { "CheckObjCHeader" : checkObjCHeader })
- if conf.CheckObjCHeader("Sparkle/Sparkle.h") :
- env["HAVE_SPARKLE"] = 1
- env["SPARKLE_FLAGS"] = sparkle_flags
- env["SPARKLE_FRAMEWORK"] = "/Library/Frameworks/Sparkle.framework"
- conf.Finish()
+ sparkle_flags = {
+ "FRAMEWORKPATH": ["3rdParty/Sparkle/Sparkle-1.14.0"],
+ "FRAMEWORKS": ["Sparkle"]
+ }
+ sparkle_env = conf_env.Clone()
+ sparkle_env.MergeFlags(sparkle_flags)
+ conf = Configure(sparkle_env, custom_tests = { "CheckObjCHeader" : checkObjCHeader })
+ if conf.CheckObjCHeader("Sparkle/Sparkle.h") :
+ env["HAVE_SPARKLE"] = 1
+ env["SPARKLE_FLAGS"] = sparkle_flags
+ env["SPARKLE_FRAMEWORK"] = Dir("../../3rdParty/Sparkle/Sparkle-1.14.0/Sparkle.framework")
+ conf.Finish()
+
+ if env.get("sparkle_public_dsa_key", None) != None :
+ env["SWIFT_SPARKLE_PUBLIC_DSA_KEY"] = File(env.get("sparkle_public_dsa_key"))
+ else :
+ env["SWIFT_SPARKLE_PUBLIC_DSA_KEY"] = None
# Growl
env["HAVE_GROWL"] = 0
if env["PLATFORM"] == "darwin" :
- growl_flags = {
- "FRAMEWORKPATH": ["/Library/Frameworks"],
- "FRAMEWORKS": ["Growl"]
- }
- growl_env = conf_env.Clone()
- growl_env.MergeFlags(growl_flags)
- conf = Configure(growl_env, custom_tests = { "CheckObjCHeader" : checkObjCHeader })
- if conf.CheckObjCHeader("Growl/Growl.h") :
- env["HAVE_GROWL"] = 1
- env["GROWL_FLAGS"] = growl_flags
- env["GROWL_FRAMEWORK"] = "/Library/Frameworks/Growl.framework"
- conf.Finish()
-
-# Snarl
-if env["PLATFORM"] == "win32" :
- env["HAVE_SNARL"] = True
+ growl_flags = {
+ "FRAMEWORKPATH": ["/Library/Frameworks"],
+ "FRAMEWORKS": ["Growl"]
+ }
+ growl_env = conf_env.Clone()
+ growl_env.MergeFlags(growl_flags)
+ conf = Configure(growl_env, custom_tests = { "CheckObjCHeader" : checkObjCHeader })
+ if conf.CheckObjCHeader("Growl/Growl.h") :
+ env["HAVE_GROWL"] = 1
+ env["GROWL_FLAGS"] = growl_flags
+ env["GROWL_FRAMEWORK"] = "/Library/Frameworks/Growl.framework"
+ conf.Finish()
# LibXML
conf = Configure(conf_env, custom_tests = {"CheckVersion": CheckVersion})
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"] }
+ env["HAVE_LIBXML"] = 1
+ env["LIBXML_FLAGS"] = { "LIBS": ["xml2"] }
conf.Finish()
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
- libxml_env.Append()
- if os.path.basename(env["CC"]) in ("clang", "gcc"):
- env["LIBXML_FLAGS"] = { "CXXFLAGS": ["-isystem/usr/include/libxml2"], "LIBS": ["xml2"] }
- else:
- env["LIBXML_FLAGS"] = { "CPPPATH": ["/usr/include/libxml2"], "LIBS": ["xml2"] }
- conf.Finish()
+ 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
+ libxml_env.Append()
+ if os.path.basename(env["CC"]) in ("clang", "gcc"):
+ env["LIBXML_FLAGS"] = { "CXXFLAGS": ["-isystem/usr/include/libxml2"], "LIBS": ["xml2"] }
+ else:
+ env["LIBXML_FLAGS"] = { "CPPPATH": ["/usr/include/libxml2"], "LIBS": ["xml2"] }
+ conf.Finish()
# Expat
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"]) :
- env["HAVE_EXPAT"] = 1
- env["EXPAT_FLAGS"] = { "LIBS": [env["expat_libname"]] }
- env["EXPAT_FLAGS"].update(expat_flags)
- conf.Finish()
+ 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"]) :
+ 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"
- SConscript("#/3rdParty/Expat/SConscript")
- env["HAVE_EXPAT"] = 1
- env["EXPAT_BUNDLED"] = True
+ print "Expat or LibXML not found. Using bundled Expat"
+ SConscript("#/3rdParty/Expat/SConscript")
+ env["HAVE_EXPAT"] = 1
+ env["EXPAT_BUNDLED"] = True
################################################################################
# IDN library
@@ -340,292 +379,294 @@ icu_env = conf_env.Clone()
use_icu = bool(env["icu"])
icu_prefix = ""
if isinstance(env["icu"], str) :
- icu_prefix = env["icu"]
+ 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_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
- env["ICU_FLAGS"] = icu_flags
- env["ICU_FLAGS"]["LIBS"] = ["icuuc"]
+ env["HAVE_ICU"] = 1
+ env["ICU_FLAGS"] = icu_flags
+ env["ICU_FLAGS"]["LIBS"] = ["icuuc"]
icu_conf.Finish()
# LibIDN
libidn_conf_env = conf_env.Clone()
libidn_flags = {}
if env.get("libidn_libdir", None) :
- libidn_flags["LIBPATH"] = [env["libidn_libdir"]]
+ libidn_flags["LIBPATH"] = [env["libidn_libdir"]]
if env.get("libidn_includedir", None) :
- libidn_flags["CPPPATH"] = [env["libidn_includedir"]]
+ libidn_flags["CPPPATH"] = [env["libidn_includedir"]]
libidn_conf_env.MergeFlags(libidn_flags)
conf = Configure(libidn_conf_env)
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)
+ 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) :
- 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"
- Exit(1)
- else:
- print "Proceeding without an IDN library because need_idn was false. This will break all internal binaries"
+ 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"
+ Exit(1)
+ else:
+ 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
+ env["LDNS_BUNDLED"] = 1
+ env["UNBOUND_BUNDLED"] = 1
else :
- env["LDNS_FLAGS"] = {}
- env["UNBOUND_FLAGS"] = {}
+ env["LDNS_FLAGS"] = {}
+ env["UNBOUND_FLAGS"] = {}
# LibMiniUPnPc
if env["experimental_ft"] :
- 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"]) :
- env["HAVE_LIBMINIUPNPC"] = 1
- env["LIBMINIUPNPC_FLAGS"] = { "LIBS": ["miniupnpc"] }
- env["LIBMINIUPNPC_FLAGS"].update(libminiupnpc_flags)
- 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 not env.get("libminiupnpc_force_bundled") and conf.CheckCHeader("miniupnpc.h") and conf.CheckLib(env["libminiupnpc_libname"]) :
+ 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"] = {}
+ env["LIBMINIUPNPC_FLAGS"] = {}
# LibNATPMP
if env["experimental_ft"] :
- 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"]) :
- env["HAVE_LIBNATPMP"] = 1
- env["LIBNATPMP_FLAGS"] = { "LIBS": ["natpmp"] }
- env["LIBNATPMP_FLAGS"].update(libnatpmp_flags)
- 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 not env.get("libnatpmp_force_bundled") and conf.CheckCHeader("natpmp.h") and conf.CheckLib(env["libnatpmp_libname"]) :
+ 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"] = {}
+ env["LIBNATPMP_FLAGS"] = {}
# SQLite
if env["experimental"] :
- sqlite_conf_env = conf_env.Clone()
- sqlite_flags = {}
- if env.get("sqlite_libdir", None) :
- sqlite_flags["LIBPATH"] = [env["sqlite_libdir"]]
- if env.get("sqlite_includedir", None) :
- sqlite_flags["CPPPATH"] = [env["sqlite_includedir"]]
- sqlite_conf_env.MergeFlags(sqlite_flags)
- conf = Configure(sqlite_conf_env)
- if conf.CheckCHeader("sqlite3.h") and conf.CheckLib(env["sqlite_libname"]) and not env.get("sqlite_force_bundled", False):
- env["HAVE_SQLITE"] = 1
- env["SQLITE_FLAGS"] = { "LIBS": [env["sqlite_libname"]] }
- env["SQLITE_FLAGS"].update(sqlite_flags)
- else :
- env["SQLITE_BUNDLED"] = 1
- conf.Finish()
+ sqlite_conf_env = conf_env.Clone()
+ sqlite_flags = {}
+ if env.get("sqlite_libdir", None) :
+ sqlite_flags["LIBPATH"] = [env["sqlite_libdir"]]
+ if env.get("sqlite_includedir", None) :
+ sqlite_flags["CPPPATH"] = [env["sqlite_includedir"]]
+ sqlite_conf_env.MergeFlags(sqlite_flags)
+ conf = Configure(sqlite_conf_env)
+ if conf.CheckCHeader("sqlite3.h") and conf.CheckLib(env["sqlite_libname"]) and not env.get("sqlite_force_bundled", False):
+ env["HAVE_SQLITE"] = 1
+ env["SQLITE_FLAGS"] = { "LIBS": [env["sqlite_libname"]] }
+ env["SQLITE_FLAGS"].update(sqlite_flags)
+ else :
+ env["SQLITE_BUNDLED"] = 1
+ conf.Finish()
else :
- env["SQLITE_FLAGS"] = {}
+ env["SQLITE_FLAGS"] = {}
# Lua
lua_conf_env = conf_env.Clone()
lua_flags = {}
if env.get("lua_libdir", None) :
- lua_flags["LIBPATH"] = [env["lua_libdir"]]
+ lua_flags["LIBPATH"] = [env["lua_libdir"]]
if env.get("lua_includedir", None) :
- lua_flags["CPPPATH"] = [env["lua_includedir"]]
+ 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.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."
- env["LUA_FLAGS"].update(lua_flags)
+ 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
+ env["LUA_BUNDLED"] = 1
conf.Finish()
# Readline
editline_conf_env = conf_env.Clone()
editline_flags = {}
if env.get("editline_libdir", None) :
- editline_flags["LIBPATH"] = [env["editline_libdir"]]
+ editline_flags["LIBPATH"] = [env["editline_libdir"]]
if env.get("editline_includedir", None) :
- editline_flags["CPPPATH"] = [env["editline_includedir"]]
+ editline_flags["CPPPATH"] = [env["editline_includedir"]]
editline_conf_env.MergeFlags(editline_flags)
conf = Configure(editline_conf_env)
if conf.CheckLibWithHeader(env["editline_libname"], ["stdio.h", "editline/readline.h"], "c") :
- env["HAVE_EDITLINE"] = 1
- env["EDITLINE_FLAGS"] = { "LIBS": [env["editline_libname"]] }
- env["EDITLINE_FLAGS"].update(editline_flags)
+ env["HAVE_EDITLINE"] = 1
+ env["EDITLINE_FLAGS"] = { "LIBS": [env["editline_libname"]] }
+ env["EDITLINE_FLAGS"].update(editline_flags)
conf.Finish()
# Avahi
avahi_conf_env = conf_env.Clone()
avahi_flags = {}
if env.get("avahi_libdir", None) :
- avahi_flags["LIBPATH"] = [env["avahi_libdir"]]
+ avahi_flags["LIBPATH"] = [env["avahi_libdir"]]
if env.get("avahi_includedir", None) :
- avahi_flags["CPPPATH"] = [env["avahi_includedir"]]
+ avahi_flags["CPPPATH"] = [env["avahi_includedir"]]
avahi_conf_env.MergeFlags(avahi_flags)
conf = Configure(avahi_conf_env)
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)
+ 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"]
+ env["QTDIR"] = env["qt"]
-# Check for OS X Secure Transport
-if not env.get("openssl_force_bundled", False) and env["PLATFORM"] == "darwin" and env["target"] == "native" :
- env["HAVE_SECURETRANSPORT"] = True
-else :
- env["HAVE_SECURETRANSPORT"] = False
+################################################################################
+# 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":
+ env["HAVE_SECURETRANSPORT"] = True
+ elif env["target"] in ("iphone-device", "iphone-simulator", "xcode", "android") :
+ env["tls_backend"] = "openssl_bundled"
+ else :
+ env["tls_backend"] = "openssl"
# 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
-elif not env["HAVE_SECURETRANSPORT"] :
- 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", 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
- 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 we're compiling for Windows and OpenSSL isn't being used, use Schannel
- env["HAVE_SCHANNEL"] = True
-
- openssl_conf.Finish()
+if env.get("tls_backend") == "openssl_bundled" :
+ env["OPENSSL_BUNDLED"] = True
+ env["HAVE_OPENSSL"] = True
+elif env.get("tls_backend") == "openssl" :
+ openssl_env = conf_env.Clone()
+ 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]}
+ 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
+ openssl_libnames = env.get("openssl_libnames")
+ 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"]
+ openssl_conf.Finish()
if env["PLATFORM"] == "win32" :
- # On Windows link to secur32. It is needed by Swiften/SASL/WindowsAuthentication
- env.Append(LIBS = ["secur32"])
+ # On Windows link to secur32. It is needed by Swiften/SASL/WindowsAuthentication
+ env.Append(LIBS = ["secur32"])
#Hunspell
hunspell_env = conf_env.Clone()
hunspell_prefix = isinstance(env.get("hunspell_prefix", False), str) and env["hunspell_prefix"] or ""
hunspell_flags = {}
if hunspell_prefix :
- hunspell_flags = {"CPPPATH":[os.path.join(hunspell_prefix, "include")], "LIBPATH":[os.path.join(hunspell_prefix, "lib")]}
+ 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;
if env.get("hunspell_enable", False) :
- 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()
+ 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" and env["target"] == "native" :
- env["HAVE_BONJOUR"] = 1
+ 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 :
- 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()
+ bonjour_env = conf_env.Clone()
+ bonjour_conf = Configure(bonjour_env)
+ bonjour_flags = {}
+ 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()
# Cocoa & IOKit
if env["PLATFORM"] == "darwin" :
- cocoa_conf = Configure(conf_env)
- if cocoa_conf.CheckCHeader("IOKit/IOKitLib.h") :
- env["HAVE_IOKIT"] = True
- cocoa_conf.Finish()
+ cocoa_conf = Configure(conf_env)
+ if cocoa_conf.CheckCHeader("IOKit/IOKitLib.h") :
+ env["HAVE_IOKIT"] = True
+ cocoa_conf.Finish()
# Qt
try :
- myenv = env.Clone()
- myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
- env["HAVE_QT"] = True
+ myenv = env.Clone()
+ myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
+ env["HAVE_QT"] = True
except SCons.Errors.StopError:
- env["HAVE_QT"] = False
+ env["HAVE_QT"] = False
except Exception as e:
- print "Info: %s" % str(e)
- env["HAVE_QT"] = False
+ print "Info: %s" % str(e)
+ env["HAVE_QT"] = False
################################################################################
# DocBook setup
################################################################################
if env.get("docbook_xml") :
- env["DOCBOOK_XML_DIR"] = env["docbook_xml"]
+ env["DOCBOOK_XML_DIR"] = env["docbook_xml"]
if env.get("docbook_xsl") :
- env["DOCBOOK_XSL_DIR"] = env["docbook_xsl"]
+ env["DOCBOOK_XSL_DIR"] = env["docbook_xsl"]
################################################################################
@@ -633,11 +674,11 @@ if env.get("docbook_xsl") :
################################################################################
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/*"))
+ 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."
################################################################################
@@ -645,23 +686,23 @@ except TypeError:
################################################################################
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) :
- 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"])
+ 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) :
+ 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 :
- env.Append(CPPPATH = [root])
+ env.Append(CPPPATH = [root])
################################################################################
@@ -669,29 +710,29 @@ else :
################################################################################
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)
+ 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) :
- 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("#/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) :
- continue
- sconscript = os.path.join(full_dir, "SConscript")
- if os.path.isfile(sconscript) :
- modules.append(dir)
+ 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")
@@ -700,13 +741,13 @@ 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))
+ env["SCONS_STAGE"] = stage
+ SConscript(dirs = map(lambda x : root + "/" + x, modules))
# SLOCCount
if ARGUMENTS.get("sloccount", False) :
- for project in env["PROJECTS"] :
- env.SLOCCount("#/" + project)
+ for project in env["PROJECTS"] :
+ env.SLOCCount("#/" + project)
################################################################################
@@ -719,11 +760,11 @@ print " -------------------"
parsers = []
if env.get("HAVE_LIBXML", 0):
- parsers.append("LibXML")
+ parsers.append("LibXML")
if env.get("HAVE_EXPAT", 0):
- parsers.append("Expat")
- if env.get("EXPAT_BUNDLED", False) :
- parsers.append("(Bundled)")
+ parsers.append("Expat")
+ if env.get("EXPAT_BUNDLED", False) :
+ parsers.append("(Bundled)")
print " Projects: " + ' '.join(env["PROJECTS"])
print ""
print " XML Parsers: " + ' '.join(parsers)
@@ -731,3 +772,8 @@ 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
+
+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."
+ Exit(1)
+
diff --git a/BuildTools/SCons/Tools/AppBundle.py b/BuildTools/SCons/Tools/AppBundle.py
index f1072f5..337e83f 100644
--- a/BuildTools/SCons/Tools/AppBundle.py
+++ b/BuildTools/SCons/Tools/AppBundle.py
@@ -1,64 +1,72 @@
import SCons.Util, os.path
+from datetime import date
def generate(env) :
- def createAppBundle(env, bundle, version = "1.0", resources = [], frameworks = [], info = {}, handlesXMPPURIs = False) :
- bundleDir = bundle + ".app"
- bundleContentsDir = bundleDir + "/Contents"
- resourcesDir = bundleContentsDir + "/Resources"
- frameworksDir = bundleContentsDir + "/Frameworks"
- env.Install(bundleContentsDir + "/MacOS", bundle)
- env.WriteVal(bundleContentsDir + "/PkgInfo", env.Value("APPL\77\77\77\77"))
+ def createAppBundle(env, bundle, version = "1.0", resources = [], frameworks = [], info = {}, handlesXMPPURIs = False, sparklePublicDSAKey = None) :
+ env.Tool("InstallWithSymLinks", toolpath = ["#/BuildTools/SCons/Tools"])
- infoDict = {
- "CFBundleDevelopmentRegion" : "English",
- "CFBundleExecutable" : bundle,
- "CFBundleIdentifier" : "im.swift." + bundle,
- "CFBundleInfoDictionaryVersion" : "6.0",
- "CFBundleName" : bundle,
- "CFBundlePackageType" : "APPL",
- "CFBundleSignature": "\77\77\77\77",
- "CFBundleVersion" : version,
- "CFBundleIconFile" : bundle,
- "NSPrincipalClass" : "NSApplication",
- "NSHumanReadableCopyright" : unichr(0xA9) + " 2010 Swift Development Team.\nAll Rights Reserved."
- }
- infoDict.update(info)
+ bundleDir = bundle + ".app"
+ bundleContentsDir = bundleDir + "/Contents"
+ resourcesDir = bundleContentsDir + "/Resources"
+ frameworksDir = bundleContentsDir + "/Frameworks"
+ env.Install(bundleContentsDir + "/MacOS", bundle)
+ env.WriteVal(bundleContentsDir + "/PkgInfo", env.Value("APPL\77\77\77\77"))
- plist = """<?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- """
- for key, value in infoDict.items() :
- plist += "<key>" + key + "</key>\n"
- plist += "<string>" + value.encode("utf-8") + "</string>\n"
- if handlesXMPPURIs :
- plist += """<key>CFBundleURLTypes</key>
+ infoDict = {
+ "CFBundleDevelopmentRegion" : "English",
+ "CFBundleExecutable" : bundle,
+ "CFBundleIdentifier" : "im.swift." + bundle,
+ "CFBundleInfoDictionaryVersion" : "6.0",
+ "CFBundleName" : bundle,
+ "CFBundlePackageType" : "APPL",
+ "CFBundleSignature": "\77\77\77\77",
+ "CFBundleVersion" : version,
+ "CFBundleIconFile" : bundle,
+ "NSPrincipalClass" : "NSApplication",
+ "NSHumanReadableCopyright" : "(c) 2010-%d Isode Ltd.\nAll Rights Reserved." % date.today().year
+ }
+ infoDict.update(info)
+
+ plist = """<?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ """
+ for key, value in infoDict.items() :
+ plist += "<key>" + key + "</key>\n"
+ plist += "<string>" + value.encode("utf-8") + "</string>\n"
+ if handlesXMPPURIs :
+ plist += """<key>CFBundleURLTypes</key>
<array>
- <dict>
- <key>CFBundleURLName</key>
- <string>XMPP URL</string>
- <key>CFBundleURLSchemes</key>
- <array>
- <string>xmpp</string>
- </array>
- </dict>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>XMPP URL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>xmpp</string>
+ </array>
+ </dict>
</array>\n"""
- plist += """</dict>
- </plist>
- """
- env.WriteVal(bundleContentsDir + "/Info.plist", env.Value(plist))
- for (target, resource) in resources.items() :
- env.Install(os.path.join(resourcesDir, target), resource)
+ if sparklePublicDSAKey :
+ plist += "<key>SUPublicDSAKeyFile</key>"
+ plist += "<string>" + sparklePublicDSAKey.name.encode("utf-8") + "</string>"
+ env.Install(resourcesDir, sparklePublicDSAKey)
+ plist += """</dict>
+ </plist>
+ """
+ env.WriteVal(bundleContentsDir + "/Info.plist", env.Value(plist))
+
+ for (target, resource) in resources.items() :
+ env.Install(os.path.join(resourcesDir, target), resource)
- for framework in frameworks :
- env.Install(frameworksDir, framework)
+ for framework in frameworks :
+ env.InstallWithSymLinks(frameworksDir, framework)
- return env.Dir(bundleDir)
+ return env.Dir(bundleDir)
- env.AddMethod(createAppBundle, "AppBundle")
+ env.AddMethod(createAppBundle, "AppBundle")
def exists(env) :
- return env["PLATFORM"] == "darwin"
+ return env["PLATFORM"] == "darwin"
diff --git a/BuildTools/SCons/Tools/BuildVersion.py b/BuildTools/SCons/Tools/BuildVersion.py
index b15448a..7968282 100644
--- a/BuildTools/SCons/Tools/BuildVersion.py
+++ b/BuildTools/SCons/Tools/BuildVersion.py
@@ -3,16 +3,16 @@ import SCons.Util
import Version
def generate(env) :
- def createBuildVersion(env, target, project) :
- buildVersion = """#pragma once
+ def createBuildVersion(env, target, project) :
+ buildVersion = """#pragma once
static const char* buildVersion = \"%(buildVersion)s\";\n
#define SWIFT_VERSION_STRING \"%(buildVersion)s\";\n
""" % { "buildVersion" : Version.getBuildVersion(env.Dir("#").abspath, project) }
- env.WriteVal(target, env.Value(buildVersion))
+ env.WriteVal(target, env.Value(buildVersion))
- env.AddMethod(createBuildVersion, "BuildVersion")
+ env.AddMethod(createBuildVersion, "BuildVersion")
def exists(env) :
- return true
+ return true
diff --git a/BuildTools/SCons/Tools/DoxyGen.py b/BuildTools/SCons/Tools/DoxyGen.py
index 79af1c9..66a9111 100644
--- a/BuildTools/SCons/Tools/DoxyGen.py
+++ b/BuildTools/SCons/Tools/DoxyGen.py
@@ -1,26 +1,26 @@
import SCons.Util, os
def generate(env) :
- def modify_targets(target, source, env) :
- target = [env.File("html/index.html")]
- return target, source
+ def modify_targets(target, source, env) :
+ target = [env.File("html/index.html")]
+ return target, source
- def generate_actions(source, target, env, for_signature) :
- if env.WhereIs("$DOXYGEN") and env.WhereIs("$DOT") :
- return [SCons.Action.Action("$DOXYGEN $SOURCE", cmdstr = "$DOXYCOMSTR")]
- else :
- return []
+ def generate_actions(source, target, env, for_signature) :
+ if env.WhereIs("$DOXYGEN") and env.WhereIs("$DOT") :
+ return [SCons.Action.Action("$DOXYGEN $SOURCE", cmdstr = "$DOXYCOMSTR")]
+ else :
+ return []
- env["DOXYGEN"] = "doxygen"
- # FIXME: For some reason, things go incredibly slow (at least on OS X)
- # when not doing this. Some environment flag is having an effect on
- # this; find out which
- env["ENV"] = os.environ
- env["DOT"] = "dot"
- env["BUILDERS"]["DoxyGen"] = SCons.Builder.Builder(
- emitter = modify_targets,
- generator = generate_actions,
- single_source = True)
+ env["DOXYGEN"] = "doxygen"
+ # FIXME: For some reason, things go incredibly slow (at least on OS X)
+ # when not doing this. Some environment flag is having an effect on
+ # this; find out which
+ env["ENV"] = os.environ
+ env["DOT"] = "dot"
+ env["BUILDERS"]["DoxyGen"] = SCons.Builder.Builder(
+ emitter = modify_targets,
+ generator = generate_actions,
+ single_source = True)
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/Flags.py b/BuildTools/SCons/Tools/Flags.py
index 0768181..fe0cfcc 100644
--- a/BuildTools/SCons/Tools/Flags.py
+++ b/BuildTools/SCons/Tools/Flags.py
@@ -1,13 +1,13 @@
import SCons.Util
def generate(env) :
- def useFlags(env, flags) :
- for flag in flags :
- if flag in env :
- env[flag] = env[flag] + flags[flag]
- else :
- env[flag] = flags[flag]
- env.AddMethod(useFlags, "UseFlags")
+ def useFlags(env, flags) :
+ for flag in flags :
+ if flag in env :
+ env[flag] = env[flag] + flags[flag]
+ else :
+ env[flag] = flags[flag]
+ env.AddMethod(useFlags, "UseFlags")
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/InstallWithSymLinks.py b/BuildTools/SCons/Tools/InstallWithSymLinks.py
new file mode 100644
index 0000000..23d12ed
--- /dev/null
+++ b/BuildTools/SCons/Tools/InstallWithSymLinks.py
@@ -0,0 +1,114 @@
+"""SCons.Tool.install
+
+Tool-specific initialization for the install tool.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+"""
+
+#
+# Copyright (c) 2001 - 2015 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+from SCons.Script import Action, Builder
+from SCons.Node import FS
+import shutil
+import stat
+import os
+from os import path
+
+class CopytreeError(EnvironmentError):
+ pass
+
+# This is a patched version of shutil.copytree from python 2.5. It
+# doesn't fail if the dir exists, which regular copytree does
+# (annoyingly). Note the XXX comment in the docstring.
+def scons_copytree(src, dst, symlinks=False):
+ """Recursively copy a directory tree using copy2().
+
+ The destination directory must not already exist.
+ If exception(s) occur, an CopytreeError is raised with a list of reasons.
+
+ If the optional symlinks flag is true, symbolic links in the
+ source tree result in symbolic links in the destination tree; if
+ it is false, the contents of the files pointed to by symbolic
+ links are copied.
+
+ XXX Consider this example code rather than the ultimate tool.
+
+ """
+ names = os.listdir(src)
+ # garyo@genarts.com fix: check for dir before making dirs.
+ if not os.path.exists(dst):
+ os.makedirs(dst)
+ errors = []
+ for name in names:
+ srcname = os.path.join(src, name)
+ dstname = os.path.join(dst, name)
+ try:
+ if symlinks and os.path.islink(srcname):
+ linkto = os.readlink(srcname)
+ os.symlink(linkto, dstname)
+ elif os.path.isdir(srcname):
+ scons_copytree(srcname, dstname, symlinks)
+ else:
+ shutil.copy2(srcname, dstname)
+ # XXX What about devices, sockets etc.?
+ except (IOError, os.error), why:
+ errors.append((srcname, dstname, str(why)))
+ # catch the CopytreeError from the recursive copytree so that we can
+ # continue with other files
+ except CopytreeError, err:
+ errors.extend(err.args[0])
+ try:
+ shutil.copystat(src, dst)
+ except WindowsError:
+ # can't copy file access times on Windows
+ pass
+ except OSError, why:
+ errors.extend((src, dst, str(why)))
+ if errors:
+ raise CopytreeError, errors
+
+
+def symlinkBuilderImpl(target, source, env):
+ lnk = target[0].abspath
+ src = source[0].abspath
+ lnkdir,lnkname = path.split(lnk)
+ srcdir,srcname = path.split(src)
+
+ scons_copytree(src, os.path.join(lnk, srcname), True)
+
+ return None
+
+def symlinkBuilderPrinter(target, source, env):
+ lnk = path.basename(target[0].abspath)
+ src = path.basename(source[0].abspath)
+ return 'INSTALL PRESERVING SYMLINKS ' + target[0].get_internal_path()
+
+def generate(env) :
+ symlinkBuilder = Builder(action = Action(symlinkBuilderImpl, symlinkBuilderPrinter), target_factory = FS.Entry, source_factory = FS.Entry)
+ env.Append(BUILDERS = {'InstallWithSymLinks' : symlinkBuilder})
+
+def exists(env) :
+ return True \ No newline at end of file
diff --git a/BuildTools/SCons/Tools/Nib.py b/BuildTools/SCons/Tools/Nib.py
index 91eb064..cf5b0dc 100644
--- a/BuildTools/SCons/Tools/Nib.py
+++ b/BuildTools/SCons/Tools/Nib.py
@@ -1,12 +1,12 @@
import SCons.Util
def generate(env) :
- env["IBTOOL"] = "ibtool"
- env["BUILDERS"]["Nib"] = SCons.Builder.Builder(
- action = SCons.Action.Action("$IBTOOL --errors --warnings --notices --output-format human-readable-text --compile $TARGET $SOURCE", cmdstr = "$NIBCOMSTR"),
- suffix = ".nib",
- src_suffix = ".xib",
- single_source = True)
+ env["IBTOOL"] = "ibtool"
+ env["BUILDERS"]["Nib"] = SCons.Builder.Builder(
+ action = SCons.Action.Action("$IBTOOL --errors --warnings --notices --output-format human-readable-text --compile $TARGET $SOURCE", cmdstr = "$NIBCOMSTR"),
+ suffix = ".nib",
+ src_suffix = ".xib",
+ single_source = True)
def exists(env) :
- return env["PLATFORM"] == "darwin"
+ return env["PLATFORM"] == "darwin"
diff --git a/BuildTools/SCons/Tools/ReplacePragmaOnce.py b/BuildTools/SCons/Tools/ReplacePragmaOnce.py
index 3df0f41..cb49bbb 100644
--- a/BuildTools/SCons/Tools/ReplacePragmaOnce.py
+++ b/BuildTools/SCons/Tools/ReplacePragmaOnce.py
@@ -1,25 +1,25 @@
import SCons.Util, os.path
def generate(env) :
- root = env.Dir("#").abspath
- def relpath(path, start) :
- i = len(os.path.commonprefix([path, start]))
- return path[i+1:]
+ root = env.Dir("#").abspath
+ def relpath(path, start) :
+ i = len(os.path.commonprefix([path, start]))
+ return path[i+1:]
- def replacePragmaOnce(env, target, source) :
- guard = relpath(source[0].abspath, root).replace("/", "_").replace(".", "_").upper()
- data = source[0].get_contents()
- f = open(str(target[0]), 'wb')
- if "#pragma once" in data :
- f.write(data.replace("#pragma once", "#ifndef %(guard)s\n#define %(guard)s" % {"guard": guard}))
- f.write("\n#endif\n")
- else :
- f.write(data)
- f.close()
+ def replacePragmaOnce(env, target, source) :
+ guard = relpath(source[0].abspath, root).replace("/", "_").replace(".", "_").upper()
+ data = source[0].get_contents()
+ f = open(str(target[0]), 'wb')
+ if "#pragma once" in data :
+ f.write(data.replace("#pragma once", "#ifndef %(guard)s\n#define %(guard)s" % {"guard": guard}))
+ f.write("\n#endif\n")
+ else :
+ f.write(data)
+ f.close()
- env["BUILDERS"]["ReplacePragmaOnce"] = SCons.Builder.Builder(
- action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
- single_source = True)
+ env["BUILDERS"]["ReplacePragmaOnce"] = SCons.Builder.Builder(
+ action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
+ single_source = True)
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/SLOCCount.py b/BuildTools/SCons/Tools/SLOCCount.py
index 682a797..be31672 100644
--- a/BuildTools/SCons/Tools/SLOCCount.py
+++ b/BuildTools/SCons/Tools/SLOCCount.py
@@ -1,17 +1,17 @@
import SCons.Util, os.path, os
def generate(env) :
- def createSLOCCount(env, source) :
- myenv = env.Clone()
- myenv["ENV"]["HOME"] = os.environ["HOME"]
- source = myenv.Dir(source)
- target = myenv.File("#/" + source.path + ".sloccount")
- # FIXME: There's probably a better way to force building the .sc
- if os.path.exists(target.abspath) :
- os.unlink(target.abspath)
- return myenv.Command(target, source, [SCons.Action.Action("sloccount --duplicates --wide --details " + source.path + " | grep -v qrc_ > $TARGET", cmdstr = "$GENCOMSTR")])
+ def createSLOCCount(env, source) :
+ myenv = env.Clone()
+ myenv["ENV"]["HOME"] = os.environ["HOME"]
+ source = myenv.Dir(source)
+ target = myenv.File("#/" + source.path + ".sloccount")
+ # FIXME: There's probably a better way to force building the .sc
+ if os.path.exists(target.abspath) :
+ os.unlink(target.abspath)
+ return myenv.Command(target, source, [SCons.Action.Action("sloccount --duplicates --wide --details " + source.path + " | grep -v qrc_ > $TARGET", cmdstr = "$GENCOMSTR")])
- env.AddMethod(createSLOCCount, "SLOCCount")
+ env.AddMethod(createSLOCCount, "SLOCCount")
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py
index 1eee4f6..72acb22 100644
--- a/BuildTools/SCons/Tools/Test.py
+++ b/BuildTools/SCons/Tools/Test.py
@@ -1,53 +1,53 @@
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 :
- 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", "ASAN_OPTIONS", "LSAN_OPTIONS", "SWIFT_NETWORK_TEST_IPV4", "SWIFT_NETWORK_TEST_IPV6"]:
- if os.environ.get(i, "") :
- test_env["ENV"][i] = os.environ[i]
- 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
- 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) :
- if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type :
- pass
-
- env.AddMethod(registerTest, "Test")
- env.AddMethod(registerScriptTests, "ScriptTests")
+ def registerTest(env, target, type = "unit", is_checker = False) :
+ if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type :
+ 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", "ASAN_OPTIONS", "LSAN_OPTIONS", "SWIFT_NETWORK_TEST_IPV4", "SWIFT_NETWORK_TEST_IPV6"]:
+ if os.environ.get(i, "") :
+ test_env["ENV"][i] = os.environ[i]
+ 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
+ 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) :
+ if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type :
+ pass
+
+ env.AddMethod(registerTest, "Test")
+ env.AddMethod(registerScriptTests, "ScriptTests")
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/WindowsBundle.py b/BuildTools/SCons/Tools/WindowsBundle.py
index ef77acb..20d41ff 100644
--- a/BuildTools/SCons/Tools/WindowsBundle.py
+++ b/BuildTools/SCons/Tools/WindowsBundle.py
@@ -4,119 +4,119 @@ import re
import shutil
def which(program_name):
- if hasattr(shutil, "which"):
- return shutil.which(program_name)
- else:
- path = os.getenv('PATH')
- for p in path.split(os.path.pathsep):
- p = os.path.join(p,program_name)
- if os.path.exists(p) and os.access(p,os.X_OK):
- return p
+ if hasattr(shutil, "which"):
+ return shutil.which(program_name)
+ else:
+ path = os.getenv('PATH')
+ for p in path.split(os.path.pathsep):
+ p = os.path.join(p,program_name)
+ if os.path.exists(p) and os.access(p,os.X_OK):
+ return p
def generate(env) :
- def captureWinDeployQtMapping(release = True):
- p = False
-
- qt_bin_folder = ""
- if "QTDIR" in env:
- qt_bin_folder = env["QTDIR"] + "\\bin;"
-
- environ = {"PATH": qt_bin_folder + os.getenv("PATH"), "TEMP": os.getenv("TEMP"), "TMP": os.getenv("TMP")}
-
- if release:
- p = subprocess.Popen(['windeployqt', '--release', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ)
- else:
- p = subprocess.Popen(['windeployqt', '--debug', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ)
-
- if p:
- stdout, stderr = p.communicate()
-
- mappings = []
-
- p = re.compile(ur'"([^\"]*)" "([^\"]*)"')
-
- matches = re.findall(p, stdout)
- for match in matches:
- mappings.append(match)
- return mappings
- else:
- return False
-
- def createWindowsBundleManual(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"))
- 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 :
- e = env.Entry(resource)
- if e.isdir() :
- for subresource in env.Glob(str(e) + "/*") :
- all_files += env.Install(os.path.join(bundle, dir, e.name), subresource)
- else :
- all_files += env.Install(os.path.join(bundle, dir), resource)
- return all_files
-
- # This version of uses windeployqt tool
- def createWindowsBundleWithWinDeployQt(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4') :
- assert(qtversion == '5')
- all_files = []
-
- # add swift executable
- all_files += env.Install(bundle, bundle + ".exe")
-
- # adding resources (swift sounds/images/translations)
- for dir, resourceFiles in resources.items() :
- for resource in resourceFiles :
- e = env.Entry(resource)
- if e.isdir() :
- for subresource in env.Glob(str(e) + "/*") :
- all_files += env.Install(os.path.join(bundle, dir, e.name), subresource)
- else :
- all_files += env.Install(os.path.join(bundle, dir), resource)
-
- qtmappings = captureWinDeployQtMapping()
- assert(qtmappings)
-
- # handle core DLLs
- qt_corelib_regex = re.compile(ur".*bin.*\\(.*)\.dll")
-
- for qtlib in qtlibs:
- if qtlib.startswith("Qt5"):
- (src_path, target_path) = next(((src_path, target_path) for (src_path, target_path) in qtmappings if qt_corelib_regex.match(src_path) and qt_corelib_regex.match(src_path).group(1) == qtlib), (None, None))
- if src_path != None:
- all_files += env.Install(bundle, src_path)
-
- # handle core dependencies
- for (src_path, target_path) in qtmappings:
- if qt_corelib_regex.match(src_path) and not qt_corelib_regex.match(src_path).group(1).startswith("Qt5"):
- all_files += env.Install(bundle, src_path)
-
- # handle plugins
- qt_plugin_regex = re.compile(ur".*plugins.*\\(.*)\\(.*)\.dll")
- for (src_path, target_path) in qtmappings:
- if qt_plugin_regex.match(src_path):
- plugin_folder, filename = qt_plugin_regex.match(src_path).groups()
- try:
- if plugin_folder in ["audio"] or filename[1:] in qtplugins[plugin_folder]:
- all_files += env.Install(os.path.join(bundle, plugin_folder), src_path)
- except:
- pass
- return all_files
-
- def createWindowsBundle(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4'):
- if which("windeployqt.exe"):
- return createWindowsBundleWithWinDeployQt(env, bundle, resources, qtplugins, qtlibs, qtversion)
- else:
- return createWindowsBundleManual(env, bundle, resources, qtplugins, qtlibs, qtversion)
-
- env.AddMethod(createWindowsBundle, "WindowsBundle")
+ def captureWinDeployQtMapping(release = True):
+ p = False
+
+ qt_bin_folder = ""
+ if "QTDIR" in env:
+ qt_bin_folder = env["QTDIR"] + "\\bin;"
+
+ environ = {"PATH": qt_bin_folder + os.getenv("PATH"), "TEMP": os.getenv("TEMP"), "TMP": os.getenv("TMP")}
+
+ if release:
+ p = subprocess.Popen(['windeployqt', '--release', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ)
+ else:
+ p = subprocess.Popen(['windeployqt', '--debug', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ)
+
+ if p:
+ stdout, stderr = p.communicate()
+
+ mappings = []
+
+ p = re.compile(ur'"([^\"]*)" "([^\"]*)"')
+
+ matches = re.findall(p, stdout)
+ for match in matches:
+ mappings.append(match)
+ return mappings
+ else:
+ return False
+
+ def createWindowsBundleManual(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"))
+ 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 :
+ e = env.Entry(resource)
+ if e.isdir() :
+ for subresource in env.Glob(str(e) + "/*") :
+ all_files += env.Install(os.path.join(bundle, dir, e.name), subresource)
+ else :
+ all_files += env.Install(os.path.join(bundle, dir), resource)
+ return all_files
+
+ # This version of uses windeployqt tool
+ def createWindowsBundleWithWinDeployQt(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4') :
+ assert(qtversion == '5')
+ all_files = []
+
+ # add swift executable
+ all_files += env.Install(bundle, bundle + ".exe")
+
+ # adding resources (swift sounds/images/translations)
+ for dir, resourceFiles in resources.items() :
+ for resource in resourceFiles :
+ e = env.Entry(resource)
+ if e.isdir() :
+ for subresource in env.Glob(str(e) + "/*") :
+ all_files += env.Install(os.path.join(bundle, dir, e.name), subresource)
+ else :
+ all_files += env.Install(os.path.join(bundle, dir), resource)
+
+ qtmappings = captureWinDeployQtMapping()
+ assert(qtmappings)
+
+ # handle core DLLs
+ qt_corelib_regex = re.compile(ur".*bin.*\\(.*)\.dll")
+
+ for qtlib in qtlibs:
+ if qtlib.startswith("Qt5"):
+ (src_path, target_path) = next(((src_path, target_path) for (src_path, target_path) in qtmappings if qt_corelib_regex.match(src_path) and qt_corelib_regex.match(src_path).group(1) == qtlib), (None, None))
+ if src_path != None:
+ all_files += env.Install(bundle, src_path)
+
+ # handle core dependencies
+ for (src_path, target_path) in qtmappings:
+ if qt_corelib_regex.match(src_path) and not qt_corelib_regex.match(src_path).group(1).startswith("Qt5"):
+ all_files += env.Install(bundle, src_path)
+
+ # handle plugins
+ qt_plugin_regex = re.compile(ur".*plugins.*\\(.*)\\(.*)\.dll")
+ for (src_path, target_path) in qtmappings:
+ if qt_plugin_regex.match(src_path):
+ plugin_folder, filename = qt_plugin_regex.match(src_path).groups()
+ try:
+ if plugin_folder in ["audio"] or filename[1:] in qtplugins[plugin_folder]:
+ all_files += env.Install(os.path.join(bundle, plugin_folder), src_path)
+ except:
+ pass
+ return all_files
+
+ def createWindowsBundle(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4'):
+ if which("windeployqt.exe"):
+ return createWindowsBundleWithWinDeployQt(env, bundle, resources, qtplugins, qtlibs, qtversion)
+ else:
+ return createWindowsBundleManual(env, bundle, resources, qtplugins, qtlibs, qtversion)
+
+ env.AddMethod(createWindowsBundle, "WindowsBundle")
def exists(env) :
- return env["PLATFORM"] == "win32"
+ return env["PLATFORM"] == "win32"
diff --git a/BuildTools/SCons/Tools/WriteVal.py b/BuildTools/SCons/Tools/WriteVal.py
index 4e8d3bb..ad77a99 100644
--- a/BuildTools/SCons/Tools/WriteVal.py
+++ b/BuildTools/SCons/Tools/WriteVal.py
@@ -1,15 +1,15 @@
import SCons.Util
def generate(env) :
- def replacePragmaOnce(env, target, source) :
- f = open(str(target[0]), 'wb')
- f.write(source[0].get_contents())
- f.close()
+ def replacePragmaOnce(env, target, source) :
+ f = open(str(target[0]), 'wb')
+ f.write(source[0].get_contents())
+ f.close()
- env["BUILDERS"]["WriteVal"] = SCons.Builder.Builder(
- action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
- single_source = True)
+ env["BUILDERS"]["WriteVal"] = SCons.Builder.Builder(
+ action = SCons.Action.Action(replacePragmaOnce, cmdstr = "$GENCOMSTR"),
+ single_source = True)
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/nsis.py b/BuildTools/SCons/Tools/nsis.py
index f5b2905..393beb8 100644
--- a/BuildTools/SCons/Tools/nsis.py
+++ b/BuildTools/SCons/Tools/nsis.py
@@ -6,34 +6,34 @@ nsisIncludes_re = re.compile(r'^\s*!include (translations-\S*)', re.M)
"""
TODO:
- - Extract the target from the nsis file
- - When a target is provided use the output function
+ - Extract the target from the nsis file
+ - When a target is provided use the output function
"""
def generate(env) :
- """Add Builders and construction variables for qt to an Environment."""
- Builder = SCons.Builder.Builder
+ """Add Builders and construction variables for qt to an Environment."""
+ Builder = SCons.Builder.Builder
- env['NSIS_MAKENSIS'] = 'makensis'
- env['NSIS_OPTIONS'] = ["/V2"]
- def winToLocalReformat(path) :
- return os.path.join(*path.split("\\"))
- def scanNsisContent(node, env, path, arg):
- contents = node.get_contents()
- includes = nsisFiles_re.findall(contents) + nsisIncludes_re.findall(contents)
- includes = [ winToLocalReformat(include) for include in includes ]
- return filter(lambda x: x.rfind('*')==-1, includes)
- nsisscanner = env.Scanner(name = 'nsisfile',
- function = scanNsisContent,
- argument = None,
- skeys = ['.nsi'])
- nsisbuilder = Builder(
- action = SCons.Action.Action('$NSIS_MAKENSIS $NSIS_OPTIONS $SOURCE', cmdstr = '$NSISCOMSTR'),
- source_scanner = nsisscanner,
- single_source = True
- )
- env.Append( BUILDERS={'Nsis' : nsisbuilder} )
+ env['NSIS_MAKENSIS'] = 'makensis'
+ env['NSIS_OPTIONS'] = ["/V2"]
+ def winToLocalReformat(path) :
+ return os.path.join(*path.split("\\"))
+ def scanNsisContent(node, env, path, arg):
+ contents = node.get_contents()
+ includes = nsisFiles_re.findall(contents) + nsisIncludes_re.findall(contents)
+ includes = [ winToLocalReformat(include) for include in includes ]
+ return filter(lambda x: x.rfind('*')==-1, includes)
+ nsisscanner = env.Scanner(name = 'nsisfile',
+ function = scanNsisContent,
+ argument = None,
+ skeys = ['.nsi'])
+ nsisbuilder = Builder(
+ action = SCons.Action.Action('$NSIS_MAKENSIS $NSIS_OPTIONS $SOURCE', cmdstr = '$NSISCOMSTR'),
+ source_scanner = nsisscanner,
+ single_source = True
+ )
+ env.Append( BUILDERS={'Nsis' : nsisbuilder} )
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py
index ec33b97..b965e06 100644
--- a/BuildTools/SCons/Tools/qt4.py
+++ b/BuildTools/SCons/Tools/qt4.py
@@ -47,24 +47,24 @@ import SCons.Util
import SCons.SConf
class ToolQtWarning(SCons.Warnings.Warning):
- pass
+ pass
class GeneratedMocFileNotIncluded(ToolQtWarning):
- pass
+ pass
class QtdirNotFound(ToolQtWarning):
- pass
+ pass
SCons.Warnings.enableWarningClass(ToolQtWarning)
qrcinclude_re = re.compile(r'<file (alias=\"[^\"]*\")?>([^<]*)</file>', re.M)
def transformToWinePath(path) :
- return os.popen('winepath -w "%s"'%path).read().strip().replace('\\','/')
+ return os.popen('winepath -w "%s"'%path).read().strip().replace('\\','/')
header_extensions = [".h", ".hxx", ".hpp", ".hh"]
if SCons.Util.case_sensitive_suffixes('.h', '.H'):
- header_extensions.append('.H')
+ header_extensions.append('.H')
# TODO: The following two lines will work when integrated back to SCons
# TODO: Meanwhile the third line will do the work
#cplusplus = __import__('c++', globals(), locals(), [])
@@ -72,519 +72,522 @@ if SCons.Util.case_sensitive_suffixes('.h', '.H'):
cxx_suffixes = [".c", ".cxx", ".cpp", ".cc"]
def checkMocIncluded(target, source, env):
- moc = target[0]
- cpp = source[0]
- # looks like cpp.includes is cleared before the build stage :-(
- # not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
- path = SCons.Defaults.CScan.path_function(env, moc.cwd)
- includes = SCons.Defaults.CScan(cpp, env, path)
- if not moc in includes:
- SCons.Warnings.warn(
- GeneratedMocFileNotIncluded,
- "Generated moc file '%s' is not included by '%s'" %
- (str(moc), str(cpp)))
+ moc = target[0]
+ cpp = source[0]
+ # looks like cpp.includes is cleared before the build stage :-(
+ # not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
+ path = SCons.Defaults.CScan.path_function(env, moc.cwd)
+ includes = SCons.Defaults.CScan(cpp, env, path)
+ if not moc in includes:
+ SCons.Warnings.warn(
+ GeneratedMocFileNotIncluded,
+ "Generated moc file '%s' is not included by '%s'" %
+ (str(moc), str(cpp)))
def find_file(filename, paths, node_factory):
- for dir in paths:
- node = node_factory(filename, dir)
- if node.rexists():
- return node
- return None
+ for dir in paths:
+ node = node_factory(filename, dir)
+ if node.rexists():
+ return node
+ return None
class _Automoc:
- """
- Callable class, which works as an emitter for Programs, SharedLibraries and
- StaticLibraries.
- """
-
- def __init__(self, objBuilderName):
- self.objBuilderName = objBuilderName
-
- def __call__(self, target, source, env):
- """
- Smart autoscan function. Gets the list of objects for the Program
- or Lib. Adds objects and builders for the special qt files.
- """
- try:
- if int(env.subst('$QT4_AUTOSCAN')) == 0:
- return target, source
- except ValueError:
- pass
- try:
- debug = int(env.subst('$QT4_DEBUG'))
- except ValueError:
- debug = 0
-
- # some shortcuts used in the scanner
- splitext = SCons.Util.splitext
- objBuilder = getattr(env, self.objBuilderName)
-
- # some regular expressions:
- # Q_OBJECT detection
- q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
- # cxx and c comment 'eater'
- #comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
- # CW: something must be wrong with the regexp. See also bug #998222
- # CURRENTLY THERE IS NO TEST CASE FOR THAT
-
- # The following is kind of hacky to get builders working properly (FIXME)
- objBuilderEnv = objBuilder.env
- objBuilder.env = env
- mocBuilderEnv = env.Moc4.env
- env.Moc4.env = env
-
- # make a deep copy for the result; MocH objects will be appended
- out_sources = source[:]
-
- for obj in source:
- if isinstance(obj,basestring): # big kludge!
- print "scons: qt4: '%s' MAYBE USING AN OLD SCONS VERSION AND NOT CONVERTED TO 'File'. Discarded." % str(obj)
- continue
- if not obj.has_builder():
- # binary obj file provided
- if debug:
- print "scons: qt: '%s' seems to be a binary. Discarded." % str(obj)
- continue
- cpp = obj.sources[0]
- if not splitext(str(cpp))[1] in cxx_suffixes:
- if debug:
- print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp)
- # c or fortran source
- continue
- #cpp_contents = comment.sub('', cpp.get_contents())
- try:
- cpp_contents = cpp.get_contents()
- except: continue # may be an still not generated source
- h=None
- for h_ext in header_extensions:
- # try to find the header file in the corresponding source
- # directory
- hname = splitext(cpp.name)[0] + h_ext
- h = find_file(hname, (cpp.get_dir(),), env.File)
- if h:
- if debug:
- print "scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))
- #h_contents = comment.sub('', h.get_contents())
- h_contents = h.get_contents()
- break
- if not h and debug:
- print "scons: qt: no header for '%s'." % (str(cpp))
- if h and q_object_search.search(h_contents):
- # h file with the Q_OBJECT macro found -> add moc_cpp
- moc_cpp = env.Moc4(h)
- moc_o = objBuilder(moc_cpp)
- out_sources.append(moc_o)
- #moc_cpp.target_scanner = SCons.Defaults.CScan
- if debug:
- print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))
- if cpp and q_object_search.search(cpp_contents):
- # cpp file with Q_OBJECT macro found -> add moc
- # (to be included in cpp)
- moc = env.Moc4(cpp)
- env.Ignore(moc, moc)
- if debug:
- print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))
- #moc.source_scanner = SCons.Defaults.CScan
- # restore the original env attributes (FIXME)
- objBuilder.env = objBuilderEnv
- env.Moc4.env = mocBuilderEnv
-
- return (target, out_sources)
+ """
+ Callable class, which works as an emitter for Programs, SharedLibraries and
+ StaticLibraries.
+ """
+
+ def __init__(self, objBuilderName):
+ self.objBuilderName = objBuilderName
+
+ def __call__(self, target, source, env):
+ """
+ Smart autoscan function. Gets the list of objects for the Program
+ or Lib. Adds objects and builders for the special qt files.
+ """
+ try:
+ if int(env.subst('$QT4_AUTOSCAN')) == 0:
+ return target, source
+ except ValueError:
+ pass
+ try:
+ debug = int(env.subst('$QT4_DEBUG'))
+ except ValueError:
+ debug = 0
+
+ # some shortcuts used in the scanner
+ splitext = SCons.Util.splitext
+ objBuilder = getattr(env, self.objBuilderName)
+
+ # some regular expressions:
+ # Q_OBJECT detection
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ # cxx and c comment 'eater'
+ #comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
+ # CW: something must be wrong with the regexp. See also bug #998222
+ # CURRENTLY THERE IS NO TEST CASE FOR THAT
+
+ # The following is kind of hacky to get builders working properly (FIXME)
+ objBuilderEnv = objBuilder.env
+ objBuilder.env = env
+ mocBuilderEnv = env.Moc4.env
+ env.Moc4.env = env
+
+ # make a deep copy for the result; MocH objects will be appended
+ out_sources = source[:]
+
+ for obj in source:
+ if isinstance(obj,basestring): # big kludge!
+ print "scons: qt4: '%s' MAYBE USING AN OLD SCONS VERSION AND NOT CONVERTED TO 'File'. Discarded." % str(obj)
+ continue
+ if not obj.has_builder():
+ # binary obj file provided
+ if debug:
+ print "scons: qt: '%s' seems to be a binary. Discarded." % str(obj)
+ continue
+ cpp = obj.sources[0]
+ if not splitext(str(cpp))[1] in cxx_suffixes:
+ if debug:
+ print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp)
+ # c or fortran source
+ continue
+ #cpp_contents = comment.sub('', cpp.get_contents())
+ try:
+ cpp_contents = cpp.get_contents()
+ except: continue # may be an still not generated source
+ h=None
+ for h_ext in header_extensions:
+ # try to find the header file in the corresponding source
+ # directory
+ hname = splitext(cpp.name)[0] + h_ext
+ h = find_file(hname, (cpp.get_dir(),), env.File)
+ if h:
+ if debug:
+ print "scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))
+ #h_contents = comment.sub('', h.get_contents())
+ h_contents = h.get_contents()
+ break
+ if not h and debug:
+ print "scons: qt: no header for '%s'." % (str(cpp))
+ if h and q_object_search.search(h_contents):
+ # h file with the Q_OBJECT macro found -> add moc_cpp
+ moc_cpp = env.Moc4(h)
+ moc_o = objBuilder(moc_cpp)
+ out_sources.append(moc_o)
+ #moc_cpp.target_scanner = SCons.Defaults.CScan
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))
+ if cpp and q_object_search.search(cpp_contents):
+ # cpp file with Q_OBJECT macro found -> add moc
+ # (to be included in cpp)
+ moc = env.Moc4(cpp)
+ env.Ignore(moc, moc)
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))
+ #moc.source_scanner = SCons.Defaults.CScan
+ # restore the original env attributes (FIXME)
+ objBuilder.env = objBuilderEnv
+ env.Moc4.env = mocBuilderEnv
+
+ return (target, out_sources)
AutomocShared = _Automoc('SharedObject')
AutomocStatic = _Automoc('StaticObject')
def _detect(env):
- """Not really safe, but fast method to detect the QT library"""
- if 'QTDIR' in env :
- return env['QTDIR']
-
- if 'QTDIR' in os.environ :
- return os.environ['QTDIR']
-
- moc = None
- if env["qt5"]:
- moc = env.WhereIs('moc-qt5') or env.WhereIs('moc5') or env.WhereIs('moc')
- else :
- moc = env.WhereIs('moc-qt4') or env.WhereIs('moc4') or env.WhereIs('moc')
- if moc:
- # Test whether the moc command we found is real, or whether it is just the qtchooser dummy.
- p = subprocess.Popen([moc, "-v"], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p.communicate()
- if p.returncode == 0:
- import sys
- if sys.platform == "darwin" :
- return ""
- QTDIR = os.path.dirname(os.path.dirname(moc))
- return QTDIR
-
- raise SCons.Errors.StopError(
- QtdirNotFound,
- "Could not detect Qt 4 installation")
- return None
+ """Not really safe, but fast method to detect the QT library"""
+ if 'QTDIR' in env :
+ return env['QTDIR']
+
+ if 'QTDIR' in os.environ :
+ return os.environ['QTDIR']
+
+ moc = None
+ if env["qt5"]:
+ moc = env.WhereIs('moc-qt5') or env.WhereIs('moc5') or env.WhereIs('moc')
+ else :
+ moc = env.WhereIs('moc-qt4') or env.WhereIs('moc4') or env.WhereIs('moc')
+ if moc:
+ # Test whether the moc command we found is real, or whether it is just the qtchooser dummy.
+ p = subprocess.Popen([moc, "-v"], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env["ENV"])
+ p.communicate()
+ if p.returncode == 0:
+ import sys
+ if sys.platform == "darwin" :
+ return ""
+ QTDIR = os.path.dirname(os.path.dirname(moc))
+ return QTDIR
+
+ raise SCons.Errors.StopError(
+ QtdirNotFound,
+ "Could not detect Qt 4 installation")
+ return None
def generate(env):
- """Add Builders and construction variables for qt to an Environment."""
-
- def locateQt4Command(env, command, qtdir) :
- if len(qtdir) == 0 :
- qtdir = "/usr"
- if env["qt5"]:
- suffixes = [
- '-qt5',
- '-qt5.exe',
- '5',
- '5.exe',
- '',
- '.exe',
- ]
- else :
- suffixes = [
- '-qt4',
- '-qt4.exe',
- '4',
- '4.exe',
- '',
- '.exe',
- ]
- triedPaths = []
- for suffix in suffixes :
- fullpath = os.path.join(qtdir,'bin',command + suffix)
- if os.access(fullpath, os.X_OK) :
- return fullpath
- triedPaths.append(fullpath)
-
- fullpath = env.Detect([command+'-qt4', command+'4', command])
- if not (fullpath is None) : return fullpath
-
- raise Exception("Qt4 command '" + command + "' not found. Tried: " + ', '.join(triedPaths))
-
-
- CLVar = SCons.Util.CLVar
- Action = SCons.Action.Action
- Builder = SCons.Builder.Builder
- splitext = SCons.Util.splitext
-
- env['QTDIR'] = _detect(env)
- # TODO: 'Replace' should be 'SetDefault'
-# env.SetDefault(
- env.Replace(
- QTDIR = _detect(env),
- # TODO: This is not reliable to QTDIR value changes but needed in order to support '-qt4' variants
- QT4_MOC = locateQt4Command(env,'moc', env['QTDIR']),
- QT4_UIC = locateQt4Command(env,'uic', env['QTDIR']),
- QT4_RCC = locateQt4Command(env,'rcc', env['QTDIR']),
- QT4_LUPDATE = locateQt4Command(env,'lupdate', env['QTDIR']),
- QT4_LRELEASE = locateQt4Command(env,'lrelease', env['QTDIR']),
- QT4_LIB = '', # KLUDGE to avoid linking qt3 library
-
- QT4_AUTOSCAN = 1, # Should the qt tool try to figure out, which sources are to be moc'ed?
-
- # Some QT specific flags. I don't expect someone wants to
- # manipulate those ...
- QT4_UICFLAGS = CLVar(''),
- QT4_MOCFROMHFLAGS = CLVar(''),
- QT4_MOCFROMCXXFLAGS = CLVar('-i'),
- QT4_QRCFLAGS = '',
-
- # suffixes/prefixes for the headers / sources to generate
- QT4_UISUFFIX = '.ui',
- QT4_UICDECLPREFIX = 'ui_',
- QT4_UICDECLSUFFIX = '.h',
- QT4_MOCHPREFIX = 'moc_',
- QT4_MOCHSUFFIX = '$CXXFILESUFFIX',
- QT4_MOCCXXPREFIX = '',
- QT4_MOCCXXSUFFIX = '.moc',
- QT4_QRCSUFFIX = '.qrc',
- QT4_QRCCXXSUFFIX = '$CXXFILESUFFIX',
- QT4_QRCCXXPREFIX = 'qrc_',
- QT4_MOCCPPPATH = [],
- QT4_MOCINCFLAGS = '$( ${_concat("-I", QT4_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)',
-
- # 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
- 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',
- Action(checkMocIncluded,None)],
- QT4_LUPDATECOM = '$QT4_LUPDATE $SOURCE -ts $TARGET',
- QT4_LRELEASECOM = '$QT4_LRELEASE -silent $SOURCE -qm $TARGET',
- QT4_RCCCOM = '$QT4_RCC $QT4_QRCFLAGS -name $SOURCE $SOURCE -o $TARGET',
- )
- if len(env["QTDIR"]) > 0 :
- env.Replace(QT4_LIBPATH = os.path.join('$QTDIR', 'lib'))
-
- # Translation builder
- tsbuilder = Builder(
- action = SCons.Action.Action('$QT4_LUPDATECOM'), #,'$QT4_LUPDATECOMSTR'),
- multi=1
- )
- env.Append( BUILDERS = { 'Ts': tsbuilder } )
- qmbuilder = Builder(
- action = SCons.Action.Action('$QT4_LRELEASECOM', cmdstr = '$QT4_LRELEASECOMSTR'),
- src_suffix = '.ts',
- suffix = '.qm',
- single_source = True
- )
- env.Append( BUILDERS = { 'Qm': qmbuilder } )
-
- # Resource builder
- def scanResources(node, env, path, arg):
- # I've being careful on providing names relative to the qrc file
- # If that was not needed that code could be simplified a lot
- def recursiveFiles(basepath, path) :
- result = []
- for item in os.listdir(os.path.join(basepath, path)) :
- itemPath = os.path.join(path, item)
- if os.path.isdir(os.path.join(basepath, itemPath)) :
- result += recursiveFiles(basepath, itemPath)
- else:
- result.append(itemPath)
- return result
- contents = node.get_contents()
- includes = [included[1] for included in qrcinclude_re.findall(contents)]
- qrcpath = os.path.dirname(node.path)
- dirs = [included for included in includes if os.path.isdir(os.path.join(qrcpath,included))]
- # dirs need to include files recursively
- for dir in dirs :
- includes.remove(dir)
- includes+=recursiveFiles(qrcpath,dir)
- return includes
- qrcscanner = SCons.Scanner.Scanner(name = 'qrcfile',
- function = scanResources,
- argument = None,
- skeys = ['.qrc'])
- qrcbuilder = Builder(
- action = SCons.Action.Action('$QT4_RCCCOM', cmdstr = '$QT4_RCCCOMSTR'),
- source_scanner = qrcscanner,
- src_suffix = '$QT4_QRCSUFFIX',
- suffix = '$QT4_QRCCXXSUFFIX',
- prefix = '$QT4_QRCCXXPREFIX',
- single_source = True
- )
- env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
-
- # Interface builder
- uic4builder = Builder(
- action = SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'),
- src_suffix='$QT4_UISUFFIX',
- suffix='$QT4_UICDECLSUFFIX',
- prefix='$QT4_UICDECLPREFIX',
- single_source = True
- #TODO: Consider the uiscanner on new scons version
- )
- env['BUILDERS']['Uic4'] = uic4builder
-
- # Metaobject builder
- mocBld = Builder(action={}, prefix={}, suffix={})
- for h in header_extensions:
- act = SCons.Action.Action('$QT4_MOCFROMHCOM', cmdstr = '$QT4_MOCFROMHCOMSTR')
- mocBld.add_action(h, act)
- mocBld.prefix[h] = '$QT4_MOCHPREFIX'
- mocBld.suffix[h] = '$QT4_MOCHSUFFIX'
- for cxx in cxx_suffixes:
- act = SCons.Action.Action('$QT4_MOCFROMCXXCOM', cmdstr = '$QT4_MOCFROMCXXCOMSTR')
- mocBld.add_action(cxx, act)
- mocBld.prefix[cxx] = '$QT4_MOCCXXPREFIX'
- mocBld.suffix[cxx] = '$QT4_MOCCXXSUFFIX'
- env['BUILDERS']['Moc4'] = mocBld
-
- # er... no idea what that was for
- static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
- static_obj.src_builder.append('Uic4')
- shared_obj.src_builder.append('Uic4')
-
- # We use the emitters of Program / StaticLibrary / SharedLibrary
- # to scan for moc'able files
- # We can't refer to the builders directly, we have to fetch them
- # as Environment attributes because that sets them up to be called
- # correctly later by our emitter.
- env.AppendUnique(PROGEMITTER =[AutomocStatic],
- SHLIBEMITTER=[AutomocShared],
- LIBEMITTER =[AutomocStatic],
- # Of course, we need to link against the qt libraries
- LIBPATH=["$QT4_LIBPATH"],
- LIBS=['$QT4_LIB'])
-
- # TODO: Does dbusxml2cpp need an adapter
- env.AddMethod(enable_modules, "EnableQt4Modules")
+ """Add Builders and construction variables for qt to an Environment."""
+
+ def locateQt4Command(env, command, qtdir) :
+ if len(qtdir) == 0 :
+ qtdir = "/usr"
+ if env["qt5"]:
+ suffixes = [
+ '-qt5',
+ '-qt5.exe',
+ '5',
+ '5.exe',
+ '',
+ '.exe',
+ ]
+ else :
+ suffixes = [
+ '-qt4',
+ '-qt4.exe',
+ '4',
+ '4.exe',
+ '',
+ '.exe',
+ ]
+ triedPaths = []
+ for suffix in suffixes :
+ fullpath = os.path.join(qtdir,'bin',command + suffix)
+ if os.access(fullpath, os.X_OK) :
+ return fullpath
+ triedPaths.append(fullpath)
+
+ fullpath = env.Detect([command+'-qt4', command+'4', command])
+ if not (fullpath is None) : return fullpath
+
+ raise Exception("Qt4 command '" + command + "' not found. Tried: " + ', '.join(triedPaths))
+
+
+ CLVar = SCons.Util.CLVar
+ Action = SCons.Action.Action
+ Builder = SCons.Builder.Builder
+ splitext = SCons.Util.splitext
+
+ env['QTDIR'] = _detect(env)
+ # TODO: 'Replace' should be 'SetDefault'
+# env.SetDefault(
+ env.Replace(
+ QTDIR = _detect(env),
+ # TODO: This is not reliable to QTDIR value changes but needed in order to support '-qt4' variants
+ QT4_MOC = locateQt4Command(env,'moc', env['QTDIR']),
+ QT4_UIC = locateQt4Command(env,'uic', env['QTDIR']),
+ QT4_RCC = locateQt4Command(env,'rcc', env['QTDIR']),
+ QT4_LUPDATE = locateQt4Command(env,'lupdate', env['QTDIR']),
+ QT4_LRELEASE = locateQt4Command(env,'lrelease', env['QTDIR']),
+ QT4_LIB = '', # KLUDGE to avoid linking qt3 library
+
+ QT4_AUTOSCAN = 1, # Should the qt tool try to figure out, which sources are to be moc'ed?
+
+ # Some QT specific flags. I don't expect someone wants to
+ # manipulate those ...
+ QT4_UICFLAGS = CLVar(''),
+ QT4_MOCFROMHFLAGS = CLVar(''),
+ QT4_MOCFROMCXXFLAGS = CLVar('-i'),
+ QT4_QRCFLAGS = '--compress 9 --threshold 5',
+
+ # suffixes/prefixes for the headers / sources to generate
+ QT4_UISUFFIX = '.ui',
+ QT4_UICDECLPREFIX = 'ui_',
+ QT4_UICDECLSUFFIX = '.h',
+ QT4_MOCHPREFIX = 'moc_',
+ QT4_MOCHSUFFIX = '$CXXFILESUFFIX',
+ QT4_MOCCXXPREFIX = '',
+ QT4_MOCCXXSUFFIX = '.moc',
+ QT4_QRCSUFFIX = '.qrc',
+ QT4_QRCCXXSUFFIX = '$CXXFILESUFFIX',
+ QT4_QRCCXXPREFIX = 'qrc_',
+ QT4_MOCCPPPATH = [],
+ QT4_MOCINCFLAGS = '$( ${_concat("-I", QT4_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)',
+
+ # 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
+ 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',
+ Action(checkMocIncluded,None)],
+ QT4_LUPDATECOM = '$QT4_LUPDATE $SOURCE -ts $TARGET',
+ QT4_LRELEASECOM = '$QT4_LRELEASE -silent $SOURCE -qm $TARGET',
+ QT4_RCCCOM = '$QT4_RCC $QT4_QRCFLAGS -name $SOURCE $SOURCE -o $TARGET',
+ )
+ if len(env["QTDIR"]) > 0 :
+ env.Replace(QT4_LIBPATH = os.path.join('$QTDIR', 'lib'))
+
+ # Translation builder
+ tsbuilder = Builder(
+ action = SCons.Action.Action('$QT4_LUPDATECOM'), #,'$QT4_LUPDATECOMSTR'),
+ multi=1
+ )
+ env.Append( BUILDERS = { 'Ts': tsbuilder } )
+ qmbuilder = Builder(
+ action = SCons.Action.Action('$QT4_LRELEASECOM', cmdstr = '$QT4_LRELEASECOMSTR'),
+ src_suffix = '.ts',
+ suffix = '.qm',
+ single_source = True
+ )
+ env.Append( BUILDERS = { 'Qm': qmbuilder } )
+
+ # Resource builder
+ def scanResources(node, env, path, arg):
+ # I've being careful on providing names relative to the qrc file
+ # If that was not needed that code could be simplified a lot
+ def recursiveFiles(basepath, path) :
+ result = []
+ for item in os.listdir(os.path.join(basepath, path)) :
+ itemPath = os.path.join(path, item)
+ if os.path.isdir(os.path.join(basepath, itemPath)) :
+ result += recursiveFiles(basepath, itemPath)
+ else:
+ result.append(itemPath)
+ return result
+ contents = node.get_contents()
+ includes = [included[1] for included in qrcinclude_re.findall(contents)]
+ qrcpath = os.path.dirname(node.path)
+ dirs = [included for included in includes if os.path.isdir(os.path.join(qrcpath,included))]
+ # dirs need to include files recursively
+ for dir in dirs :
+ includes.remove(dir)
+ includes+=recursiveFiles(qrcpath,dir)
+ return includes
+ qrcscanner = SCons.Scanner.Scanner(name = 'qrcfile',
+ function = scanResources,
+ argument = None,
+ skeys = ['.qrc'])
+ qrcbuilder = Builder(
+ action = SCons.Action.Action('$QT4_RCCCOM', cmdstr = '$QT4_RCCCOMSTR'),
+ source_scanner = qrcscanner,
+ src_suffix = '$QT4_QRCSUFFIX',
+ suffix = '$QT4_QRCCXXSUFFIX',
+ prefix = '$QT4_QRCCXXPREFIX',
+ single_source = True
+ )
+ env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
+
+ # Interface builder
+ uic4builder = Builder(
+ action = SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'),
+ src_suffix='$QT4_UISUFFIX',
+ suffix='$QT4_UICDECLSUFFIX',
+ prefix='$QT4_UICDECLPREFIX',
+ single_source = True
+ #TODO: Consider the uiscanner on new scons version
+ )
+ env['BUILDERS']['Uic4'] = uic4builder
+
+ # Metaobject builder
+ mocBld = Builder(action={}, prefix={}, suffix={})
+ for h in header_extensions:
+ act = SCons.Action.Action('$QT4_MOCFROMHCOM', cmdstr = '$QT4_MOCFROMHCOMSTR')
+ mocBld.add_action(h, act)
+ mocBld.prefix[h] = '$QT4_MOCHPREFIX'
+ mocBld.suffix[h] = '$QT4_MOCHSUFFIX'
+ for cxx in cxx_suffixes:
+ act = SCons.Action.Action('$QT4_MOCFROMCXXCOM', cmdstr = '$QT4_MOCFROMCXXCOMSTR')
+ mocBld.add_action(cxx, act)
+ mocBld.prefix[cxx] = '$QT4_MOCCXXPREFIX'
+ mocBld.suffix[cxx] = '$QT4_MOCCXXSUFFIX'
+ env['BUILDERS']['Moc4'] = mocBld
+
+ # er... no idea what that was for
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+ static_obj.src_builder.append('Uic4')
+ shared_obj.src_builder.append('Uic4')
+
+ # We use the emitters of Program / StaticLibrary / SharedLibrary
+ # to scan for moc'able files
+ # We can't refer to the builders directly, we have to fetch them
+ # as Environment attributes because that sets them up to be called
+ # correctly later by our emitter.
+ env.AppendUnique(PROGEMITTER =[AutomocStatic],
+ SHLIBEMITTER=[AutomocShared],
+ LIBEMITTER =[AutomocStatic],
+ # Of course, we need to link against the qt libraries
+ LIBPATH=["$QT4_LIBPATH"],
+ LIBS=['$QT4_LIB'])
+
+ # TODO: Does dbusxml2cpp need an adapter
+ env.AddMethod(enable_modules, "EnableQt4Modules")
def enable_modules(self, modules, debug=False, crosscompiling=False, version='4') :
- import sys
-
- validModules = [
- 'QtCore',
- 'QtGui',
- 'QtOpenGL',
- 'Qt3Support',
- 'QtAssistant',
- 'QtScript',
- 'QtDBus',
- 'QtSql',
- # The next modules have not been tested yet so, please
- # maybe they require additional work on non Linux platforms
- 'QtNetwork',
- 'QtSvg',
- 'QtTest',
- 'QtXml',
- 'QtXmlPatterns',
- 'QtUiTools',
- 'QtDesigner',
- 'QtDesignerComponents',
- 'QtWebKit',
- 'QtHelp',
- 'QtScript',
-
- # Qt5 modules
- 'QtWidgets',
- 'QtMultimedia',
- 'QtWebKitWidgets',
- 'QtWebChannel',
- ]
- if sys.platform != "win32" and sys.platform != "darwin" and not crosscompiling :
- validModules += ['QtX11Extras']
- staticModules = [
- 'QtUiTools',
- ]
- invalidModules=[]
- for module in modules:
- if module not in validModules :
- invalidModules.append(module)
- if invalidModules :
- raise Exception("Modules %s are not Qt4 modules. Valid Qt4 modules are: %s"% (
- str(invalidModules),str(validModules)))
-
- moduleDefines = {
- 'QtScript' : ['QT_SCRIPT_LIB'],
- 'QtSvg' : ['QT_SVG_LIB'],
- 'Qt3Support' : ['QT_QT3SUPPORT_LIB','QT3_SUPPORT'],
- 'QtSql' : ['QT_SQL_LIB'],
- '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'],
- }
- for module in modules :
- try : self.AppendUnique(CPPDEFINES=moduleDefines[module])
- except: pass
- debugSuffix = ''
-
-
- include_flag = "-I"
- if os.path.basename(self["CC"]) in ("gcc", "clang"):
- include_flag = "-isystem"
-
-
- if sys.platform != "win32" and sys.platform != "darwin" and not crosscompiling :
- if self["qt"]:
- # The user specified qt path in config.py and we are going to use the
- # installation under that location.
- UsePkgConfig = False
- else:
- # The user did not specify a qt path in config py and we are going to
- # ask pkg-config for the correct flags.
- UsePkgConfig = True
- if not UsePkgConfig:
- if debug : debugSuffix = '_debug'
- if version == '4' :
- self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR", "include", "phonon")])
- for module in modules :
- module_str = module
- if not version == '4' :
- module_str = module_str.replace('Qt', 'Qt5')
- self.AppendUnique(LIBS=[module_str+debugSuffix])
- self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
- self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR","include")])
- self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR","include", module)])
- self["QT4_MOCCPPPATH"] = self["CPPPATH"]
- return
- else:
- test_conf = self.Configure()
- modules_str = " ".join(modules)
- if not version == '4' :
- modules_str = modules_str.replace('Qt', 'Qt5')
-
- # Check if Qt is registered at pkg-config
- ret = test_conf.TryAction('pkg-config --exists \'%s\'' % modules_str)[0]
- if ret != 1:
- test_conf.Finish()
- raise Exception('Qt installation is missing packages. The following are required: %s' % modules_str)
- return
- test_conf.env.ParseConfig("pkg-config --cflags --libs " + modules_str)
- self.AppendUnique(LIBS=test_conf.env["LIBS"], LIBPATH=test_conf.env["LIBPATH"], CPPPATH=test_conf.env["CPPPATH"])
- self["QT4_MOCCPPPATH"] = self["CPPPATH"]
- test_conf.Finish()
- return
-
- if sys.platform == "win32" or crosscompiling :
- if crosscompiling:
- transformedQtdir = transformToWinePath(self['QTDIR'])
- self['QT4_MOC'] = "QTDIR=%s %s"%( transformedQtdir, self['QT4_MOC'])
- self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include")])
- try: modules.remove("QtDBus")
- except: pass
- if debug : debugSuffix = 'd'
- if "QtAssistant" in modules:
- self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include","QtAssistant")])
- modules.remove("QtAssistant")
- modules.append("QtAssistantClient")
- 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 :
- self["QT4_MOCCPPPATH"] = [
- path.replace('$QTDIR', transformedQtdir)
- for path in self['CPPPATH'] ]
- else :
- self["QT4_MOCCPPPATH"] = self["CPPPATH"]
- self.AppendUnique(LIBPATH=[os.path.join('$QTDIR','lib')])
- self.PrependUnique(LIBS=["shell32"])
- return
-
- if sys.platform=="darwin" :
- if debug : debugSuffix = 'd'
-
- if len(self["QTDIR"]) > 0 :
- self.AppendUnique(LIBPATH=[os.path.join('$QTDIR','lib')])
- self.AppendUnique(LINKFLAGS="-F$QTDIR/lib")
- self.AppendUnique(CPPFLAGS="-iframework$QTDIR/lib")
- self.AppendUnique(LINKFLAGS="-L$QTDIR/lib") #TODO clean!
-
- # FIXME: Phonon Hack
- if version == '4' :
- self.Append(LINKFLAGS=['-framework', "phonon"])
-
- for module in modules :
- if module in staticModules :
- self.AppendUnique(LIBS=[module+debugSuffix]) # TODO: Add the debug suffix
- self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
- else :
- if len(self["QTDIR"]) > 0 :
- self.Append(CPPFLAGS = [include_flag + os.path.join("$QTDIR", "lib", module + ".framework", "Versions", version, "Headers")])
- else :
- self.Append(CPPFLAGS = [include_flag + 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")
- self.Append(LINKFLAGS=['-framework', 'AGL']) #TODO ughly kludge to avoid quotes
- self.Append(LINKFLAGS=['-framework', 'OpenGL'])
- self["QT4_MOCCPPPATH"] = self["CPPPATH"]
+ import sys
+
+ validModules = [
+ 'QtCore',
+ 'QtGui',
+ 'QtOpenGL',
+ 'Qt3Support',
+ 'QtAssistant',
+ 'QtScript',
+ 'QtDBus',
+ 'QtSql',
+ # The next modules have not been tested yet so, please
+ # maybe they require additional work on non Linux platforms
+ 'QtNetwork',
+ 'QtSvg',
+ 'QtTest',
+ 'QtXml',
+ 'QtXmlPatterns',
+ 'QtUiTools',
+ 'QtDesigner',
+ 'QtDesignerComponents',
+ 'QtWebKit',
+ 'QtHelp',
+ 'QtScript',
+
+ # Qt5 modules
+ 'QtWidgets',
+ 'QtMultimedia',
+ 'QtWebKitWidgets',
+ 'QtWebChannel',
+ ]
+ if sys.platform != "win32" and sys.platform != "darwin" and not crosscompiling :
+ validModules += ['QtX11Extras']
+ staticModules = [
+ 'QtUiTools',
+ ]
+ invalidModules=[]
+ for module in modules:
+ if module not in validModules :
+ invalidModules.append(module)
+ if invalidModules :
+ raise Exception("Modules %s are not Qt4 modules. Valid Qt4 modules are: %s"% (
+ str(invalidModules),str(validModules)))
+
+ moduleDefines = {
+ 'QtScript' : ['QT_SCRIPT_LIB'],
+ 'QtSvg' : ['QT_SVG_LIB'],
+ 'Qt3Support' : ['QT_QT3SUPPORT_LIB','QT3_SUPPORT'],
+ 'QtSql' : ['QT_SQL_LIB'],
+ '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'],
+ }
+ for module in modules :
+ try : self.AppendUnique(CPPDEFINES=moduleDefines[module])
+ except: pass
+ debugSuffix = ''
+
+
+ include_flag = "-I"
+ if os.path.basename(self["CC"]) in ("gcc", "clang"):
+ include_flag = "-isystem"
+
+
+ if sys.platform != "win32" and sys.platform != "darwin" and not crosscompiling :
+ if self["qt"]:
+ # The user specified qt path in config.py and we are going to use the
+ # installation under that location.
+ UsePkgConfig = False
+ else:
+ # The user did not specify a qt path in config py and we are going to
+ # ask pkg-config for the correct flags.
+ UsePkgConfig = True
+ if not UsePkgConfig:
+ if debug : debugSuffix = '_debug'
+ if version == '4' :
+ self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR", "include", "phonon")])
+ for module in modules :
+ module_str = module
+ if not version == '4' :
+ module_str = module_str.replace('Qt', 'Qt5')
+ self.AppendUnique(LIBS=[module_str+debugSuffix])
+ self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
+ self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR","include")])
+ self.AppendUnique(CPPFLAGS = [include_flag + os.path.join("$QTDIR","include", module)])
+ self["QT4_MOCCPPPATH"] = self["CPPPATH"]
+ return
+ else:
+ test_conf = self.Configure()
+ modules_str = " ".join(modules)
+ if not version == '4' :
+ modules_str = modules_str.replace('Qt', 'Qt5')
+
+ # Check if Qt is registered at pkg-config
+ ret = test_conf.TryAction('pkg-config --exists \'%s\'' % modules_str)[0]
+ if ret != 1:
+ test_conf.Finish()
+ raise Exception('Qt installation is missing packages. The following are required: %s' % modules_str)
+ return
+
+ def parse_conf_as_system(env, cmd, unique=1):
+ return env.MergeFlags(cmd.replace("-I/", include_flag + "/"), unique)
+
+ test_conf.env.ParseConfig("pkg-config --cflags --libs " + modules_str, parse_conf_as_system)
+ self["QT4_MOCCPPPATH"] = self["CPPPATH"]
+ test_conf.Finish()
+ return
+
+ if sys.platform == "win32" or crosscompiling :
+ if crosscompiling:
+ transformedQtdir = transformToWinePath(self['QTDIR'])
+ self['QT4_MOC'] = "QTDIR=%s %s"%( transformedQtdir, self['QT4_MOC'])
+ self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include")])
+ try: modules.remove("QtDBus")
+ except: pass
+ if debug : debugSuffix = 'd'
+ if "QtAssistant" in modules:
+ self.AppendUnique(CPPPATH=[os.path.join("$QTDIR","include","QtAssistant")])
+ modules.remove("QtAssistant")
+ modules.append("QtAssistantClient")
+ 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 :
+ self["QT4_MOCCPPPATH"] = [
+ path.replace('$QTDIR', transformedQtdir)
+ for path in self['CPPPATH'] ]
+ else :
+ self["QT4_MOCCPPPATH"] = self["CPPPATH"]
+ self.AppendUnique(LIBPATH=[os.path.join('$QTDIR','lib')])
+ self.PrependUnique(LIBS=["shell32"])
+ return
+
+ if sys.platform=="darwin" :
+ if debug : debugSuffix = 'd'
+
+ if len(self["QTDIR"]) > 0 :
+ self.AppendUnique(LIBPATH=[os.path.join('$QTDIR','lib')])
+ self.AppendUnique(LINKFLAGS="-F$QTDIR/lib")
+ self.AppendUnique(CPPFLAGS=["-iframework$QTDIR/lib", include_flag + os.path.join("$QTDIR", "include")])
+ self.Append(LINKFLAGS="-Wl,-rpath,$QTDIR/lib")
+
+ # FIXME: Phonon Hack
+ if version == '4' :
+ self.Append(LINKFLAGS=['-framework', "phonon"])
+
+ for module in modules :
+ if module in staticModules :
+ self.AppendUnique(LIBS=[module+debugSuffix]) # TODO: Add the debug suffix
+ self.AppendUnique(LIBPATH=[os.path.join("$QTDIR","lib")])
+ else :
+ if len(self["QTDIR"]) > 0 :
+ self.Append(CPPFLAGS = [include_flag + os.path.join("$QTDIR", "lib", module + ".framework", "Headers")])
+ else :
+ self.Append(CPPFLAGS = [include_flag + os.path.join("/Library/Frameworks", module + ".framework", "Headers")])
+ self.Append(LINKFLAGS=['-framework', module])
+ if 'QtOpenGL' in modules:
+ self.AppendUnique(LINKFLAGS="-F/System/Library/Frameworks")
+ self.Append(LINKFLAGS=['-framework', 'AGL']) #TODO ughly kludge to avoid quotes
+ self.Append(LINKFLAGS=['-framework', 'OpenGL'])
+ self["QT4_MOCCPPPATH"] = self["CPPPATH"]
def exists(env):
- return _detect(env)
+ return _detect(env)
diff --git a/BuildTools/SCons/Tools/textfile.py b/BuildTools/SCons/Tools/textfile.py
index b290125..89f8963 100644
--- a/BuildTools/SCons/Tools/textfile.py
+++ b/BuildTools/SCons/Tools/textfile.py
@@ -25,23 +25,23 @@
__doc__ = """
Textfile/Substfile builder for SCons.
- Create file 'target' which typically is a textfile. The 'source'
- may be any combination of strings, Nodes, or lists of same. A
- 'linesep' will be put between any part written and defaults to
- os.linesep.
-
- The only difference between the Textfile builder and the Substfile
- builder is that strings are converted to Value() nodes for the
- former and File() nodes for the latter. To insert files in the
- former or strings in the latter, wrap them in a File() or Value(),
- respectively.
-
- The values of SUBST_DICT first have any construction variables
- expanded (its keys are not expanded). If a value of SUBST_DICT is
- a python callable function, it is called and the result is expanded
- as the value. Values are substituted in a "random" order; if any
- substitution could be further expanded by another subsitition, it
- is unpredictible whether the expansion will occur.
+ Create file 'target' which typically is a textfile. The 'source'
+ may be any combination of strings, Nodes, or lists of same. A
+ 'linesep' will be put between any part written and defaults to
+ os.linesep.
+
+ The only difference between the Textfile builder and the Substfile
+ builder is that strings are converted to Value() nodes for the
+ former and File() nodes for the latter. To insert files in the
+ former or strings in the latter, wrap them in a File() or Value(),
+ respectively.
+
+ The values of SUBST_DICT first have any construction variables
+ expanded (its keys are not expanded). If a value of SUBST_DICT is
+ a python callable function, it is called and the result is expanded
+ as the value. Values are substituted in a "random" order; if any
+ substitution could be further expanded by another subsitition, it
+ is unpredictible whether the expansion will occur.
"""
__revision__ = "src/engine/SCons/Tool/textfile.py 5357 2011/09/09 21:31:03 bdeegan"
@@ -56,117 +56,117 @@ from SCons.Node.Python import Value
from SCons.Util import is_String, is_Sequence, is_Dict
def _do_subst(node, subs):
- """
- Fetch the node contents and replace all instances of the keys with
- their values. For example, if subs is
- {'%VERSION%': '1.2345', '%BASE%': 'MyProg', '%prefix%': '/bin'},
- then all instances of %VERSION% in the file will be replaced with
- 1.2345 and so forth.
- """
- contents = node.get_text_contents()
- if not subs: return contents
- for (k,v) in subs:
- contents = re.sub(k, v, contents)
- return contents
+ """
+ Fetch the node contents and replace all instances of the keys with
+ their values. For example, if subs is
+ {'%VERSION%': '1.2345', '%BASE%': 'MyProg', '%prefix%': '/bin'},
+ then all instances of %VERSION% in the file will be replaced with
+ 1.2345 and so forth.
+ """
+ contents = node.get_text_contents()
+ if not subs: return contents
+ for (k,v) in subs:
+ contents = re.sub(k, v, contents)
+ return contents
def _action(target, source, env):
- # prepare the line separator
- linesep = env['LINESEPARATOR']
- if linesep is None:
- linesep = os.linesep
- elif is_String(linesep):
- pass
- elif isinstance(linesep, Value):
- linesep = linesep.get_text_contents()
- else:
- raise SCons.Errors.UserError(
- 'unexpected type/class for LINESEPARATOR: %s'
- % repr(linesep), None)
-
- # create a dictionary to use for the substitutions
- if 'SUBST_DICT' not in env:
- subs = None # no substitutions
- else:
- d = env['SUBST_DICT']
- if is_Dict(d):
- d = list(d.items())
- elif is_Sequence(d):
- pass
- else:
- raise SCons.Errors.UserError('SUBST_DICT must be dict or sequence')
- subs = []
- for (k,v) in d:
- if callable(v):
- v = v()
- if is_String(v):
- v = env.subst(v)
- else:
- v = str(v)
- subs.append((k,v))
-
- # write the file
- try:
- fd = open(target[0].get_path(), "wb")
- except (OSError,IOError), e:
- raise SCons.Errors.UserError("Can't write target file %s" % target[0])
- # separate lines by 'linesep' only if linesep is not empty
- lsep = None
- for s in source:
- if lsep: fd.write(lsep)
- fd.write(_do_subst(s, subs))
- lsep = linesep
- fd.close()
+ # prepare the line separator
+ linesep = env['LINESEPARATOR']
+ if linesep is None:
+ linesep = os.linesep
+ elif is_String(linesep):
+ pass
+ elif isinstance(linesep, Value):
+ linesep = linesep.get_text_contents()
+ else:
+ raise SCons.Errors.UserError(
+ 'unexpected type/class for LINESEPARATOR: %s'
+ % repr(linesep), None)
+
+ # create a dictionary to use for the substitutions
+ if 'SUBST_DICT' not in env:
+ subs = None # no substitutions
+ else:
+ d = env['SUBST_DICT']
+ if is_Dict(d):
+ d = list(d.items())
+ elif is_Sequence(d):
+ pass
+ else:
+ raise SCons.Errors.UserError('SUBST_DICT must be dict or sequence')
+ subs = []
+ for (k,v) in d:
+ if callable(v):
+ v = v()
+ if is_String(v):
+ v = env.subst(v)
+ else:
+ v = str(v)
+ subs.append((k,v))
+
+ # write the file
+ try:
+ fd = open(target[0].get_path(), "wb")
+ except (OSError,IOError), e:
+ raise SCons.Errors.UserError("Can't write target file %s" % target[0])
+ # separate lines by 'linesep' only if linesep is not empty
+ lsep = None
+ for s in source:
+ if lsep: fd.write(lsep)
+ fd.write(_do_subst(s, subs))
+ lsep = linesep
+ fd.close()
def _strfunc(target, source, env):
- return "Creating '%s'" % target[0]
+ return "Creating '%s'" % target[0]
def _convert_list_R(newlist, sources):
- for elem in sources:
- if is_Sequence(elem):
- _convert_list_R(newlist, elem)
- elif isinstance(elem, Node):
- newlist.append(elem)
- else:
- newlist.append(Value(elem))
+ for elem in sources:
+ if is_Sequence(elem):
+ _convert_list_R(newlist, elem)
+ elif isinstance(elem, Node):
+ newlist.append(elem)
+ else:
+ newlist.append(Value(elem))
def _convert_list(target, source, env):
- if len(target) != 1:
- raise SCons.Errors.UserError("Only one target file allowed")
- newlist = []
- _convert_list_R(newlist, source)
- return target, newlist
+ if len(target) != 1:
+ raise SCons.Errors.UserError("Only one target file allowed")
+ newlist = []
+ _convert_list_R(newlist, source)
+ return target, newlist
_common_varlist = ['SUBST_DICT', 'LINESEPARATOR']
_text_varlist = _common_varlist + ['TEXTFILEPREFIX', 'TEXTFILESUFFIX']
_text_builder = SCons.Builder.Builder(
- action = SCons.Action.Action(_action, _strfunc, varlist = _text_varlist),
- source_factory = Value,
- emitter = _convert_list,
- prefix = '$TEXTFILEPREFIX',
- suffix = '$TEXTFILESUFFIX',
- )
+ action = SCons.Action.Action(_action, _strfunc, varlist = _text_varlist),
+ source_factory = Value,
+ emitter = _convert_list,
+ prefix = '$TEXTFILEPREFIX',
+ suffix = '$TEXTFILESUFFIX',
+ )
_subst_varlist = _common_varlist + ['SUBSTFILEPREFIX', 'TEXTFILESUFFIX']
_subst_builder = SCons.Builder.Builder(
- action = SCons.Action.Action(_action, _strfunc, varlist = _subst_varlist),
- source_factory = SCons.Node.FS.File,
- emitter = _convert_list,
- prefix = '$SUBSTFILEPREFIX',
- suffix = '$SUBSTFILESUFFIX',
- src_suffix = ['.in'],
- )
+ action = SCons.Action.Action(_action, _strfunc, varlist = _subst_varlist),
+ source_factory = SCons.Node.FS.File,
+ emitter = _convert_list,
+ prefix = '$SUBSTFILEPREFIX',
+ suffix = '$SUBSTFILESUFFIX',
+ src_suffix = ['.in'],
+ )
def generate(env):
- env['LINESEPARATOR'] = os.linesep
- env['BUILDERS']['MyTextfile'] = _text_builder
- env['TEXTFILEPREFIX'] = ''
- env['TEXTFILESUFFIX'] = '.txt'
- env['BUILDERS']['MySubstfile'] = _subst_builder
- env['SUBSTFILEPREFIX'] = ''
- env['SUBSTFILESUFFIX'] = ''
+ env['LINESEPARATOR'] = os.linesep
+ env['BUILDERS']['MyTextfile'] = _text_builder
+ env['TEXTFILEPREFIX'] = ''
+ env['TEXTFILESUFFIX'] = '.txt'
+ env['BUILDERS']['MySubstfile'] = _subst_builder
+ env['SUBSTFILEPREFIX'] = ''
+ env['SUBSTFILESUFFIX'] = ''
def exists(env):
- return 1
+ return 1
# Local Variables:
# tab-width:4
diff --git a/BuildTools/SCons/Tools/wix.py b/BuildTools/SCons/Tools/wix.py
index 705d249..907b6d9 100644
--- a/BuildTools/SCons/Tools/wix.py
+++ b/BuildTools/SCons/Tools/wix.py
@@ -3,49 +3,49 @@ import SCons.Util
from subprocess import call
def generate(env) :
- wixPath = env.get("wix_bindir", "")
- if len(wixPath) > 0 and wixPath[-1] != "\\":
- wixPath += "\\"
- env['WIX_HEAT'] = wixPath + 'heat.exe'
- env['WIX_HEAT_OPTIONS'] = '-nologo -ag -sfrag -suid -template fragment -dr ProgramFilesFolder'
- env['WIX_CANDLE'] = wixPath + 'candle.exe'
- env['WIX_CANDLE_OPTIONS'] = '-nologo'
- env['WIX_LIGHT'] = wixPath + 'light.exe'
- env['WIX_LIGHT_OPTIONS'] = '-nologo -ext WixUIExtension'
-
- def WiX_IncludeScanner(source, env, path, arg):
- wixIncludeRegexp = re.compile(r'^\s*\<\?include (\S+.wxs)\s*\?\>\S*', re.M)
- contents = source.get_contents()
- includes = wixIncludeRegexp.findall(contents)
- return [ "" + include for include in includes ]
-
- heat_builder = SCons.Builder.Builder(
- action = '"$WIX_HEAT" dir "$WIX_SOURCE_OBJECT_DIR" -cg Files $WIX_HEAT_OPTIONS -o ${TARGET} -t Swift\\Packaging\\WiX\\include.xslt',
- suffix = '.wxi')
-
-
- candle_scanner = env.Scanner(name = 'wixincludefile',
- function = WiX_IncludeScanner,
- argument = None,
- skeys = ['.wxs'])
-
- candle_builder = SCons.Builder.Builder(
- action = '"$WIX_CANDLE" $WIX_CANDLE_OPTIONS ${SOURCES} -o ${TARGET}',
- src_suffix = '.wxs',
- suffix = '.wixobj',
- source_scanner = candle_scanner,
- src_builder = heat_builder)
-
-
- light_builder = SCons.Builder.Builder(
- action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -o ${TARGET}',
- src_suffix = '.wixobj',
- src_builder = candle_builder)
-
- env['BUILDERS']['WiX_Heat'] = heat_builder
- env['BUILDERS']['WiX_Candle'] = candle_builder
- env['BUILDERS']['WiX_Light'] = light_builder
+ wixPath = env.get("wix_bindir", "")
+ if len(wixPath) > 0 and wixPath[-1] != "\\":
+ wixPath += "\\"
+ env['WIX_HEAT'] = wixPath + 'heat.exe'
+ env['WIX_HEAT_OPTIONS'] = '-nologo -ag -sfrag -suid -template fragment -dr ProgramFilesFolder'
+ env['WIX_CANDLE'] = wixPath + 'candle.exe'
+ env['WIX_CANDLE_OPTIONS'] = '-nologo'
+ env['WIX_LIGHT'] = wixPath + 'light.exe'
+ env['WIX_LIGHT_OPTIONS'] = '-nologo -ext WixUIExtension'
+
+ def WiX_IncludeScanner(source, env, path, arg):
+ wixIncludeRegexp = re.compile(r'^\s*\<\?include (\S+.wxs)\s*\?\>\S*', re.M)
+ contents = source.get_contents()
+ includes = wixIncludeRegexp.findall(contents)
+ return [ "" + include for include in includes ]
+
+ heat_builder = SCons.Builder.Builder(
+ action = '"$WIX_HEAT" dir "$WIX_SOURCE_OBJECT_DIR" -cg Files $WIX_HEAT_OPTIONS -o ${TARGET} -t Swift\\Packaging\\WiX\\include.xslt',
+ suffix = '.wxi')
+
+
+ candle_scanner = env.Scanner(name = 'wixincludefile',
+ function = WiX_IncludeScanner,
+ argument = None,
+ skeys = ['.wxs'])
+
+ candle_builder = SCons.Builder.Builder(
+ action = '"$WIX_CANDLE" $WIX_CANDLE_OPTIONS ${SOURCES} -o ${TARGET}',
+ src_suffix = '.wxs',
+ suffix = '.wixobj',
+ source_scanner = candle_scanner,
+ src_builder = heat_builder)
+
+
+ light_builder = SCons.Builder.Builder(
+ action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -o ${TARGET}',
+ src_suffix = '.wixobj',
+ src_builder = candle_builder)
+
+ env['BUILDERS']['WiX_Heat'] = heat_builder
+ env['BUILDERS']['WiX_Candle'] = candle_builder
+ env['BUILDERS']['WiX_Light'] = light_builder
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py
index 6482664..d34c2a7 100644
--- a/BuildTools/SCons/Version.py
+++ b/BuildTools/SCons/Version.py
@@ -1,68 +1,68 @@
import subprocess, os, datetime, re, os.path
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
+ 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()
- if p.wait() == 0 :
- return gitVersion
- return None
+ 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()
+ 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
+ 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)
- if gitVersion :
- return gitVersion
+ gitVersion = getGitBuildVersion(root, project)
+ if gitVersion :
+ return gitVersion
- return datetime.date.today().strftime("%Y%m%d")
+ return datetime.date.today().strftime("%Y%m%d")
def convertToWindowsVersion(version) :
- version_match = re.match("(\d+)\.(\d+)(.*)", version)
- major = version_match and int(version_match.group(1)) or 0
- minor = version_match and int(version_match.group(2)) or 0
- if version_match and len(version_match.group(3)) == 0 :
- patch = 60000
- else :
- match = re.match("^beta(\d+)(.*)", version_match.group(3))
- build_string = ""
- if match :
- patch = 1000*int(match.group(1))
- build_string = match.group(2)
- else :
- rc_match = re.match("^rc(\d+)(.*)", version_match.group(3))
- if rc_match :
- 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)
+ version_match = re.match("(\d+)\.(\d+)(.*)", version)
+ major = version_match and int(version_match.group(1)) or 0
+ minor = version_match and int(version_match.group(2)) or 0
+ if version_match and len(version_match.group(3)) == 0 :
+ patch = 60000
+ else :
+ match = re.match("^beta(\d+)(.*)", version_match.group(3))
+ build_string = ""
+ if match :
+ patch = 1000*int(match.group(1))
+ build_string = match.group(2)
+ else :
+ rc_match = re.match("^rc(\d+)(.*)", version_match.group(3))
+ if rc_match :
+ 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)
- if build_match :
- patch += int(build_match.group(1))
+ if len(build_string) > 0 :
+ build_match = re.match("^-dev(\d+)", build_string)
+ if build_match :
+ patch += int(build_match.group(1))
- return (major, minor, patch)
+ return (major, minor, patch)