summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools')
-rwxr-xr-xBuildTools/CheckHeaders.py2
-rwxr-xr-xBuildTools/CheckTranslations.py8
-rwxr-xr-xBuildTools/Copyright/find-contribs.py6
-rwxr-xr-xBuildTools/Copyrighter.py16
-rw-r--r--BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py10
-rw-r--r--BuildTools/DocBook/SCons/XSLT.py2
-rwxr-xr-xBuildTools/FixIncludes.py4
-rwxr-xr-xBuildTools/GenerateAppCastFeeds.py2
-rwxr-xr-xBuildTools/GetBuildVersion.py2
-rwxr-xr-xBuildTools/Gource/GetGravatars.py14
-rwxr-xr-xBuildTools/ProjectCopyrightSummary.py2
-rw-r--r--BuildTools/SCons/SConscript.boot16
-rw-r--r--BuildTools/SCons/SConstruct62
-rw-r--r--BuildTools/SCons/Tools/AppBundle.py4
-rw-r--r--BuildTools/SCons/Tools/InstallWithSymLinks.py8
-rw-r--r--BuildTools/SCons/Tools/WindowsBundle.py20
-rw-r--r--BuildTools/SCons/Tools/qt4.py51
-rw-r--r--BuildTools/SCons/Tools/textfile.py8
-rw-r--r--BuildTools/SCons/Tools/wix.py3
-rw-r--r--BuildTools/SCons/Version.py2
-rw-r--r--BuildTools/TranslationCoverage.xslt50
-rwxr-xr-xBuildTools/UpdateDebianChangelog.py3
-rwxr-xr-xBuildTools/scons2ninja.py24
23 files changed, 211 insertions, 108 deletions
diff --git a/BuildTools/CheckHeaders.py b/BuildTools/CheckHeaders.py
index 79ff85c..752d257 100755
--- a/BuildTools/CheckHeaders.py
+++ b/BuildTools/CheckHeaders.py
@@ -30,13 +30,13 @@ if filename.endswith("Swiften.h") :
file = open(filename, "r")
for line in file.readlines() :
if not "#include" in line :
continue
if "Base/Log.h" in filename :
continue
for forbiddenInclude, ignores in FORBIDDEN_INCLUDES :
if forbiddenInclude in line and len([x for x in ignores if x in filename]) == 0 :
- print "Found " + forbiddenInclude + " include in " + filename
+ print("Found " + forbiddenInclude + " include in " + filename)
foundBadHeaders = True
sys.exit(foundBadHeaders)
diff --git a/BuildTools/CheckTranslations.py b/BuildTools/CheckTranslations.py
index 615f81f..0617fba 100755
--- a/BuildTools/CheckTranslations.py
+++ b/BuildTools/CheckTranslations.py
@@ -35,16 +35,16 @@ for filename in os.listdir("Swift/Translations") :
source = message.getElementsByTagName("source")[0]
sourceText = getText(source.childNodes)
sourcePlaceholders = set(re.findall("%\d+%?", sourceText))
translation = message.getElementsByTagName("translation")[0]
if "type" in translation.attributes.keys() and translation.attributes["type"]. value == "unfinished" :
finished = False
translationText = getText(translation.childNodes)
translationPlaceholders = set(re.findall("%\d+%?", translationText))
if translationPlaceholders != sourcePlaceholders :
- print "[Error] " + filename + ": Placeholder mismatch in translation '" + sourceText + "'"
+ print("[Error] " + filename + ": Placeholder mismatch in translation '" + sourceText + "'")
if not finished :
- print "[Warning] " + filename + ": Unfinished"
+ print("[Warning] " + filename + ": Unfinished")
if language not in desktop_generic_names and language != "en" :
- print "[Warning] GenericName field missing in desktop entry for " + language
+ print("[Warning] GenericName field missing in desktop entry for " + language)
if language not in desktop_comments and language != "en" :
- print "[Warning] Comment field missing in desktop entry for " + language
+ print("[Warning] Comment field missing in desktop entry for " + language)
diff --git a/BuildTools/Copyright/find-contribs.py b/BuildTools/Copyright/find-contribs.py
index ac30afb..799ae7b 100755
--- a/BuildTools/Copyright/find-contribs.py
+++ b/BuildTools/Copyright/find-contribs.py
@@ -40,18 +40,18 @@ def print_log(full_log):
if not commit[author_bit] in contributors:
contributors[commit[author_bit]] = []
contributors[commit[author_bit]].append(commit[commit_bit])
for contributor in contributors:
print contributor + " has contributed patches " + ", ".join([commit[len(commit_bit):] for commit in contributors[contributor]])
full_swiften_log = subprocess.check_output(["git", "log", "--", "Swiften"])
-print "Contributors for Swiften/ subtree:\n"
+print("Contributors for Swiften/ subtree:\n")
print_log(full_swiften_log)
full_all_log = subprocess.check_output(["git", "log"])
-print "\n\n\n\n"
+print("\n\n\n\n")
-print "Contributors for full tree:\n"
+print("Contributors for full tree:\n")
print_log(full_all_log)
diff --git a/BuildTools/Copyrighter.py b/BuildTools/Copyrighter.py
index a16050c..4c7bfeb 100755
--- a/BuildTools/Copyrighter.py
+++ b/BuildTools/Copyrighter.py
@@ -2,19 +2,19 @@
#coding=utf-8
import os, re, datetime, sys, subprocess
DEFAULT_LICENSE = "gpl3"
CONTRIBUTOR_LICENSE = "mit"
LICENSE_DIR = "Documentation/Licenses"
# The following regex parses license comment blocks and its part out of a complete source file.
-reParseLicenseCommentBlocks = re.compile(ur'(\/\*\n\s\*\sCopyright \(c\) (?P<startYear>\d\d\d\d)(-(?P<endYear>\d\d\d\d))? (?P<author>[^\n\.]*)\.?\n.\* (?P<license>[^\n]*)\n \* (?P<seeMore>[^\n]+)\n *\*\/)')
+reParseLicenseCommentBlocks = re.compile(r'(\/\*\n\s\*\sCopyright \(c\) (?P<startYear>\d\d\d\d)(-(?P<endYear>\d\d\d\d))? (?P<author>[^\n\.]*)\.?\n.\* (?P<license>[^\n]*)\n \* (?P<seeMore>[^\n]+)\n *\*\/)')
class License :
def __init__(self, name, file) :
self.name = name
self.file = file
licenses = {
"default": License("All rights reserved.", "See the COPYING file for more information."),
"gpl3" : License("Licensed under the GNU General Public License v3.", "See " + LICENSE_DIR + "/" + "GPLv3.txt" + " for more information."),
@@ -116,37 +116,37 @@ def check_copyright(filename, hints) :
username, email = get_userinfo()
copyrightSetting = get_copyright_setting(username, email)
for block in copyrightBlocks :
if block.author.content == copyrightSetting.author:
year = block.yearBegin.content if not block.yearEnd else block.yearEnd.content
if int(year) == copyrightSetting.year:
return True
else :
if hints :
- print "Copyright block for " + copyrightSetting.author + " does not cover current year in: " + filename
+ print("Copyright block for " + copyrightSetting.author + " does not cover current year in: " + filename)
return False
if hints :
- print "Missing copyright block for " + copyrightSetting.author + " in: " + filename
+ print("Missing copyright block for " + copyrightSetting.author + " in: " + filename)
return False
else :
if hints :
- print "No copyright found in: " + filename
+ print("No copyright found in: " + filename)
return False
def replace_data_in_file(filename, begin, end, replaceWith) :
with open(filename, 'r') as file:
content = file.read()
with open(filename, 'w') as file:
file.write(content[:begin] + replaceWith + content[end:])
def set_or_update_copyright(filename) :
if check_copyright(filename, False) :
- print "No update required for file: " + filename
+ print("No update required for file: " + filename)
else :
copyrightBlocks = parse_file_new(filename)
username, email = get_userinfo()
copyrightSetting = get_copyright_setting(username, email)
lastBlock = 0
for block in copyrightBlocks :
if block.author.content == copyrightSetting.author :
if not block.yearEnd :
# replace year with range
@@ -155,34 +155,34 @@ def set_or_update_copyright(filename) :
# replace end of range with current year
replace_data_in_file(filename, block.yearEnd.begin, block.yearEnd.end, "%s" % str(copyrightSetting.year))
return
lastBlock = block.total.end
# No copyright block found. Append a new one.
replace_data_in_file(filename, lastBlock+1, lastBlock+1, "\n" + str(copyrightSetting))
def print_help() :
- print """Usage:
+ print("""Usage:
Copyrighter.py check-copyright $filename
Cheks for the existence of a copyright comment block.
Copyrighter.py set-copyright $filename
Adds or updates the existing copyright comment block.
License setting:
A users license configuration can be set via the SWIFT_LICENSE_CONFIG environment variable
in the format "$copyright holder|$license", e.g. "Jane Doe|mit". Possible values for
$license are default, mit and gpl.
- """
+ """)
if sys.argv[1] == "check-copyright" :
file = sys.argv[2]
if (file.endswith(".cpp") or file.endswith(".h")) and not "3rdParty" in file :
if not check_copyright(file, True) :
sys.exit(-1)
elif sys.argv[1] == "set-copyright" :
file = sys.argv[2]
set_or_update_copyright(file)
else :
- print "Unknown command: " + sys.argv[1]
+ print("Unknown command: " + sys.argv[1])
print_help()
sys.exit(-1)
diff --git a/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py b/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py
index dada920..19e5f87 100644
--- a/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py
+++ b/BuildTools/CrashReportAnalysis/WindowsMinidumpAnalyse.py
@@ -1,35 +1,35 @@
#!/usr/bin/env python
# Note
# ----
# This script requires:
# - cdb, the Windows command line debugger installed and available in PATH.
-# - the SWIFT_DIST environment variable set to a locatioon that contains msi and pdb.gz files.
+# - the SWIFT_DIST environment variable set to a location that contains msi and pdb.gz files.
import sys
from subprocess import call
from subprocess import Popen, PIPE
import ntpath
import shutil
import re
import urllib2
import os
import gzip
import time
swiftWindowBuildsPathPrefix = os.getenv("SWIFT_DIST")
if swiftWindowBuildsPathPrefix == None :
- print "Please set the SWIFT_DIST environment variable to a location containing msi and pdb.gz files."
+ print("Please set the SWIFT_DIST environment variable to a location containing msi and pdb.gz files.")
sys.exit(1)
if len(sys.argv) != 3:
- print "Usage: python WindowsMinidumpAnalyse.py VERSION MINIDUMP_FILE"
+ print("Usage: python WindowsMinidumpAnalyse.py VERSION MINIDUMP_FILE")
sys.exit(1)
version = sys.argv[1]
minidump_file = sys.argv[2]
minidump_filename = ntpath.basename(minidump_file)
minidump_fullpath = os.path.abspath(minidump_file)
humantext_fullpath = os.path.splitext(minidump_fullpath)[0]+".txt"
symbol_cache_path = os.path.join(os.getenv("TEMP"), "\symbols")
working_folder = "tmp-crash-{0}".format(minidump_filename)
@@ -87,19 +87,19 @@ def printHumanReadableReport():
cdbFullCommand = ["cdb", "-i", os.getcwd(), "-y", symbolPath, "-z", minidump_filename, "-srcpath", oldDir, "-logo", humantext_fullpath, "-c", cdbCommand ]
print("Run command: " + str(cdbFullCommand))
call(cdbFullCommand)
# for testing, delete the old folder
try:
shutil.rmtree(working_folder)
except:
- print ""
+ print("")
# clone local git repository into dedicated directory
call(["git", "clone", ".", working_folder], shell=True)
# git version from swift version
match = re.match( r"(.*)-dev(\d+)", version)
if match:
basetag = match.group(1)
commits = int(match.group(2))
@@ -114,19 +114,19 @@ else:
exit_code = process.wait()
commit = output.strip()
assert(len(commit) > 0)
# Create symbol cache directory
if not os.path.exists(symbol_cache_path):
os.makedirs(symbol_cache_path)
-#print "Checking out commit {0}.".format(commit)
+#print("Checking out commit {0}.".format(commit))
call(["git", "-C", working_folder, "checkout", commit])
os.chdir(working_folder)
downloadInstaller(version)
downloadDebugSymbols(version)
unpackInstaller(version)
unpackDebugSymbols(version)
copyMinidump(minidump_fullpath)
diff --git a/BuildTools/DocBook/SCons/XSLT.py b/BuildTools/DocBook/SCons/XSLT.py
index 38e36c5..6a40b62 100644
--- a/BuildTools/DocBook/SCons/XSLT.py
+++ b/BuildTools/DocBook/SCons/XSLT.py
@@ -2,19 +2,19 @@ import SCons.Util
import xml.dom.minidom, os, os.path
################################################################################
# XSLT processor
################################################################################
def generate(env) :
def generate_actions(source, target, env, for_signature) :
if not env.has_key("XSLTSTYLESHEET") :
- raise SCons.Errors.UserError, "The XSLTSTYLESHEET construction variable must be defined"
+ raise SCons.Errors.UserError("The XSLTSTYLESHEET construction variable must be defined")
# Process the XML catalog files
# FIXME: It's probably not clean to do an ENV assignment globally
env["ENV"]["XML_CATALOG_FILES"] = " ".join(env.get("XMLCATALOGS", ""))
# Build the XMLLint command
xmllintcmd = ["$XMLLINT", "--nonet", "--xinclude", "--postvalid", "--noout", "$SOURCE"]
# Build the XSLT command
diff --git a/BuildTools/FixIncludes.py b/BuildTools/FixIncludes.py
index 8984944..e532464 100755
--- a/BuildTools/FixIncludes.py
+++ b/BuildTools/FixIncludes.py
@@ -147,19 +147,19 @@ for line in content[headerStart:headerEnd]:
headerType = fileNameToHeaderType(lineToFileName(line))
#filename = lineToFileName(line)
if headerType in headerGroups:
headerGroups[headerType].append(line)
else:
headerGroups[headerType] = [line]
if containsComplexPreprocessorDirectives:
- print "Cannot format headers containing preprocessor #if, #pragma, #define or #undef statements!"
+ print("Cannot format headers containing preprocessor #if, #pragma, #define or #undef statements!")
exit(1)
if filename_base.endswith(".h"):
if not HeaderType.PRAGMA_ONCE in headerGroups:
- print "Missing #pragma once!"
+ print("Missing #pragma once!")
exit(2)
cleanHeaderFile(content, headerStart, headerEnd, headerGroups)
elif filename_base.endswith(".cpp") or filename_base.endswith(".mm"):
cleanImplementationFile(content, headerStart, headerEnd, headerGroups)
diff --git a/BuildTools/GenerateAppCastFeeds.py b/BuildTools/GenerateAppCastFeeds.py
index 8135134..e7493df 100755
--- a/BuildTools/GenerateAppCastFeeds.py
+++ b/BuildTools/GenerateAppCastFeeds.py
@@ -142,12 +142,12 @@ writeAppcastFile(filename=os.path.join(args.outputFolder, "swift-stable-appcast-
writeAppcastFile(filename=os.path.join(args.outputFolder, "swift-testing-appcast-mac.xml"),
title="Swift Testing Releases",
description="",
regexPattern="^\d+(\.\d+)?(\.\d+)?(beta\d+)?(rc\d+)?$",
appcastURL=urlparse.urljoin(args.downloadsURL, "swift-testing-appcast-mac.xml"),
releases=manualReleases)
writeAppcastFile(filename=os.path.join(args.outputFolder, "swift-development-appcast-mac.xml"),
title="Swift Development Releases",
description="",
- regexPattern="^\d+(\.\d+)?(\.\d+)?(alpha)?(beta\d+)?(rc\d+)?(-dev\d+)?$",
+ regexPattern="^\d+(\.\d+)?(\.\d+)?(alpha\d*)?(beta\d+)?(rc\d+)?(-dev\d+)?$",
appcastURL=urlparse.urljoin(args.downloadsURL, "swift-development-appcast-mac.xml"),
releases=automaticReleases)
diff --git a/BuildTools/GetBuildVersion.py b/BuildTools/GetBuildVersion.py
index 70fdc5c..be7cc03 100755
--- a/BuildTools/GetBuildVersion.py
+++ b/BuildTools/GetBuildVersion.py
@@ -10,12 +10,12 @@ only_major = False
if "--major" in sys.argv :
only_major = True
if only_major :
v = Version.getBuildVersion(os.path.dirname(sys.argv[0]) + "/..", sys.argv[1])
version_match = re.match("(\d+)\.(\d+).*", v)
if version_match :
print version_match.group(1)
else :
- print "0"
+ print("0")
else :
print Version.getBuildVersion(os.path.dirname(sys.argv[0]) + "/..", sys.argv[1])
diff --git a/BuildTools/Gource/GetGravatars.py b/BuildTools/Gource/GetGravatars.py
index d1f40a4..17198aa 100755
--- a/BuildTools/Gource/GetGravatars.py
+++ b/BuildTools/Gource/GetGravatars.py
@@ -1,49 +1,49 @@
#!/usr/bin/env python
import subprocess, os, sys, hashlib, urllib
GRAVATAR_URL = "http://www.gravatar.com/avatar/%(id)s?d=404"
if len(sys.argv) != 2 :
- print "Usage: " + sys.argv[0] + " <output-dir>"
+ print("Usage: " + sys.argv[0] + " <output-dir>")
sys.exit(-1)
output_dir = sys.argv[1]
# Retrieve the list of authors
authors = {}
p = subprocess.Popen("git log --pretty=format:'%ae|%an'", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
for line in p.stdout.readlines() :
author_components = line.rstrip().split("|")
authors[author_components[0]] = author_components[1]
p.stdin.close()
if p.wait() != 0 :
- print "Error"
+ print("Error")
sys.exit(-1)
# Get & save the avatars
if not os.path.isdir(output_dir) :
os.makedirs(output_dir)
for email, name in authors.items() :
- print "Processing avatar for " + name + " <" + email + ">"
+ print("Processing avatar for " + name + " <" + email + ">")
filename = os.path.join(output_dir, name + ".png")
if os.path.isfile(filename) :
- print "-> Already there. Skipping."
+ print("-> Already there. Skipping.")
continue
m = hashlib.md5()
m.update(email)
url = GRAVATAR_URL % {"id" : m.hexdigest()}
- print "- Downloading " + url
+ print("- Downloading " + url)
f = urllib.urlopen(url)
input = None
if f.getcode() == 200 :
input = f.read()
f.close()
if input :
- print "- Saving file " + filename
+ print("- Saving file " + filename)
f = open(filename, "w")
f.write(input)
f.close()
else :
- print "- No Gravatar found"
+ print("- No Gravatar found")
diff --git a/BuildTools/ProjectCopyrightSummary.py b/BuildTools/ProjectCopyrightSummary.py
index 6e2d824..f6b18a0 100755
--- a/BuildTools/ProjectCopyrightSummary.py
+++ b/BuildTools/ProjectCopyrightSummary.py
@@ -11,19 +11,19 @@ for directory in ['Documentation', 'Limber', 'Packages', 'QA', 'Slimber', 'Sluif
for filename in filenames:
if any(fnmatch.fnmatch(filename, pattern) for pattern in ['*.cpp', '*.h', '*.mm', '*.m', '*.c']):
projectSourceFiles.append(os.path.join(root, filename))
def CopyrightNames(filename):
names = []
with open(filename, 'r') as file:
data = file.read()
- p = re.compile(ur'\* Copyright.*\d\d\d\d (.*?)\.?$', re.MULTILINE)
+ p = re.compile(r'\* Copyright.*\d\d\d\d (.*?)\.?$', re.MULTILINE)
names = re.findall(p, data)
return names
names = Set()
for file in projectSourceFiles:
copyrightNames = CopyrightNames(file)
for name in copyrightNames:
names.add(name)
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 3b21dde..411fb7d 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -31,19 +31,20 @@ vars.Add(BoolVariable("swiften_dll", "Build Swiften as dynamically linked librar
if os.name != "nt" :
vars.Add(BoolVariable("coverage", "Compile with coverage information", "no"))
if os.name == "posix" :
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"))
if os.name == "nt" :
- vars.Add(PathVariable("vcredist", "MSVC redistributable dir", None, PathVariable.PathAccept))
+ vars.Add(PathVariable("vcredist", "MSVC redistributable path", None, PathVariable.PathAccept))
+ vars.Add(PathVariable("vcredistdir", "MSVC redistributable dir", None, PathVariable.PathAccept))
if os.name == "nt" :
vars.Add(PathVariable("wix_bindir", "Path to WiX binaries", "", PathVariable.PathAccept))
if os.name == "nt" :
vars.Add(PackageVariable("bonjour", "Bonjour SDK location", "yes"))
vars.Add(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("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)
@@ -101,18 +102,19 @@ vars.Add(PathVariable("avahi_libdir", "Avahi library location", None, PathVariab
vars.Add(PathVariable("qt", "Qt location", "", PathVariable.PathAccept))
vars.Add(BoolVariable("qt5", "Compile in Qt5 mode", "yes"))
vars.Add(PathVariable("docbook_xml", "DocBook XML", None, PathVariable.PathAccept))
vars.Add(PathVariable("docbook_xsl", "DocBook XSL", None, PathVariable.PathAccept))
vars.Add(BoolVariable("build_examples", "Build example programs", "yes"))
vars.Add(BoolVariable("enable_variants", "Build in a separate dir under build/, depending on compile flags", "no"))
vars.Add(BoolVariable("experimental_ft", "Build experimental file transfer", "yes"))
vars.Add(BoolVariable("experimental", "Build experimental features", "no"))
vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0", "yes"))
+vars.Add(EnumVariable("msvc_runtime", "Choose MSVC runtime library", "MD", ["MT", "MTd", "MD", "MDd"]))
vars.Add(BoolVariable("unbound", "Build bundled ldns and unbound. Use them for DNS lookup.", "no"))
vars.Add(BoolVariable("check_headers", "Independently build compilation units for all Swiften headers for detecting missing dependencies.", "no"))
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"))
vars.Add(BoolVariable("help2man", "Run help2man to geneate man pages", "false"))
# 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)
@@ -243,18 +245,21 @@ for flags_type in ["ccflags", "cxxflags", "linkflags"] :
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"] = []
+if env["PLATFORM"] != "win32" :
+ env.AppendUnique(CCFLAGS=['-isystem', Dir('#').abspath + '/Backport/'])
+
# 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"])
@@ -266,23 +271,25 @@ 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"])
env.Append(LINKFLAGS = ["/OPT:NOREF"])
- env.Append(CCFLAGS = ["/MD"])
else :
env.Append(CCFLAGS = ["-g"])
-elif env["PLATFORM"] == "win32" :
- env.Append(CCFLAGS = ["/MD"])
+
+if env["PLATFORM"] == "win32" :
+ env.AppendUnique(CCFLAGS = ["/{}".format(env.get("msvc_runtime"))])
+ # debug builds against debug MSVC runtime can cause some more sections in the object file
+ env.AppendUnique(CCFLAGS = ["/bigobj"])
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",
@@ -357,19 +364,18 @@ else :
"-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()
- "-Wno-inconsistent-missing-destructor-override", # FIXME: fix source code issues regarding this warning later
"-Wno-shadow-field", # FIXME: fix source code issues regarding this warning later
"-Wno-unused-template", # FIXME: fix source code issues regarding this warning later
])
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) :
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 6d63d5b..78f388b 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -1,21 +1,21 @@
import sys, os, re, platform
import SCons.SConf
Import("env", "conf_env")
root = Dir("../..").abspath
# Override SConscript to handle tests
oldSConscript = SConscript
-def SConscript(*arguments, **keywords) :
- if not keywords.get("test_only", False) or env["TEST"] :
- return apply(oldSConscript, arguments, keywords)
+def SConscript(*args, **kwargs) :
+ if not kwargs.get("test_only", False) or env["TEST"] :
+ return oldSConscript(*args, **kwargs)
env.SConscript = SConscript
################################################################################
# Extend the default build environment (not affecting the configure env)
#
# Keeping both environments separated mostly because of SCons Issue 2391,
# although it doesn't hurt to separate them (e.g. not have pretty printed
# strings in config.log)
################################################################################
@@ -136,23 +136,23 @@ int main(int argc, char* argv[]) {
return int(ret[1])
else :
return -1
conf = Configure(conf_env, custom_tests = {
'CheckCpp11Support' : checkForCpp11Support,
})
if not conf.CheckCXX() or not conf.CheckCC() :
- print "Error: You need a working compiler"
+ print("Error: You need a working compiler")
Exit(1)
if not conf.CheckCpp11Support() :
- print "Error: You need a compiler with support for the C++11 standard"
+ print("Error: You need a compiler with support for the C++11 standard")
Exit(1)
env["HAVE_ZLIB"] = True
zlib_flags = {}
zlib_okay = False
if env.get("zlib_libdir", None) :
zlib_flags["LIBPATH"] = [env["zlib_libdir"]]
zlib_okay = True
@@ -164,19 +164,19 @@ if env.get("zlib_libfile", None) :
zlib_okay = True
elif zlib_okay :
zlib_flags["LIBS"] = ["z"]
if (not zlib_okay) and conf.CheckLib("z") :
zlib_flags["LIBS"] = ["z"]
zlib_okay = True
if zlib_okay :
env["ZLIB_FLAGS"] = zlib_flags
elif not env.get("zlib_bundled_enable", True) :
- print "Error: Zlib not found and zlib_bundled_enable is false"
+ print("Error: Zlib not found and zlib_bundled_enable is false")
Exit(1)
else :
env["ZLIB_BUNDLED"] = True
if conf.CheckLib("resolv") :
env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["resolv"]
if env["PLATFORM"] != "win32" :
if conf.CheckLib("pthread") :
@@ -232,19 +232,19 @@ for (lib, header) in boostLibs :
libNames.append(libName)
if not env.get("boost_force_bundled") and allLibsPresent :
env["BOOST_FLAGS"] = boost_flags
if env["PLATFORM"] != "win32" :
env["BOOST_FLAGS"].update({"LIBS": libNames})
if not conf.CheckCXXHeader("boost/uuid/uuid.hpp") :
# FIXME: Remove this workaround when UUID is available in most distros
env["BOOST_BUNDLED_UUID_ONLY"] = True
elif not env.get("boost_bundled_enable", True) :
- print "Error: Boost not found and boost_bundled_enable is false"
+ print("Error: Boost not found and boost_bundled_enable is false")
Exit(1)
else :
env["BOOST_BUNDLED"] = True
boost_version = GetVersion(conf, "BOOST_VERSION", "boost/version.hpp")
if boost_version == 106400 :
#Version 1.64 has some issues with the serialization of boost::optional, see https://svn.boost.org/trac10/ticket/13050
env["BOOST_1_64_DETECTED"] = True
else:
env["BOOST_1_64_DETECTED"] = False
@@ -367,19 +367,19 @@ if env.get("try_expat", True) and not env.get("HAVE_LIBXML",0) :
if conf.CheckCHeader("expat.h") and conf.CheckLib(env["expat_libname"]) :
env["HAVE_EXPAT"] = 1
env["EXPAT_FLAGS"] = { "LIBS": [env["expat_libname"]] }
env["EXPAT_FLAGS"].update(expat_flags)
conf.Finish()
# Bundled expat
bundledExpat = False
if not env.get("HAVE_EXPAT", 0) and not env.get("HAVE_LIBXML", 0) :
- print "Expat or LibXML not found. Using bundled Expat"
+ print("Expat or LibXML not found. Using bundled Expat")
SConscript("#/3rdParty/Expat/SConscript")
env["HAVE_EXPAT"] = 1
env["EXPAT_BUNDLED"] = True
################################################################################
# IDN library
################################################################################
env["NEED_IDN"] = env.get("need_idn", True)
@@ -418,22 +418,22 @@ if env.get("try_libidn", True) and not env.get("HAVE_ICU") and conf.CheckCHeader
env["LIBIDN_FLAGS"].update(libidn_flags)
conf.Finish()
# Fallback to bundled LibIDN
if not env.get("HAVE_ICU", False) and not env.get("HAVE_LIBIDN", False) :
if env.get("libidn_bundled_enable", True) :
env["HAVE_LIBIDN"] = 1
env["LIBIDN_BUNDLED"] = 1
elif env.get("need_idn", True):
- print "Error: ICU and LIBIDN not found, and libidn_bundled_enable is false"
+ print("Error: ICU and LIBIDN not found, and libidn_bundled_enable is false")
Exit(1)
else:
- print "Proceeding without an IDN library because need_idn was false. This will break all internal binaries"
+ print("Proceeding without an IDN library because need_idn was false. This will break all internal binaries")
# Unbound
if env["unbound"] :
env["LDNS_BUNDLED"] = 1
env["UNBOUND_BUNDLED"] = 1
else :
env["LDNS_FLAGS"] = {}
env["UNBOUND_FLAGS"] = {}
@@ -508,19 +508,19 @@ if env.get("lua_includedir", None) :
lua_conf_env.MergeFlags(lua_flags)
conf = Configure(lua_conf_env)
if not env.get("lua_force_bundled", False) and conf.CheckLibWithHeader(env["lua_libname"], "lua.hpp", "cxx", autoadd = 0) :
env["HAVE_LUA"] = 1
env["LUA_FLAGS"] = { "LIBS": [env["lua_libname"]] }
lua_version = GetVersion(conf, "LUA_VERSION_NUM", "lua.h")
if lua_version > 0 :
env["LUA_FLAGS"]["LUA_VERSION"] = str(lua_version // 100) + "." + str(lua_version % 100)
else :
- print "Warning: Unable to determine Lua version. Not installing Lua libraries."
+ print("Warning: Unable to determine Lua version. Not installing Lua libraries.")
env["LUA_FLAGS"].update(lua_flags)
else :
env["LUA_BUNDLED"] = 1
conf.Finish()
# Readline
editline_conf_env = conf_env.Clone()
editline_flags = {}
if env.get("editline_libdir", None) :
@@ -548,18 +548,22 @@ if env.get("try_avahi", True) and conf.CheckCHeader("avahi-client/client.h") and
env["HAVE_AVAHI"] = True
env["AVAHI_FLAGS"] = { "LIBS": ["avahi-client", "avahi-common"] }
env["AVAHI_FLAGS"].update(avahi_flags)
conf.Finish()
# Qt
if env["qt"] :
env["QTDIR"] = env["qt"]
+if env["PLATFORM"] == "win32" :
+ systemIncludeFlag = "/I"
+else:
+ systemIncludeFlag = "-isystem"
################################################################################
# TLS backend selection
################################################################################
env["OPENSSL_FLAGS"] = {}
if env.get("tls_backend") == "native" :
if env["PLATFORM"] == "win32" :
env["HAVE_SCHANNEL"] = True
elif env["PLATFORM"] == "darwin" and env["target"] == "native":
@@ -577,21 +581,21 @@ elif env.get("tls_backend") == "openssl" :
use_openssl = bool(env["openssl"])
openssl_prefix = ""
if isinstance(env["openssl"], str) :
openssl_prefix = env["openssl"]
openssl_flags = {}
if openssl_prefix :
openssl_include = env.get("openssl_include")
openssl_libdir = env.get("openssl_libdir")
if openssl_include:
- openssl_flags = {"CPPPATH":[openssl_include]}
+ openssl_flags = { "CPPFLAGS": [systemIncludeFlag + openssl_include]}
else:
- openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] }
+ openssl_flags = { "CPPFLAGS": [systemIncludeFlag + os.path.join(openssl_prefix, "include")] }
if openssl_libdir:
openssl_flags["LIBPATH"] = [openssl_libdir]
env["OPENSSL_DIR"] = openssl_prefix
elif env["PLATFORM"] == "win32" :
openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib", "VC")]
env["OPENSSL_DIR"] = openssl_prefix
else :
openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib")]
openssl_env.MergeFlags(openssl_flags)
@@ -660,19 +664,19 @@ if env["PLATFORM"] == "darwin" :
# Qt
try :
myenv = env.Clone()
myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
env["HAVE_QT"] = True
except SCons.Errors.StopError:
env["HAVE_QT"] = False
except Exception as e:
- print "Info: %s" % str(e)
+ print("Info: %s" % str(e))
env["HAVE_QT"] = False
################################################################################
# DocBook setup
################################################################################
if env.get("docbook_xml") :
env["DOCBOOK_XML_DIR"] = env["docbook_xml"]
if env.get("docbook_xsl") :
@@ -682,33 +686,35 @@ if env.get("docbook_xsl") :
################################################################################
# Set up git hooks
################################################################################
try:
if env.Dir("#/.git").exists() :
if not env.GetOption("clean") and env.get("install_git_hooks", True) :
env.Install("#/.git/hooks", Glob("#/BuildTools/Git/Hooks/*"))
except TypeError:
- print "You seem to be using Swift in a Git submodule. Not installing hooks."
+ print("You seem to be using Swift in a Git submodule. Not installing hooks.")
################################################################################
# Replace #pragma once with proper guards on platforms that require it
################################################################################
if ARGUMENTS.get("replace_pragma_once", False) :
env.Tool("ReplacePragmaOnce", toolpath = ["#/BuildTools/SCons/Tools"])
def relpath(path, start) :
i = len(os.path.commonprefix([path, start]))
return path[i+1:]
for actual_root, dirs, files in os.walk(root) :
+ dirs.sort()
+ files.sort()
if "3rdParty" in actual_root :
continue
for file in files :
if not file.endswith(".h") :
continue
include = relpath(os.path.join(actual_root, file), root)
env.ReplacePragmaOnce("#/include/" + include, "#/" + include)
env.Append(CPPPATH = ["#/include"])
else :
@@ -723,66 +729,66 @@ if ARGUMENTS.get("dump_trace", False) :
env.SetOption("no_exec", True)
env["TEST"] = True
env["BOOST_BUILD_BCP"] = True
env.Decider(lambda x, y, z : True)
SCons.Node.Python.Value.changed_since_last_build = (lambda x, y, z: True)
# Modules
modules = []
if os.path.isdir(Dir("#/3rdParty").abspath) :
- for dir in os.listdir(Dir("#/3rdParty").abspath) :
+ for dir in sorted(os.listdir(Dir("#/3rdParty").abspath)) :
full_dir = os.path.join(Dir("#/3rdParty").abspath, dir)
if not os.path.isdir(full_dir) :
continue
sconscript = os.path.join(full_dir, "SConscript")
if os.path.isfile(sconscript) :
modules.append("3rdParty/" + dir)
-for dir in os.listdir(Dir("#").abspath) :
+for dir in sorted(os.listdir(Dir("#").abspath)) :
full_dir = os.path.join(Dir("#").abspath, dir)
if not os.path.isdir(full_dir) :
continue
sconscript = os.path.join(full_dir, "SConscript")
if os.path.isfile(sconscript) :
modules.append(dir)
# QA comes last
modules.remove("QA")
modules.append("QA")
# Flags
env["PROJECTS"] = [m for m in modules if m not in ["Documentation", "QA", "SwifTools"] and not m.startswith("3rdParty")]
for stage in ["flags", "build"] :
env["SCONS_STAGE"] = stage
- SConscript(dirs = map(lambda x : root + "/" + x, modules))
+ SConscript(dirs = list(map(lambda x : root + "/" + x, modules)))
# SLOCCount
if ARGUMENTS.get("sloccount", False) :
for project in env["PROJECTS"] :
env.SLOCCount("#/" + project)
################################################################################
# Print summary
################################################################################
-print
-print " Build Configuration"
-print " -------------------"
+print("")
+print(" Build Configuration")
+print(" -------------------")
parsers = []
if env.get("HAVE_LIBXML", 0):
parsers.append("LibXML")
if env.get("HAVE_EXPAT", 0):
parsers.append("Expat")
if env.get("EXPAT_BUNDLED", False) :
parsers.append("(Bundled)")
-print " Projects: " + ' '.join(env["PROJECTS"])
-print ""
-print " XML Parsers: " + ' '.join(parsers)
+print(" Projects: " + ' '.join(env["PROJECTS"]))
+print("")
+print(" XML Parsers: " + ' '.join(parsers))
-print " TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" or env.get("HAVE_SECURETRANSPORT",0) and "Secure Transport" or env.get("HAVE_SCHANNEL", 0) and "Schannel" or "Disabled")
-print " DNSSD Support: " + (env.get("HAVE_BONJOUR") and "Bonjour" or (env.get("HAVE_AVAHI") and "Avahi" or "Disabled"))
-print
+print(" TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" or env.get("HAVE_SECURETRANSPORT",0) and "Secure Transport" or env.get("HAVE_SCHANNEL", 0) and "Schannel" or "Disabled"))
+print(" DNSSD Support: " + (env.get("HAVE_BONJOUR") and "Bonjour" or (env.get("HAVE_AVAHI") and "Avahi" or "Disabled")))
+print("")
if not GetOption("help") and not env.get("HAVE_OPENSSL", 0) and not env.get("HAVE_SCHANNEL", 0) and not env.get("HAVE_SECURETRANSPORT", 0):
- print "Error: A working TLS backend is required. Please check the documentation for more information."
+ print("Error: A working TLS backend is required. Please check the documentation for more information.")
Exit(1)
diff --git a/BuildTools/SCons/Tools/AppBundle.py b/BuildTools/SCons/Tools/AppBundle.py
index 337e83f..31cfef1 100644
--- a/BuildTools/SCons/Tools/AppBundle.py
+++ b/BuildTools/SCons/Tools/AppBundle.py
@@ -28,35 +28,35 @@ def generate(env) :
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"
+ plist += "<string>" + value + "</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>
</array>\n"""
if sparklePublicDSAKey :
plist += "<key>SUPublicDSAKeyFile</key>"
- plist += "<string>" + sparklePublicDSAKey.name.encode("utf-8") + "</string>"
+ plist += "<string>" + sparklePublicDSAKey.name + "</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)
diff --git a/BuildTools/SCons/Tools/InstallWithSymLinks.py b/BuildTools/SCons/Tools/InstallWithSymLinks.py
index 23d12ed..4955192 100644
--- a/BuildTools/SCons/Tools/InstallWithSymLinks.py
+++ b/BuildTools/SCons/Tools/InstallWithSymLinks.py
@@ -68,33 +68,33 @@ def scons_copytree(src, dst, symlinks=False):
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:
+ except (IOError, os.error) as 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:
+ except CopytreeError as 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:
+ except OSError as why:
errors.extend((src, dst, str(why)))
if errors:
- raise CopytreeError, 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)
diff --git a/BuildTools/SCons/Tools/WindowsBundle.py b/BuildTools/SCons/Tools/WindowsBundle.py
index 20d41ff..4d73fa3 100644
--- a/BuildTools/SCons/Tools/WindowsBundle.py
+++ b/BuildTools/SCons/Tools/WindowsBundle.py
@@ -27,19 +27,19 @@ def generate(env) :
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'"([^\"]*)" "([^\"]*)"')
+ p = re.compile(r'"([^\"]*)" "([^\"]*)"')
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') :
@@ -77,34 +77,47 @@ def generate(env) :
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)
+ # Add QtWebKit dependencies.
+ # This is needed as QtWebKit since 5.6 is developed and released seperately
+ # of Qt and windeployqt does not know about its dependencies anymore.
+ for map_from, map_to in qtmappings:
+ if map_to == "Qt5WebKit.dll":
+ # hidden Qt5WebKit dependencies
+ hidden_dependencies = ["libxml2.dll", "libxslt.dll"]
+ for dependency in hidden_dependencies:
+ dependency_from_path = os.path.join(env["QTDIR"], "bin", dependency)
+ if os.path.isfile(dependency_from_path):
+ qtmappings.append((dependency_from_path, dependency))
+ break
+
# handle core DLLs
- qt_corelib_regex = re.compile(ur".*bin.*\\(.*)\.dll")
+ qt_corelib_regex = re.compile(r".*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")
+ qt_plugin_regex = re.compile(r".*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
@@ -113,10 +126,9 @@ def generate(env) :
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"
-
diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py
index d5c14e2..372b261 100644
--- a/BuildTools/SCons/Tools/qt4.py
+++ b/BuildTools/SCons/Tools/qt4.py
@@ -31,18 +31,19 @@ selection method.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Tool/qt.py 0.96.92.D001 2006/04/10 23:13:27 knight"
import os.path
import re
import subprocess
+from string import Template
import SCons.Action
import SCons.Builder
import SCons.Defaults
import SCons.Scanner
import SCons.Tool
import SCons.Util
import SCons.SConf
@@ -123,73 +124,75 @@ class _Automoc:
# 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
+ objBuilder.env = env.Clone()
+ if os.path.basename(objBuilder.env ["CXX"]).startswith(("gcc", "clang")):
+ objBuilder.env.Append(CXXFLAGS = "-w")
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)
+ if isinstance(obj,str): # 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)
+ 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)
+ 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()
+ cpp_contents = str(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))
+ print("scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp)))
#h_contents = comment.sub('', h.get_contents())
- h_contents = h.get_contents()
+ h_contents = str(h.get_contents())
break
if not h and debug:
- print "scons: qt: no header for '%s'." % (str(cpp))
+ 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))
+ 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))
+ 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')
@@ -338,19 +341,19 @@ def generate(env):
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()
+ contents = str(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',
@@ -362,20 +365,42 @@ def generate(env):
source_scanner = qrcscanner,
src_suffix = '$QT4_QRCSUFFIX',
suffix = '$QT4_QRCCXXSUFFIX',
prefix = '$QT4_QRCCXXPREFIX',
single_source = True
)
env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
# Interface builder
+ def addDisableWarningsPragmaToFile(target, source, env):
+ assert( len(target) == 1 )
+ assert( len(source) == 1 )
+ srcf = str(source[0])
+ dstf = str(target[0])
+ with open(dstf, 'r+') as uiHeader:
+ data=uiHeader.read()
+
+ template = Template(
+"""#pragma once
+#pragma warning(push, 0)
+#pragma GCC system_header
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wall"
+$uiheadertext
+#pragma clang diagnostic pop
+#pragma warning(pop)
+""")
+ uiHeader.seek(0)
+ uiHeader.write(template.substitute(uiheadertext=data))
+ uiHeader.truncate()
+
uic4builder = Builder(
- action = SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'),
+ action = [SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'), SCons.Action.Action(addDisableWarningsPragmaToFile, None)],
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
diff --git a/BuildTools/SCons/Tools/textfile.py b/BuildTools/SCons/Tools/textfile.py
index cc58666..73105ad 100644
--- a/BuildTools/SCons/Tools/textfile.py
+++ b/BuildTools/SCons/Tools/textfile.py
@@ -101,25 +101,29 @@ def _action(target, source, env):
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:
+ except (OSError,IOError) as 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).encode("utf-8"))
+ stringtowrite = _do_subst(s, subs)
+ if isinstance(stringtowrite, str):
+ fd.write(stringtowrite)
+ elif isinstance(stringtowrite, unicode):
+ fd.write(stringtowrite.encode('utf-8'))
lsep = linesep
fd.close()
def _strfunc(target, source, env):
return "Creating '%s'" % target[0]
def _convert_list_R(newlist, sources):
for elem in sources:
if is_Sequence(elem):
diff --git a/BuildTools/SCons/Tools/wix.py b/BuildTools/SCons/Tools/wix.py
index 907b6d9..889afe4 100644
--- a/BuildTools/SCons/Tools/wix.py
+++ b/BuildTools/SCons/Tools/wix.py
@@ -32,20 +32,19 @@ def generate(env) :
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}',
+ action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -loc Swift\\Packaging\\WiX\\Swift_en-us.wxl -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
-
diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py
index f215a5d..001374a 100644
--- a/BuildTools/SCons/Version.py
+++ b/BuildTools/SCons/Version.py
@@ -11,19 +11,19 @@ def getGitBuildVersion(root, project) :
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
+ # 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)
diff --git a/BuildTools/TranslationCoverage.xslt b/BuildTools/TranslationCoverage.xslt
new file mode 100644
index 0000000..4329174
--- /dev/null
+++ b/BuildTools/TranslationCoverage.xslt
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<!--
+
+To use this XSLT, run it with xsltproc:
+
+ xsltproc BuildTools/TranslationCoverage.xslt Swift/Translations/swift_nl.ts
+
+Supported parameters:
+
+ full if set to 1 or true, generate a full report instead of the default oneliner.
+
+-->
+
+<xsl:param name="full" select="'0'" />
+<xsl:param name="filename" />
+<xsl:output method="text" />
+
+<xsl:variable name="contexts" select="count(TS/context)"/>
+<xsl:variable name="vanished" select="count(TS/context/message/translation[@type = 'vanished'])"/>
+<xsl:variable name="obsolete" select="count(TS/context/message/translation[@type = 'obsolete'])"/>
+<xsl:variable name="strings" select="count(TS/context/message/source) - $vanished - $obsolete"/>
+<xsl:variable name="translations" select="count(TS/context/message/translation[not(@type) and text()])"/>
+<xsl:variable name="missing" select="$strings - $translations"/>
+<xsl:variable name="percent_done" select="floor($translations div $strings * 100)"/>
+
+<xsl:template match="/TS">
+ <xsl:choose>
+ <xsl:when test="$full != '0' and $full != 'false'"><xsl:call-template name="full" /></xsl:when>
+ <xsl:otherwise><xsl:call-template name="terse" /></xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="terse"><xsl:value-of select="$percent_done"/>% complete, <xsl:value-of select="$vanished"/> vanished, <xsl:value-of select="$obsolete"/> obsolete, <xsl:value-of select="$missing"/> missing
+</xsl:template>
+
+<xsl:template name="full"><xsl:if test="$filename">Report for <xsl:value-of select="$filename" />:
+
+</xsl:if>Contexts: <xsl:value-of select="$contexts"/>
+Active Strings: <xsl:value-of select="$strings"/>
+Translations: <xsl:value-of select="$translations"/>, <xsl:value-of select="$percent_done"/>% complete
+Missing: <xsl:value-of select="$missing"/>
+Vanished: <xsl:value-of select="$vanished"/>
+Obsolete: <xsl:value-of select="$obsolete"/>
+
+Note: Strings and Translations do not include vanished or obsolete messages.
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/BuildTools/UpdateDebianChangelog.py b/BuildTools/UpdateDebianChangelog.py
index 1d0e3ea..d7e1f1b 100755
--- a/BuildTools/UpdateDebianChangelog.py
+++ b/BuildTools/UpdateDebianChangelog.py
@@ -14,28 +14,27 @@ project = ""
last_version = ""
m = re.match("([\w-]+) \((.*)-\d+\)", last_version_line)
if m :
project = m.group(1)
last_version = m.group(2)
if project == "" :
project="swift-im"
-if "dev" in version :
+if "dev" in version or "alpha" in version :
distribution = "development"
elif "beta" in version or "rc" in version :
distribution = "beta development"
else :
distribution = "release beta development"
if last_version != version :
changelog = open(sys.argv[1])
changelog_data = changelog.read()
changelog.close()
changelog = open(sys.argv[1], "w")
changelog.write(project + " (" + version + "-1)" + " " + distribution + "; urgency=low\n\n")
changelog.write(" * Upstream development snapshot\n\n")
changelog.write(" -- Swift Package Maintainer <packages@swift.im> " + email.utils.formatdate() + "\n")
changelog.write("\n")
changelog.write(changelog_data)
changelog.close()
-
diff --git a/BuildTools/scons2ninja.py b/BuildTools/scons2ninja.py
index 6c77c88..df4c655 100755
--- a/BuildTools/scons2ninja.py
+++ b/BuildTools/scons2ninja.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
################################################################################
#
# scons2ninja: A script to create a Ninja build file from SCons.
#
# Copyright (c) 2013 Remko Tronçon
# Licensed under the simplified BSD license.
# See COPYING for details.
#
@@ -198,21 +198,21 @@ class NinjaBuilder :
result += "\n"
result += self.pools + "\n"
result += self.rules + "\n"
result += self._build + "\n"
return result
def to_string(self, lst, quote = False) :
if is_list(lst) :
if quote :
- return ' '.join([quote_spaces(x) for x in lst])
+ return ' '.join([quote_spaces(x) for x in lst])
else :
- return ' '.join([escape(x) for x in lst])
+ return ' '.join([escape(x) for x in lst])
if is_regexp(lst) :
return ' '.join([escape(x) for x in self.targets if lst.match(x)])
return escape(lst)
def get_flags_variable(self, flags_type, flags) :
if len(flags) == 0 :
return ''
if flags_type not in self._flags :
self._flags[flags_type] = {}
@@ -242,20 +242,20 @@ scons_dependencies = [os.path.normpath(x) for x in scons_dependencies]
################################################################################
# Rules
################################################################################
ninja = NinjaBuilder()
ninja.pool('scons_pool', depth = 1)
if sys.platform == 'win32' :
- ninja.rule('cl',
- deps = 'msvc',
+ ninja.rule('cl',
+ deps = 'msvc',
command = '$cl /showIncludes $clflags -c $in /Fo$out',
description = 'CXX $out')
ninja.rule('link',
command = '$link $in $linkflags $libs /out:$out',
description = 'LINK $out')
ninja.rule('link_mt',
command = '$link $in $linkflags $libs /out:$out ; $mt $mtflags',
@@ -363,19 +363,19 @@ previous_file = None
f = subprocess.Popen(scons_generate_cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True)
stage = 'preamble'
skip_nth_line = -1
stack = ['.']
for line in f.stdout :
line = line.rstrip()
# Skip lines if requested from previous command
if skip_nth_line >= 0 :
- skip_nth_line -= 1
+ skip_nth_line -= 1
if skip_nth_line == 0 :
continue
if line.startswith('scons: done building targets') :
break
if stage == "preamble" :
# Pass all lines from the SCons configuration step to output
if re.match("^scons: Building targets ...", line) :
@@ -401,19 +401,19 @@ for line in f.stdout :
elif stage == "dependencies" :
if not re.match('^[\s|]+\+\-', line) :
# Work around bug in SCons that splits output over multiple lines
continue
level = line.index('+-') / 2
filename = line[level*2+2:]
if filename.startswith('[') :
- filename = filename[1:-1]
+ filename = filename[1:-1]
# Check if we use the 'fixed' format which escapes filenamenames
if filename.startswith('\'') and filename.endswith('\'') :
filename = eval(filename)
if level < len(stack) :
stack = stack[0:level]
elif level > len(stack) :
if level != len(stack) + 1 :
@@ -423,19 +423,19 @@ for line in f.stdout :
# Skip absolute paths
if not os.path.isabs(filename) :
target = stack[-1]
if target not in dependencies :
dependencies[target] = []
dependencies[target].append(filename)
previous_filename = filename
if f.wait() != 0 :
- print "Error calling '" + scons_generate_cmd + "'"
+ print("Error calling '" + scons_generate_cmd + "'")
print f.stderr.read()
exit(-1)
# Pass 2: Parse build rules
tools = {}
for line in build_lines :
# Custom python function
m = re.match('^(\w+)\(\[([^\]]*)\]', line)
if m :
@@ -522,22 +522,22 @@ for line in build_lines :
ninja.build(out, 'lib', files, libflags = flags)
elif tool == 'link':
objects, flags = partition(flags, lambda x: x.endswith('.obj') or x.endswith('.res'))
out, flags = extract_unary_flag("/out:", flags)
libs, flags = partition(flags, lambda x: not x.startswith("/") and x.endswith(".lib"))
libpaths = get_unary_flags("/libpath:", flags)
deps = get_built_libs(libs, libpaths, ninja.targets)
if out in mtflags :
- ninja.build(out, 'link_mt', objects, deps = sorted(deps),
+ ninja.build(out, 'link_mt', objects, deps = sorted(deps),
libs = libs, linkflags = flags, mtflags = mtflags[out])
else :
- ninja.build(out, 'link', objects, deps = sorted(deps),
+ ninja.build(out, 'link', objects, deps = sorted(deps),
libs = libs, linkflags = flags)
elif tool == 'rc':
out, flags = extract_unary_flag("/fo", flags)
files, flags = extract_non_flags(flags)
ninja.build(out, 'rc', files[0], order_deps = '_generated_headers', rcflags = flags)
elif tool == 'mt':
# Already handled
@@ -583,22 +583,24 @@ for line in build_lines :
elif tool == 'dsymutil':
out, flags = extract_binary_flag("-o", flags)
files, flags = extract_non_flags(flags)
ninja.build(out, 'dsymutil', files, dsymutilflags = flags)
elif tool == 'sdef' :
source = flags[0];
outdir, flags = extract_binary_flag("-o", flags)
basename, flags = extract_binary_flag("--basename", flags)
- ninja.build(os.path.join(outdir, basename + ".h"), 'sdef', [source],
+ ninja.build(os.path.join(outdir, basename + ".h"), 'sdef', [source],
basename = basename,
outdir = outdir)
+ elif tool == 'checker':
+ pass
elif not ninja_custom_command(ninja, line) :
raise Exception("Unknown tool: '" + line + "'")
# Phony target for all generated headers, used as an order-only depency from all C/C++ sources
ninja.build('_generated_headers', 'phony', ninja.header_targets())
# Regenerate build.ninja file