summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'BuildTools')
-rwxr-xr-xBuildTools/CheckHeaders.py46
-rwxr-xr-xBuildTools/CheckTests.py48
-rwxr-xr-xBuildTools/CheckTranslations.py70
-rwxr-xr-xBuildTools/Copyright/find-contribs.py80
-rwxr-xr-xBuildTools/Copyrighter.py276
-rwxr-xr-xBuildTools/Coverage/FilterLCovData.py24
-rwxr-xr-xBuildTools/Coverage/GenerateSummary.py32
-rwxr-xr-xBuildTools/Cppcheck.sh36
-rw-r--r--BuildTools/DocBook/SCons/DocBook.py162
-rw-r--r--BuildTools/DocBook/SCons/FO.py64
-rw-r--r--BuildTools/DocBook/SCons/XSLT.py106
-rwxr-xr-xBuildTools/FilterScanBuildResults.py38
-rwxr-xr-xBuildTools/FixIncludes.py196
-rwxr-xr-xBuildTools/GetBuildVersion.py16
-rwxr-xr-xBuildTools/Gource/GetGravatars.py56
-rwxr-xr-xBuildTools/InstallSwiftDependencies.sh44
-rw-r--r--BuildTools/SCons/Tools/AppBundle.py100
-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/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.py1012
-rw-r--r--BuildTools/SCons/Tools/textfile.py218
-rw-r--r--BuildTools/SCons/Tools/wix.py86
-rw-r--r--BuildTools/SCons/Version.py110
-rwxr-xr-xBuildTools/UpdateDebianChangelog.py32
-rwxr-xr-xBuildTools/scons2ninja.py916
33 files changed, 2143 insertions, 2143 deletions
diff --git a/BuildTools/CheckHeaders.py b/BuildTools/CheckHeaders.py
index 8d20f4e..79ff85c 100755
--- a/BuildTools/CheckHeaders.py
+++ b/BuildTools/CheckHeaders.py
@@ -3,18 +3,18 @@
import os, sys
FORBIDDEN_INCLUDES = [
- ("iostream", ["Swiften/Base/format.h"]),
- ("Base/Log.h", []),
- ("Base/format.h", []),
- ("algorithm", ["Swiften/Base/Algorithm.h", "Swiften/Base/SafeAllocator.h", "Swiften/Base/Listenable.h", "Swiften/Base/Concat.h"]),
- ("boost/bind.hpp", ["Swiften/Base/Listenable.h", "Swiften/FileTransfer/S5BTransportSession.h"]),
- ("boost/filesystem.hpp", []),
- ("Base/foreach.h", []),
- ("boost/date_time/date_time.hpp", []),
- ("boost/filesystem/filesystem.hpp", []),
-
- # To avoid
- ("Base/Algorithm.h", ["Swiften/StringCodecs/HMAC.h"]),
+ ("iostream", ["Swiften/Base/format.h"]),
+ ("Base/Log.h", []),
+ ("Base/format.h", []),
+ ("algorithm", ["Swiften/Base/Algorithm.h", "Swiften/Base/SafeAllocator.h", "Swiften/Base/Listenable.h", "Swiften/Base/Concat.h"]),
+ ("boost/bind.hpp", ["Swiften/Base/Listenable.h", "Swiften/FileTransfer/S5BTransportSession.h"]),
+ ("boost/filesystem.hpp", []),
+ ("Base/foreach.h", []),
+ ("boost/date_time/date_time.hpp", []),
+ ("boost/filesystem/filesystem.hpp", []),
+
+ # To avoid
+ ("Base/Algorithm.h", ["Swiften/StringCodecs/HMAC.h"]),
]
foundBadHeaders = False
@@ -22,21 +22,21 @@ foundBadHeaders = False
filename = sys.argv[1]
if "3rdParty" in filename or ".sconf" in filename or ".framework" in filename or not filename.endswith(".h") :
- sys.exit(0)
+ sys.exit(0)
if not "Swiften" in filename :
- sys.exit(0)
+ sys.exit(0)
if filename.endswith("Swiften.h") :
- sys.exit(0)
+ sys.exit(0)
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
- foundBadHeaders = True
+ 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
+ foundBadHeaders = True
sys.exit(foundBadHeaders)
diff --git a/BuildTools/CheckTests.py b/BuildTools/CheckTests.py
index 0ea56bd..7f160e7 100755
--- a/BuildTools/CheckTests.py
+++ b/BuildTools/CheckTests.py
@@ -5,29 +5,29 @@ import os, sys, re
foundUnregisteredTests = False
for (path, dirs, files) in os.walk(".") :
- if not "3rdParty" in path :
- for filename in [os.path.join(path, file) for file in files if file.endswith("Test.cpp") and file != "IdleQuerierTest.cpp" and file != "NotifierTest.cpp" and file != "ClientTest.cpp" and file != "ConnectivityTest.cpp" and file != "ReconnectTest.cpp"] :
- file = open(filename, "r")
- isRegistered = False
- registeredTests = set()
- declaredTests = set()
- for line in file.readlines() :
- m = re.match("\s*CPPUNIT_TEST_SUITE_REGISTRATION\((.*)\)", line)
- if m :
- isRegistered = True
- m = re.match("\s*CPPUNIT_TEST\((.*)\)", line)
- if m :
- registeredTests.add(m.group(1))
- continue
- m = re.match("\s*void (test.*)\(\)", line)
- if m :
- declaredTests.add(m.group(1))
- if not isRegistered :
- print filename + ": Registration missing"
- foundUnregisteredTests = True
- if registeredTests - declaredTests != set([]) :
- print filename + ": " + str(registeredTests - declaredTests)
- foundUnregisteredTests = True
- file.close()
+ if not "3rdParty" in path :
+ for filename in [os.path.join(path, file) for file in files if file.endswith("Test.cpp") and file != "IdleQuerierTest.cpp" and file != "NotifierTest.cpp" and file != "ClientTest.cpp" and file != "ConnectivityTest.cpp" and file != "ReconnectTest.cpp"] :
+ file = open(filename, "r")
+ isRegistered = False
+ registeredTests = set()
+ declaredTests = set()
+ for line in file.readlines() :
+ m = re.match("\s*CPPUNIT_TEST_SUITE_REGISTRATION\((.*)\)", line)
+ if m :
+ isRegistered = True
+ m = re.match("\s*CPPUNIT_TEST\((.*)\)", line)
+ if m :
+ registeredTests.add(m.group(1))
+ continue
+ m = re.match("\s*void (test.*)\(\)", line)
+ if m :
+ declaredTests.add(m.group(1))
+ if not isRegistered :
+ print filename + ": Registration missing"
+ foundUnregisteredTests = True
+ if registeredTests - declaredTests != set([]) :
+ print filename + ": " + str(registeredTests - declaredTests)
+ foundUnregisteredTests = True
+ file.close()
sys.exit(foundUnregisteredTests)
diff --git a/BuildTools/CheckTranslations.py b/BuildTools/CheckTranslations.py
index a9b6afd..615f81f 100755
--- a/BuildTools/CheckTranslations.py
+++ b/BuildTools/CheckTranslations.py
@@ -3,48 +3,48 @@
import os, sys, re, xml.dom.minidom
def getText(nodelist):
- text = ""
- for node in nodelist:
- if node.nodeType == node.TEXT_NODE:
- text += node.data
- return text
+ text = ""
+ for node in nodelist:
+ if node.nodeType == node.TEXT_NODE:
+ text += node.data
+ return text
desktop_generic_names = set()
desktop_comments = set()
f = open("Swift/resources/swift.desktop", "r")
for l in f.readlines() :
- m = re.match("GenericName\[(\w+)\].*", l)
- if m :
- desktop_generic_names.add(m.group(1))
- m = re.match("Comment\[(\w+)\].*", l)
- if m :
- desktop_comments.add(m.group(1))
+ m = re.match("GenericName\[(\w+)\].*", l)
+ if m :
+ desktop_generic_names.add(m.group(1))
+ m = re.match("Comment\[(\w+)\].*", l)
+ if m :
+ desktop_comments.add(m.group(1))
f.close()
for filename in os.listdir("Swift/Translations") :
- m = re.match("swift_(.*)\.ts", filename)
- if m :
- language = m.group(1)
- finished = True
- f = open("Swift/Translations/" + filename, "r")
- document = xml.dom.minidom.parse(f)
- f.close()
+ m = re.match("swift_(.*)\.ts", filename)
+ if m :
+ language = m.group(1)
+ finished = True
+ f = open("Swift/Translations/" + filename, "r")
+ document = xml.dom.minidom.parse(f)
+ f.close()
- for message in document.getElementsByTagName("message") :
- 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 + "'"
- if not finished :
- print "[Warning] " + filename + ": Unfinished"
- if language not in desktop_generic_names and language != "en" :
- 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
+ for message in document.getElementsByTagName("message") :
+ 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 + "'"
+ if not finished :
+ print "[Warning] " + filename + ": Unfinished"
+ if language not in desktop_generic_names and language != "en" :
+ 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
diff --git a/BuildTools/Copyright/find-contribs.py b/BuildTools/Copyright/find-contribs.py
index 63c454e..ac30afb 100755
--- a/BuildTools/Copyright/find-contribs.py
+++ b/BuildTools/Copyright/find-contribs.py
@@ -3,46 +3,46 @@
import subprocess
def print_log(full_log):
- full_log_lines = full_log.split("\n")
-
- commits = []
-
- commit_bit = "commit "
- author_bit = "Author: "
- date_bit = "Date: "
-
- commit = None
- for line in full_log_lines:
-
- if line[0:len(commit_bit)] == commit_bit:
- if commit:
- commits.append(commit)
- commit = {'text':''}
- handled = False
- for bit in [commit_bit, author_bit, date_bit]:
- if line[0:len(bit)] == bit:
- commit[bit] = line
- handled = True
- if not handled:
- commit['text'] += line
-
- commits.append(commit)
-
- contributions = []
-
- for commit in commits:
- if not "git@kismith.co.uk" in commit[author_bit] and not "git@el-tramo.be" in commit[author_bit]:
- contributions.append(commit)
-
- #print contributions
- contributors = {}
- for commit in contributions:
- 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_log_lines = full_log.split("\n")
+
+ commits = []
+
+ commit_bit = "commit "
+ author_bit = "Author: "
+ date_bit = "Date: "
+
+ commit = None
+ for line in full_log_lines:
+
+ if line[0:len(commit_bit)] == commit_bit:
+ if commit:
+ commits.append(commit)
+ commit = {'text':''}
+ handled = False
+ for bit in [commit_bit, author_bit, date_bit]:
+ if line[0:len(bit)] == bit:
+ commit[bit] = line
+ handled = True
+ if not handled:
+ commit['text'] += line
+
+ commits.append(commit)
+
+ contributions = []
+
+ for commit in commits:
+ if not "git@kismith.co.uk" in commit[author_bit] and not "git@el-tramo.be" in commit[author_bit]:
+ contributions.append(commit)
+
+ #print contributions
+ contributors = {}
+ for commit in contributions:
+ 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"])
diff --git a/BuildTools/Copyrighter.py b/BuildTools/Copyrighter.py
index a3b6379..a16050c 100755
--- a/BuildTools/Copyrighter.py
+++ b/BuildTools/Copyrighter.py
@@ -11,32 +11,32 @@ LICENSE_DIR = "Documentation/Licenses"
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 *\*\/)')
class License :
- def __init__(self, name, file) :
- self.name = name
- self.file = file
+ 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."),
- "mit" : License("Licensed under the MIT License.", "See " + LICENSE_DIR + "/" + "MIT.txt" + " for more information."),
- }
+ "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."),
+ "mit" : License("Licensed under the MIT License.", "See " + LICENSE_DIR + "/" + "MIT.txt" + " for more information."),
+ }
class Copyright :
- def __init__(self, author, year, license) :
- self.author = author
- self.year = year
- self.license = license
-
- def to_string(self, comment_chars) :
- return "\n".join([
- comment_chars[0],
- comment_chars[1] + " Copyright (c) %(year)s %(name)s" % {"year" : self.year, "name" : self.author },
- comment_chars[1] + licenses[self.license].name,
- comment_chars[1] + licenses[self.license].file,
- comment_chars[2],
- "\n"])
- def __str__(self):
- return """/*
+ def __init__(self, author, year, license) :
+ self.author = author
+ self.year = year
+ self.license = license
+
+ def to_string(self, comment_chars) :
+ return "\n".join([
+ comment_chars[0],
+ comment_chars[1] + " Copyright (c) %(year)s %(name)s" % {"year" : self.year, "name" : self.author },
+ comment_chars[1] + licenses[self.license].name,
+ comment_chars[1] + licenses[self.license].file,
+ comment_chars[2],
+ "\n"])
+ def __str__(self):
+ return """/*
* Copyright (c) %s %s.
* %s
* %s
@@ -44,145 +44,145 @@ class Copyright :
""" % (self.year, self.author, licenses[self.license].name, licenses[self.license].file)
class ContentRef :
- def __init__(self, begin, end, content):
- self.begin = begin
- self.end = end
- self.content = content
+ def __init__(self, begin, end, content):
+ self.begin = begin
+ self.end = end
+ self.content = content
class CopyrightBlock :
- def __init__(self, yearBegin, yearEnd, author, license, seeMore, total):
- self.yearBegin = yearBegin
- self.yearEnd = yearEnd
- self.author = author
- self.license = license
- self.seeMore = seeMore
- self.total = total
+ def __init__(self, yearBegin, yearEnd, author, license, seeMore, total):
+ self.yearBegin = yearBegin
+ self.yearEnd = yearEnd
+ self.author = author
+ self.license = license
+ self.seeMore = seeMore
+ self.total = total
def cref_from_group(match, group):
- if match.group(group):
- return ContentRef(match.start(group), match.end(group), match.group(group))
- else :
- return None
+ if match.group(group):
+ return ContentRef(match.start(group), match.end(group), match.group(group))
+ else :
+ return None
def parse_file_new(filename):
- copyrightBlocks = []
- with open(filename, 'r') as file:
- content = file.read()
- for match in re.finditer(reParseLicenseCommentBlocks, content):
- copyrightBlocks.append(CopyrightBlock(
- cref_from_group(match, "startYear"),
- cref_from_group(match, "endYear"),
- cref_from_group(match, "author"),
- cref_from_group(match, "license"),
- cref_from_group(match, "seeMore"),
- cref_from_group(match, 0)))
- return copyrightBlocks
+ copyrightBlocks = []
+ with open(filename, 'r') as file:
+ content = file.read()
+ for match in re.finditer(reParseLicenseCommentBlocks, content):
+ copyrightBlocks.append(CopyrightBlock(
+ cref_from_group(match, "startYear"),
+ cref_from_group(match, "endYear"),
+ cref_from_group(match, "author"),
+ cref_from_group(match, "license"),
+ cref_from_group(match, "seeMore"),
+ cref_from_group(match, 0)))
+ return copyrightBlocks
def get_userinfo() :
- p = subprocess.Popen("git config user.name", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
- username = p.stdout.read().rstrip()
- p.stdin.close()
- if p.wait() != 0 :
- return None
- p = subprocess.Popen("git config user.email", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
- email = p.stdout.read().rstrip()
- p.stdin.close()
- if p.wait() != 0 :
- return None
- return (username, email)
+ p = subprocess.Popen("git config user.name", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
+ username = p.stdout.read().rstrip()
+ p.stdin.close()
+ if p.wait() != 0 :
+ return None
+ p = subprocess.Popen("git config user.email", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
+ email = p.stdout.read().rstrip()
+ p.stdin.close()
+ if p.wait() != 0 :
+ return None
+ return (username, email)
def get_copyright(username, email) :
- if email in ["git@el-tramo.be", "git@kismith.co.uk"] :
- license = DEFAULT_LICENSE
- else :
- license = CONTRIBUTOR_LICENSE
- return Copyright(username, datetime.date.today().strftime("%Y"), license)
+ if email in ["git@el-tramo.be", "git@kismith.co.uk"] :
+ license = DEFAULT_LICENSE
+ else :
+ license = CONTRIBUTOR_LICENSE
+ return Copyright(username, datetime.date.today().strftime("%Y"), license)
def get_copyright_setting(username, email) :
- config = os.getenv("SWIFT_LICENSE_CONFIG")
- if config :
- copyrightHolder, license = config.split("|")
- else :
- if email.endswith("isode.com") or email in ["git@el-tramo.be", "git@kismith.co.uk", "tm@ayena.de"] :
- copyrightHolder, license = "Isode Limited", "default"
- else :
- copyrightHolder, license = username, "mit"
- return Copyright(copyrightHolder, datetime.date.today().year, license)
+ config = os.getenv("SWIFT_LICENSE_CONFIG")
+ if config :
+ copyrightHolder, license = config.split("|")
+ else :
+ if email.endswith("isode.com") or email in ["git@el-tramo.be", "git@kismith.co.uk", "tm@ayena.de"] :
+ copyrightHolder, license = "Isode Limited", "default"
+ else :
+ copyrightHolder, license = username, "mit"
+ return Copyright(copyrightHolder, datetime.date.today().year, license)
def check_copyright(filename, hints) :
- copyrightBlocks = parse_file_new(filename)
- if copyrightBlocks :
- # looking for copyright block for current author
- 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
- return False
- if hints :
- print "Missing copyright block for " + copyrightSetting.author + " in: " + filename
- return False
- else :
- if hints :
- print "No copyright found in: " + filename
- return False
+ copyrightBlocks = parse_file_new(filename)
+ if copyrightBlocks :
+ # looking for copyright block for current author
+ 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
+ return False
+ if hints :
+ print "Missing copyright block for " + copyrightSetting.author + " in: " + filename
+ return False
+ else :
+ if hints :
+ 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:])
+ 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
- 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
- replace_data_in_file(filename, block.yearBegin.begin, block.yearBegin.end, "%s-%s" % (block.yearBegin.content, str(copyrightSetting.year)))
- else :
- # 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))
+ if check_copyright(filename, False) :
+ 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
+ replace_data_in_file(filename, block.yearBegin.begin, block.yearBegin.end, "%s-%s" % (block.yearBegin.content, str(copyrightSetting.year)))
+ else :
+ # 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:
- Copyrighter.py check-copyright $filename
- Cheks for the existence of a copyright comment block.
+ 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.
+ 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.
- """
+ 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)
+ 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)
+ file = sys.argv[2]
+ set_or_update_copyright(file)
else :
- print "Unknown command: " + sys.argv[1]
- print_help()
- sys.exit(-1)
+ print "Unknown command: " + sys.argv[1]
+ print_help()
+ sys.exit(-1)
diff --git a/BuildTools/Coverage/FilterLCovData.py b/BuildTools/Coverage/FilterLCovData.py
index 33fd682..e0f5c92 100755
--- a/BuildTools/Coverage/FilterLCovData.py
+++ b/BuildTools/Coverage/FilterLCovData.py
@@ -7,23 +7,23 @@ import sys, re, os.path
assert(len(sys.argv) == 2)
def isIgnored(file) :
- return (file.find("/Swiften/") == -1 and file.find("/Slimber/") == -1 and file.find("/Swift/") == -1) or (file.find("/UnitTest/") != -1 or file.find("/QA/") != -1)
+ return (file.find("/Swiften/") == -1 and file.find("/Slimber/") == -1 and file.find("/Swift/") == -1) or (file.find("/UnitTest/") != -1 or file.find("/QA/") != -1)
output = []
inputFile = open(sys.argv[1])
inIgnoredFile = False
for line in inputFile.readlines() :
- if inIgnoredFile :
- if line == "end_of_record\n" :
- inIgnoredFile = False
- else :
- if line.startswith("SF:") and isIgnored(line) :
- inIgnoredFile = True
- else :
- m = re.match("SF:(.*)", line)
- if m :
- line = "SF:" + os.path.realpath(m.group(1)) + "\n"
- output.append(line)
+ if inIgnoredFile :
+ if line == "end_of_record\n" :
+ inIgnoredFile = False
+ else :
+ if line.startswith("SF:") and isIgnored(line) :
+ inIgnoredFile = True
+ else :
+ m = re.match("SF:(.*)", line)
+ if m :
+ line = "SF:" + os.path.realpath(m.group(1)) + "\n"
+ output.append(line)
inputFile.close()
outputFile = open(sys.argv[1], 'w')
diff --git a/BuildTools/Coverage/GenerateSummary.py b/BuildTools/Coverage/GenerateSummary.py
index e572082..9de0f4d 100755
--- a/BuildTools/Coverage/GenerateSummary.py
+++ b/BuildTools/Coverage/GenerateSummary.py
@@ -8,27 +8,27 @@ inputFile = open(sys.argv[1])
currentFile = ""
coverage = {}
for line in inputFile.readlines() :
- line = line.strip()
- m = re.match("^SF:(.*)", line)
- if m :
- currentFile = m.group(1)
- else :
- m = re.match("^DA:(\d+),(\d+)", line)
- if m :
- currentFileCoverage = coverage.get(currentFile, {})
- line = int(m.group(1))
- count = int(m.group(2))
- currentFileCoverage[line] = currentFileCoverage.get(line, 0) + count
- coverage[currentFile] = currentFileCoverage
+ line = line.strip()
+ m = re.match("^SF:(.*)", line)
+ if m :
+ currentFile = m.group(1)
+ else :
+ m = re.match("^DA:(\d+),(\d+)", line)
+ if m :
+ currentFileCoverage = coverage.get(currentFile, {})
+ line = int(m.group(1))
+ count = int(m.group(2))
+ currentFileCoverage[line] = currentFileCoverage.get(line, 0) + count
+ coverage[currentFile] = currentFileCoverage
inputFile.close()
totalLines = 0
coveredLines = 0
for c in coverage.values() :
- totalLines += len(c)
- for l in c.values() :
- if l > 0 :
- coveredLines += 1
+ totalLines += len(c)
+ for l in c.values() :
+ if l > 0 :
+ coveredLines += 1
outputFile = open(sys.argv[2], 'w')
outputFile.write(str(coveredLines) + "/" + str(totalLines))
diff --git a/BuildTools/Cppcheck.sh b/BuildTools/Cppcheck.sh
index 9f14cb2..ee52b9b 100755
--- a/BuildTools/Cppcheck.sh
+++ b/BuildTools/Cppcheck.sh
@@ -1,21 +1,21 @@
#!/bin/sh
cppcheck $@ \
- --enable=all \
- --inline-suppr \
- --suppress=postfixOperator:3rdParty/hippomocks.h \
- --suppress=stlSize:3rdParty/hippomocks.h \
- --suppress=noConstructor \
- --suppress=publicAllocationError:Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp \
- -i 3rdParty -i .git -i .sconf_temp \
- -i Swift/QtUI/EventViewer/main.cpp \
- -i Swift/QtUI/ApplicationTest \
- -i Swift/QtUI/ChatView/main.cpp \
- -i Swift/QtUI/Roster/main.cpp \
- -i Swift/QtUI/NotifierTest/NotifierTest.cpp \
- -DSWIFTEN_BUILDING -DSWIFTEN_STATIC \
- -U__BEOS__ -U__CYGWIN__ -U__QNNXTO__ -U__amigaos__ -Uhpux -U__sgi \
- \
- -I . \
- -I Swift/QtUI \
- .
+ --enable=all \
+ --inline-suppr \
+ --suppress=postfixOperator:3rdParty/hippomocks.h \
+ --suppress=stlSize:3rdParty/hippomocks.h \
+ --suppress=noConstructor \
+ --suppress=publicAllocationError:Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp \
+ -i 3rdParty -i .git -i .sconf_temp \
+ -i Swift/QtUI/EventViewer/main.cpp \
+ -i Swift/QtUI/ApplicationTest \
+ -i Swift/QtUI/ChatView/main.cpp \
+ -i Swift/QtUI/Roster/main.cpp \
+ -i Swift/QtUI/NotifierTest/NotifierTest.cpp \
+ -DSWIFTEN_BUILDING -DSWIFTEN_STATIC \
+ -U__BEOS__ -U__CYGWIN__ -U__QNNXTO__ -U__amigaos__ -Uhpux -U__sgi \
+ \
+ -I . \
+ -I Swift/QtUI \
+ .
diff --git a/BuildTools/DocBook/SCons/DocBook.py b/BuildTools/DocBook/SCons/DocBook.py
index 7641b65..ffb0bfc 100644
--- a/BuildTools/DocBook/SCons/DocBook.py
+++ b/BuildTools/DocBook/SCons/DocBook.py
@@ -6,100 +6,100 @@ import SCons.Util, SCons.Action
import xml.dom.minidom, re, os.path, sys
def generate(env) :
- # Location of stylesheets and catalogs
- docbook_dir = "#/BuildTools/DocBook"
- docbook_xsl_style_dir = env.Dir(docbook_dir + "/Stylesheets").abspath
- docbook_xml_catalog = env.File("catalog.xml").abspath
- if "DOCBOOK_XML_DIR" in env :
- docbook_xml_dir = env.Dir("$DOCBOOK_XML_DIR").abspath
- else :
- docbook_xml_dir = env.Dir("#/3rdParty/DocBook/XML").abspath
- if "DOCBOOK_XSL_DIR" in env :
- docbook_xsl_dir = env.Dir("$DOCBOOK_XSL_DIR").abspath
- else :
- docbook_xsl_dir = env.Dir("#/3rdParty/DocBook/XSL").abspath
- fop_fonts_dir = env.Dir(docbook_dir + "/Fonts").abspath
-
- # Generates a catalog from paths to external tools
- def buildCatalog(target, source, env) :
- catalog = """<?xml version='1.0'?>
+ # Location of stylesheets and catalogs
+ docbook_dir = "#/BuildTools/DocBook"
+ docbook_xsl_style_dir = env.Dir(docbook_dir + "/Stylesheets").abspath
+ docbook_xml_catalog = env.File("catalog.xml").abspath
+ if "DOCBOOK_XML_DIR" in env :
+ docbook_xml_dir = env.Dir("$DOCBOOK_XML_DIR").abspath
+ else :
+ docbook_xml_dir = env.Dir("#/3rdParty/DocBook/XML").abspath
+ if "DOCBOOK_XSL_DIR" in env :
+ docbook_xsl_dir = env.Dir("$DOCBOOK_XSL_DIR").abspath
+ else :
+ docbook_xsl_dir = env.Dir("#/3rdParty/DocBook/XSL").abspath
+ fop_fonts_dir = env.Dir(docbook_dir + "/Fonts").abspath
+
+ # Generates a catalog from paths to external tools
+ def buildCatalog(target, source, env) :
+ catalog = """<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
- <rewriteSystem
- systemIdStartString="http://www.oasis-open.org/docbook/xml/4.5/"
- rewritePrefix="%(docbook_xml_dir)s/" />
- <rewriteSystem
- systemIdStartString="docbook-xsl:/"
- rewritePrefix="%(docbook_xsl_dir)s/" />
+ <rewriteSystem
+ systemIdStartString="http://www.oasis-open.org/docbook/xml/4.5/"
+ rewritePrefix="%(docbook_xml_dir)s/" />
+ <rewriteSystem
+ systemIdStartString="docbook-xsl:/"
+ rewritePrefix="%(docbook_xsl_dir)s/" />
</catalog>"""
- docbook_xml_dir = source[0].get_contents()
- docbook_xsl_dir = source[1].get_contents()
- if env["PLATFORM"] == "win32" :
- docbook_xml_dir = docbook_xml_dir.replace("\\","/")
- docbook_xsl_dir = docbook_xsl_dir.replace("\\","/")
- file = open(target[0].abspath, "w")
- file.write(catalog % {
- "docbook_xml_dir" : docbook_xml_dir,
- "docbook_xsl_dir" : docbook_xsl_dir,
- })
- file.close()
-
- # Generates a FOP config file
- def buildFopConfig(target, source, env) :
- fopcfg = """<fop version=\"1.0\">
- <renderers>
- <renderer mime=\"application/pdf\">
- <fonts>
- <directory recursive=\"true\">%(fonts_dir)s</directory>
- </fonts>
- </renderer>
- </renderers>
+ docbook_xml_dir = source[0].get_contents()
+ docbook_xsl_dir = source[1].get_contents()
+ if env["PLATFORM"] == "win32" :
+ docbook_xml_dir = docbook_xml_dir.replace("\\","/")
+ docbook_xsl_dir = docbook_xsl_dir.replace("\\","/")
+ file = open(target[0].abspath, "w")
+ file.write(catalog % {
+ "docbook_xml_dir" : docbook_xml_dir,
+ "docbook_xsl_dir" : docbook_xsl_dir,
+ })
+ file.close()
+
+ # Generates a FOP config file
+ def buildFopConfig(target, source, env) :
+ fopcfg = """<fop version=\"1.0\">
+ <renderers>
+ <renderer mime=\"application/pdf\">
+ <fonts>
+ <directory recursive=\"true\">%(fonts_dir)s</directory>
+ </fonts>
+ </renderer>
+ </renderers>
</fop>"""
- file = open(target[0].abspath, "w")
- file.write(fopcfg % {
- "fonts_dir" : source[0].get_contents()
- })
- file.close()
+ file = open(target[0].abspath, "w")
+ file.write(fopcfg % {
+ "fonts_dir" : source[0].get_contents()
+ })
+ file.close()
- # Builds a DocBook file
- def buildDocBook(env, source) :
- db_env = env.Clone()
- db_env["XMLCATALOGS"] = [docbook_xml_catalog]
- db_env["ENV"].update({"OS" : os.environ.get("OS", "")})
+ # Builds a DocBook file
+ def buildDocBook(env, source) :
+ db_env = env.Clone()
+ db_env["XMLCATALOGS"] = [docbook_xml_catalog]
+ db_env["ENV"].update({"OS" : os.environ.get("OS", "")})
- db_env["XMLLINT"] = env.WhereIs("xmllint")
- db_env["XSLT"] = env.WhereIs("xsltproc")
- db_env["FO"] = env.WhereIs("fop")
+ db_env["XMLLINT"] = env.WhereIs("xmllint")
+ db_env["XSLT"] = env.WhereIs("xsltproc")
+ db_env["FO"] = env.WhereIs("fop")
- if not db_env["XMLLINT"] or not db_env["XSLT"] :
- return
+ if not db_env["XMLLINT"] or not db_env["XSLT"] :
+ return
- # PDF generation
- if db_env["FO"] :
- fo = db_env.XSLT(os.path.splitext(source)[0] + ".fo", source,
- XSLTSTYLESHEET = db_env["DOCBOOK_XSL_FO"])
- pdf = db_env.FO(fo)
+ # PDF generation
+ if db_env["FO"] :
+ fo = db_env.XSLT(os.path.splitext(source)[0] + ".fo", source,
+ XSLTSTYLESHEET = db_env["DOCBOOK_XSL_FO"])
+ pdf = db_env.FO(fo)
- # HTML generation
- db_env.XSLT(os.path.splitext(source)[0] + ".html", source,
- XSLTSTYLESHEET = db_env["DOCBOOK_XSL_HTML"])
+ # HTML generation
+ db_env.XSLT(os.path.splitext(source)[0] + ".html", source,
+ XSLTSTYLESHEET = db_env["DOCBOOK_XSL_HTML"])
- # Import tools
- env.Tool("FO", toolpath = [docbook_dir + "/SCons"])
- env.Tool("XSLT", toolpath = [docbook_dir + "/SCons"])
+ # Import tools
+ env.Tool("FO", toolpath = [docbook_dir + "/SCons"])
+ env.Tool("XSLT", toolpath = [docbook_dir + "/SCons"])
- # Catalog file generation
- env.Command("catalog.xml", [env.Value(docbook_xml_dir), env.Value(docbook_xsl_dir)], SCons.Action.Action(buildCatalog, cmdstr = "$GENCOMSTR"))
+ # Catalog file generation
+ env.Command("catalog.xml", [env.Value(docbook_xml_dir), env.Value(docbook_xsl_dir)], SCons.Action.Action(buildCatalog, cmdstr = "$GENCOMSTR"))
- # FO config file generation
- env["FOCFG"] = env.File("fop.cfg").abspath
- env.Command("fop.cfg", [env.Value(fop_fonts_dir)], SCons.Action.Action(buildFopConfig, cmdstr = "$GENCOMSTR"))
+ # FO config file generation
+ env["FOCFG"] = env.File("fop.cfg").abspath
+ env.Command("fop.cfg", [env.Value(fop_fonts_dir)], SCons.Action.Action(buildFopConfig, cmdstr = "$GENCOMSTR"))
- # DocBook stylesheets
- env["DOCBOOK_XSL_FO"] = docbook_xsl_style_dir + "/fo/docbook.xsl"
- env["DOCBOOK_XSL_HTML"] = docbook_xsl_style_dir + "/html/docbook.xsl"
- env.AddMethod(buildDocBook, "DocBook")
+ # DocBook stylesheets
+ env["DOCBOOK_XSL_FO"] = docbook_xsl_style_dir + "/fo/docbook.xsl"
+ env["DOCBOOK_XSL_HTML"] = docbook_xsl_style_dir + "/html/docbook.xsl"
+ env.AddMethod(buildDocBook, "DocBook")
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/DocBook/SCons/FO.py b/BuildTools/DocBook/SCons/FO.py
index a4079d7..c1c5614 100644
--- a/BuildTools/DocBook/SCons/FO.py
+++ b/BuildTools/DocBook/SCons/FO.py
@@ -6,40 +6,40 @@ import xml.dom.minidom, re
################################################################################
def generate(env) :
- def generate_actions(source, target, env, for_signature) :
- if len(env["FOCFG"]) > 0 :
- cmd = "$FO -c $FOCFG $FOFLAGS $SOURCE $TARGET"
- else :
- cmd = "$FO $FOFLAGS $SOURCE $TARGET"
- return SCons.Action.Action(cmd, cmdstr = "$FOCOMSTR")
+ def generate_actions(source, target, env, for_signature) :
+ if len(env["FOCFG"]) > 0 :
+ cmd = "$FO -c $FOCFG $FOFLAGS $SOURCE $TARGET"
+ else :
+ cmd = "$FO $FOFLAGS $SOURCE $TARGET"
+ return SCons.Action.Action(cmd, cmdstr = "$FOCOMSTR")
- def modify_sources(target, source, env) :
- if len(env["FOCFG"]) > 0 :
- source.append(env["FOCFG"])
- return target, source
+ def modify_sources(target, source, env) :
+ if len(env["FOCFG"]) > 0 :
+ source.append(env["FOCFG"])
+ return target, source
- def scan_fo(node, env, path) :
- dependencies = set()
- try :
- document = xml.dom.minidom.parseString(node.get_contents())
- except xml.parsers.expat.ExpatError:
- return []
- for include in document.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Format", "external-graphic") :
- m = re.match("url\((.*)\)", include.getAttribute("src"))
- if m :
- dependencies.add(m.group(1))
- return list(dependencies)
+ def scan_fo(node, env, path) :
+ dependencies = set()
+ try :
+ document = xml.dom.minidom.parseString(node.get_contents())
+ except xml.parsers.expat.ExpatError:
+ return []
+ for include in document.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Format", "external-graphic") :
+ m = re.match("url\((.*)\)", include.getAttribute("src"))
+ if m :
+ dependencies.add(m.group(1))
+ return list(dependencies)
- env["FO"] = "fop"
- env["FOFLAGS"] = ""
- env["FOCFG"] = ""
- env["BUILDERS"]["FO"] = SCons.Builder.Builder(
- generator = generate_actions,
- emitter = modify_sources,
- source_scanner = SCons.Scanner.Scanner(function = scan_fo, skeys = [".fo"]),
- suffix = ".pdf",
- src_suffix = ".fo"
- )
+ env["FO"] = "fop"
+ env["FOFLAGS"] = ""
+ env["FOCFG"] = ""
+ env["BUILDERS"]["FO"] = SCons.Builder.Builder(
+ generator = generate_actions,
+ emitter = modify_sources,
+ source_scanner = SCons.Scanner.Scanner(function = scan_fo, skeys = [".fo"]),
+ suffix = ".pdf",
+ src_suffix = ".fo"
+ )
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/DocBook/SCons/XSLT.py b/BuildTools/DocBook/SCons/XSLT.py
index 825f129..38e36c5 100644
--- a/BuildTools/DocBook/SCons/XSLT.py
+++ b/BuildTools/DocBook/SCons/XSLT.py
@@ -6,58 +6,58 @@ import xml.dom.minidom, os, os.path
################################################################################
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"
-
- # 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
- xsltcmd = ["$XSLT", "--nonet", "--xinclude"]
- for (param, value) in env["XSLTPARAMS"] :
- xsltcmd += ["--stringparam", param, value]
- xsltcmd += ["-o", "$TARGET", "$XSLTSTYLESHEET", "$SOURCE"]
-
- return [
- SCons.Action.Action([xmllintcmd], cmdstr = "$XMLLINTCOMSTR"),
- SCons.Action.Action([xsltcmd], cmdstr = "$XSLTCOMSTR")]
-
- def modify_sources(target, source, env) :
- if len(env["FOCFG"]) > 0 :
- source.append(env["FOCFG"])
- source.append(env.get("XMLCATALOGS", []))
- return target, source
-
- def scan_xml(node, env, path) :
- dependencies = set()
- nodes = [node]
- while len(nodes) > 0 :
- node = nodes.pop()
- try :
- document = xml.dom.minidom.parseString(node.get_contents())
- except xml.parsers.expat.ExpatError:
- continue
- for include in document.getElementsByTagNameNS("http://www.w3.org/2001/XInclude", "include") :
- include_file = include.getAttribute("href")
- dependencies.add(include_file)
- if include.getAttribute("parse") != "text" :
- nodes.append(env.File(include_file))
- return list(dependencies)
-
- env["XMLLINT"] = "xmllint"
- env["XSLT"] = "xsltproc"
- env["XSLTPARAMS"] = []
- env["BUILDERS"]["XSLT"] = SCons.Builder.Builder(
- generator = generate_actions,
- emitter = modify_sources,
- source_scanner = SCons.Scanner.Scanner(function = scan_xml),
- src_suffix = ".xml"
- )
+ 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"
+
+ # 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
+ xsltcmd = ["$XSLT", "--nonet", "--xinclude"]
+ for (param, value) in env["XSLTPARAMS"] :
+ xsltcmd += ["--stringparam", param, value]
+ xsltcmd += ["-o", "$TARGET", "$XSLTSTYLESHEET", "$SOURCE"]
+
+ return [
+ SCons.Action.Action([xmllintcmd], cmdstr = "$XMLLINTCOMSTR"),
+ SCons.Action.Action([xsltcmd], cmdstr = "$XSLTCOMSTR")]
+
+ def modify_sources(target, source, env) :
+ if len(env["FOCFG"]) > 0 :
+ source.append(env["FOCFG"])
+ source.append(env.get("XMLCATALOGS", []))
+ return target, source
+
+ def scan_xml(node, env, path) :
+ dependencies = set()
+ nodes = [node]
+ while len(nodes) > 0 :
+ node = nodes.pop()
+ try :
+ document = xml.dom.minidom.parseString(node.get_contents())
+ except xml.parsers.expat.ExpatError:
+ continue
+ for include in document.getElementsByTagNameNS("http://www.w3.org/2001/XInclude", "include") :
+ include_file = include.getAttribute("href")
+ dependencies.add(include_file)
+ if include.getAttribute("parse") != "text" :
+ nodes.append(env.File(include_file))
+ return list(dependencies)
+
+ env["XMLLINT"] = "xmllint"
+ env["XSLT"] = "xsltproc"
+ env["XSLTPARAMS"] = []
+ env["BUILDERS"]["XSLT"] = SCons.Builder.Builder(
+ generator = generate_actions,
+ emitter = modify_sources,
+ source_scanner = SCons.Scanner.Scanner(function = scan_xml),
+ src_suffix = ".xml"
+ )
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/FilterScanBuildResults.py b/BuildTools/FilterScanBuildResults.py
index ed4a55f..a4861ac 100755
--- a/BuildTools/FilterScanBuildResults.py
+++ b/BuildTools/FilterScanBuildResults.py
@@ -6,23 +6,23 @@ resultsDir = sys.argv[1]
resultDirs = [ d for d in os.listdir(resultsDir) if os.path.isdir(os.path.join(resultsDir, d)) ]
resultDirs.sort()
if len(resultDirs) > 0 :
- resultDir = os.path.join(resultsDir, resultDirs[-1])
- resultFileName = os.path.join(resultDir, "index.html")
- resultData = []
- f = open(resultFileName, "r")
- skipLines = 0
- for line in f.readlines() :
- if skipLines > 0 :
- skipLines -= 1
- else :
- if ("3rdParty" in line or "SHA1.cpp" in line or "lua.c" in line) :
- m = re.match(".*(report-.*\.html)", line)
- os.remove(os.path.join(resultDir, m.group(1)))
- skipLines = 2
- else :
- resultData.append(line)
- f.close()
+ resultDir = os.path.join(resultsDir, resultDirs[-1])
+ resultFileName = os.path.join(resultDir, "index.html")
+ resultData = []
+ f = open(resultFileName, "r")
+ skipLines = 0
+ for line in f.readlines() :
+ if skipLines > 0 :
+ skipLines -= 1
+ else :
+ if ("3rdParty" in line or "SHA1.cpp" in line or "lua.c" in line) :
+ m = re.match(".*(report-.*\.html)", line)
+ os.remove(os.path.join(resultDir, m.group(1)))
+ skipLines = 2
+ else :
+ resultData.append(line)
+ f.close()
- f = open(resultFileName, "w")
- f.writelines(resultData)
- f.close()
+ f = open(resultFileName, "w")
+ f.writelines(resultData)
+ f.close()
diff --git a/BuildTools/FixIncludes.py b/BuildTools/FixIncludes.py
index d409a2c..d1b8268 100755
--- a/BuildTools/FixIncludes.py
+++ b/BuildTools/FixIncludes.py
@@ -9,7 +9,7 @@ filename = sys.argv[1]
inPlace = False
if "-i" in sys.argv:
- inPlace = True
+ inPlace = True
filename_base = os.path.basename(filename)
(filename_name, filename_ext) = os.path.splitext(filename_base)
@@ -19,144 +19,144 @@ c_stdlib_headers = Set(["assert.h", "limits.h", "signal.h", "stdlib.h", "ctyp
cpp_stdlib_headers = Set(["algorithm", "fstream", "list", "regex", "typeindex", "array", "functional", "locale", "set", "typeinfo", "atomic", "future", "map", "sstream", "type_traits", "bitset", "initializer_list", "memory", "stack", "unordered_map", "chrono", "iomanip", "mutex", "stdexcept", "unordered_set", "codecvt", "ios", "new", "streambuf", "utility", "complex", "iosfwd", "numeric", "string", "valarray", "condition_variable", "iostream", "ostream", "strstream", "vector", "deque", "istream", "queue", "system_error", "exception", "iterator", "random", "thread", "forward_list", "limits", "ratio", "tuple", "cassert", "ciso646", "csetjmp", "cstdio", "ctime", "cctype", "climits", "csignal", "cstdlib", "cwchar", "cerrno", "clocale", "cstdarg", "cstring", "cwctype", "cfloat", "cmath", "cstddef"])
class HeaderType:
- PRAGMA_ONCE, CORRESPONDING_HEADER, C_STDLIB, CPP_STDLIB, BOOST, QT, OTHER, SWIFTEN, LIMBER, SLIMBER, SWIFT_CONTROLLERS, SLUIFT, SWIFTOOLS, SWIFT = range(14)
+ PRAGMA_ONCE, CORRESPONDING_HEADER, C_STDLIB, CPP_STDLIB, BOOST, QT, OTHER, SWIFTEN, LIMBER, SLIMBER, SWIFT_CONTROLLERS, SLUIFT, SWIFTOOLS, SWIFT = range(14)
def findHeaderBlock(lines):
- start = False
- end = False
- lastLine = None
-
- for idx, line in enumerate(lines):
- if not start and line.startswith("#"):
- start = idx
- elif start and (not end) and (not line.startswith("#")) and line.strip():
- end = idx-1
- break
- if not end:
- end = len(lines)
- return (start, end)
+ start = False
+ end = False
+ lastLine = None
+
+ for idx, line in enumerate(lines):
+ if not start and line.startswith("#"):
+ start = idx
+ elif start and (not end) and (not line.startswith("#")) and line.strip():
+ end = idx-1
+ break
+ if not end:
+ end = len(lines)
+ return (start, end)
def lineToFileName(line):
- match = re.match( r'#include "(.*)"', line)
- if match:
- return match.group(1)
- match = re.match( r'#include <(.*)>', line)
- if match:
- return match.group(1)
- return False
+ match = re.match( r'#include "(.*)"', line)
+ if match:
+ return match.group(1)
+ match = re.match( r'#include <(.*)>', line)
+ if match:
+ return match.group(1)
+ return False
def fileNameToHeaderType(name):
- if name.endswith("/" + filename_name + ".h"):
- return HeaderType.CORRESPONDING_HEADER
+ if name.endswith("/" + filename_name + ".h"):
+ return HeaderType.CORRESPONDING_HEADER
- if name in c_stdlib_headers:
- return HeaderType.C_STDLIB
+ if name in c_stdlib_headers:
+ return HeaderType.C_STDLIB
- if name in cpp_stdlib_headers:
- return HeaderType.CPP_STDLIB
+ if name in cpp_stdlib_headers:
+ return HeaderType.CPP_STDLIB
- if name.startswith("boost"):
- return HeaderType.BOOST
+ if name.startswith("boost"):
+ return HeaderType.BOOST
- if name.startswith("Q"):
- return HeaderType.QT
+ if name.startswith("Q"):
+ return HeaderType.QT
- if name.startswith("Swiften"):
- return HeaderType.SWIFTEN
+ if name.startswith("Swiften"):
+ return HeaderType.SWIFTEN
- if name.startswith("Limber"):
- return HeaderType.LIMBER
+ if name.startswith("Limber"):
+ return HeaderType.LIMBER
- if name.startswith("Slimber"):
- return HeaderType.SLIMBER
+ if name.startswith("Slimber"):
+ return HeaderType.SLIMBER
- if name.startswith("Swift/Controllers"):
- return HeaderType.SWIFT_CONTROLLERS
+ if name.startswith("Swift/Controllers"):
+ return HeaderType.SWIFT_CONTROLLERS
- if name.startswith("Sluift"):
- return HeaderType.SLUIFT
+ if name.startswith("Sluift"):
+ return HeaderType.SLUIFT
- if name.startswith("SwifTools"):
- return HeaderType.SWIFTOOLS
+ if name.startswith("SwifTools"):
+ return HeaderType.SWIFTOOLS
- if name.startswith("Swift"):
- return HeaderType.SWIFT
+ if name.startswith("Swift"):
+ return HeaderType.SWIFT
- return HeaderType.OTHER
+ return HeaderType.OTHER
def serializeHeaderGroups(groups):
- headerList = []
- for group in range(0, HeaderType.SWIFT + 1):
- if group in groups:
- # sorted and without duplicates
- headers = sorted(list(set(groups[group])))
- headerList.extend(headers)
- headerList.extend(["\n"])
- headerList.pop()
- return headerList
+ headerList = []
+ for group in range(0, HeaderType.SWIFT + 1):
+ if group in groups:
+ # sorted and without duplicates
+ headers = sorted(list(set(groups[group])))
+ headerList.extend(headers)
+ headerList.extend(["\n"])
+ headerList.pop()
+ return headerList
def overwriteFile(filename, content):
- with open(filename, 'w') as f:
- for line in content:
- f.write(line)
+ with open(filename, 'w') as f:
+ for line in content:
+ f.write(line)
def cleanHeaderFile(content, headerStart, headerEnd, headerGroups):
- del content[headerStart:headerEnd]
- newHeaders = serializeHeaderGroups(headerGroups)
- content[headerStart:1] = newHeaders
+ del content[headerStart:headerEnd]
+ newHeaders = serializeHeaderGroups(headerGroups)
+ content[headerStart:1] = newHeaders
- if inPlace :
- overwriteFile(filename, content)
- else :
- for line in content:
- print line,
+ if inPlace :
+ overwriteFile(filename, content)
+ else :
+ for line in content:
+ print line,
def cleanImplementationFile(content, headerStart, headerEnd, headerGroups):
- del content[headerStart:headerEnd]
- newHeaders = serializeHeaderGroups(headerGroups)
- content[headerStart:1] = newHeaders
+ del content[headerStart:headerEnd]
+ newHeaders = serializeHeaderGroups(headerGroups)
+ content[headerStart:1] = newHeaders
- if inPlace :
- overwriteFile(filename, content)
- else :
- for line in content:
- print line,
+ if inPlace :
+ overwriteFile(filename, content)
+ else :
+ for line in content:
+ print line,
containsComplexPreprocessorDirectives = False
with open(filename) as f:
- content = f.readlines()
+ content = f.readlines()
(headerStart, headerEnd) = findHeaderBlock(content)
headerGroups = {}
for line in content[headerStart:headerEnd]:
- if line.strip():
- if line.strip().startswith("#pragma once"):
- headerType = HeaderType.PRAGMA_ONCE
- elif line.strip().startswith("#if") or line.strip().startswith("#def") or line.strip().startswith("#undef") or line.strip().startswith("#pragma "):
- containsComplexPreprocessorDirectives = True
- break
- else:
- #print line
- headerType = fileNameToHeaderType(lineToFileName(line))
-
- #filename = lineToFileName(line)
- if headerType in headerGroups:
- headerGroups[headerType].append(line)
- else:
- headerGroups[headerType] = [line]
+ if line.strip():
+ if line.strip().startswith("#pragma once"):
+ headerType = HeaderType.PRAGMA_ONCE
+ elif line.strip().startswith("#if") or line.strip().startswith("#def") or line.strip().startswith("#undef") or line.strip().startswith("#pragma "):
+ containsComplexPreprocessorDirectives = True
+ break
+ else:
+ #print line
+ 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!"
- exit(1)
+ 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!"
- exit(2)
- cleanHeaderFile(content, headerStart, headerEnd, headerGroups)
+ if not HeaderType.PRAGMA_ONCE in headerGroups:
+ 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)
+ cleanImplementationFile(content, headerStart, headerEnd, headerGroups)
diff --git a/BuildTools/GetBuildVersion.py b/BuildTools/GetBuildVersion.py
index fc92d15..70fdc5c 100755
--- a/BuildTools/GetBuildVersion.py
+++ b/BuildTools/GetBuildVersion.py
@@ -8,14 +8,14 @@ assert(len(sys.argv) >= 2)
only_major = False
if "--major" in sys.argv :
- only_major = True
+ 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"
+ 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"
else :
- print Version.getBuildVersion(os.path.dirname(sys.argv[0]) + "/..", sys.argv[1])
+ 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 47f8a68..d1f40a4 100755
--- a/BuildTools/Gource/GetGravatars.py
+++ b/BuildTools/Gource/GetGravatars.py
@@ -5,8 +5,8 @@ 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>"
- sys.exit(-1)
+ print "Usage: " + sys.argv[0] + " <output-dir>"
+ sys.exit(-1)
output_dir = sys.argv[1]
@@ -14,36 +14,36 @@ output_dir = sys.argv[1]
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]
+ author_components = line.rstrip().split("|")
+ authors[author_components[0]] = author_components[1]
p.stdin.close()
if p.wait() != 0 :
- print "Error"
- sys.exit(-1)
+ print "Error"
+ sys.exit(-1)
# Get & save the avatars
if not os.path.isdir(output_dir) :
- os.makedirs(output_dir)
+ os.makedirs(output_dir)
for email, name in authors.items() :
- print "Processing avatar for " + name + " <" + email + ">"
- filename = os.path.join(output_dir, name + ".png")
- if os.path.isfile(filename) :
- print "-> Already there. Skipping."
- continue
+ print "Processing avatar for " + name + " <" + email + ">"
+ filename = os.path.join(output_dir, name + ".png")
+ if os.path.isfile(filename) :
+ print "-> Already there. Skipping."
+ continue
- m = hashlib.md5()
- m.update(email)
- url = GRAVATAR_URL % {"id" : m.hexdigest()}
- print "- Downloading " + url
- f = urllib.urlopen(url)
- input = None
- if f.getcode() == 200 :
- input = f.read()
- f.close()
- if input :
- print "- Saving file " + filename
- f = open(filename, "w")
- f.write(input)
- f.close()
- else :
- print "- No Gravatar found"
+ m = hashlib.md5()
+ m.update(email)
+ url = GRAVATAR_URL % {"id" : m.hexdigest()}
+ print "- Downloading " + url
+ f = urllib.urlopen(url)
+ input = None
+ if f.getcode() == 200 :
+ input = f.read()
+ f.close()
+ if input :
+ print "- Saving file " + filename
+ f = open(filename, "w")
+ f.write(input)
+ f.close()
+ else :
+ print "- No Gravatar found"
diff --git a/BuildTools/InstallSwiftDependencies.sh b/BuildTools/InstallSwiftDependencies.sh
index d1200b1..7017b5f 100755
--- a/BuildTools/InstallSwiftDependencies.sh
+++ b/BuildTools/InstallSwiftDependencies.sh
@@ -6,27 +6,27 @@ SYSTEM_NAME=$(uname)
if [ "$SYSTEM_NAME" == "Linux" ]
then
- # handle linux distributions
- SYSTEM_DISTRO=$(lsb_release -i -s)
- if [ "$SYSTEM_DISTRO" == "Debian" ]
- then
- sudo apt-get install pkg-config libssl-dev qt5-default libqt5x11extras5-dev libqt5webkit5-dev qtmultimedia5-dev qttools5-dev-tools
- elif [ "$SYSTEM_DISTRO" == "Ubuntu" ]
- then
- sudo apt-get install pkg-config libssl-dev qt5-default libqt5x11extras5-dev libqt5webkit5-dev qtmultimedia5-dev qttools5-dev-tools
- elif [ "$SYSTEM_DISTRO" == "Arch" ]
- then
- sudo pacman -S qt5-base qt5-x11extras qt5-webkit qt5-multimedia qt5-tools
- elif [ "$SYSTEM_DISTRO" == "openSUSE project" ]
- then
- sudo zypper in pkg-config libopenssl-devel libQt5Core-devel libQt5WebKit5-devel libQt5WebKitWidgets-devel libqt5-qtmultimedia-devel libqt5-qtx11extras-devel libqt5-qttools-devel libQt5Gui-devel libQt5Network-devel libQt5DBus-devel python-xml
- elif [ "$SYSTEM_DISTRO" == "Fedora" ]
- then
- sudo dnf groups install "C Development Tools and Libraries"
- sudo dnf install openssl-devel qt5-qtbase-devel qt5-linguist qt5-qtwebkit-devel qt5-qtmultimedia-devel qt5-qtx11extras-devel
- else
- echo "Unsupported Linux distribution."
- fi
+ # handle linux distributions
+ SYSTEM_DISTRO=$(lsb_release -i -s)
+ if [ "$SYSTEM_DISTRO" == "Debian" ]
+ then
+ sudo apt-get install pkg-config libssl-dev qt5-default libqt5x11extras5-dev libqt5webkit5-dev qtmultimedia5-dev qttools5-dev-tools
+ elif [ "$SYSTEM_DISTRO" == "Ubuntu" ]
+ then
+ sudo apt-get install pkg-config libssl-dev qt5-default libqt5x11extras5-dev libqt5webkit5-dev qtmultimedia5-dev qttools5-dev-tools
+ elif [ "$SYSTEM_DISTRO" == "Arch" ]
+ then
+ sudo pacman -S qt5-base qt5-x11extras qt5-webkit qt5-multimedia qt5-tools
+ elif [ "$SYSTEM_DISTRO" == "openSUSE project" ]
+ then
+ sudo zypper in pkg-config libopenssl-devel libQt5Core-devel libQt5WebKit5-devel libQt5WebKitWidgets-devel libqt5-qtmultimedia-devel libqt5-qtx11extras-devel libqt5-qttools-devel libQt5Gui-devel libQt5Network-devel libQt5DBus-devel python-xml
+ elif [ "$SYSTEM_DISTRO" == "Fedora" ]
+ then
+ sudo dnf groups install "C Development Tools and Libraries"
+ sudo dnf install openssl-devel qt5-qtbase-devel qt5-linguist qt5-qtwebkit-devel qt5-qtmultimedia-devel qt5-qtx11extras-devel
+ else
+ echo "Unsupported Linux distribution."
+ fi
else
- echo "Unsupported system."
+ echo "Unsupported system."
fi
diff --git a/BuildTools/SCons/Tools/AppBundle.py b/BuildTools/SCons/Tools/AppBundle.py
index 1db7ff8..fda3484 100644
--- a/BuildTools/SCons/Tools/AppBundle.py
+++ b/BuildTools/SCons/Tools/AppBundle.py
@@ -1,64 +1,64 @@
import SCons.Util, os.path
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) :
+ 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"))
- 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 Swift Development Team.\nAll Rights Reserved."
- }
- infoDict.update(info)
+ 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 Swift Development Team.\nAll Rights Reserved."
+ }
+ 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>
+ 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))
+ 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 (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.Install(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/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 1d03c00..a0b29ba 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,519 @@ 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)
+ 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 = '--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")
+ """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
+ 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"]
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)
diff --git a/BuildTools/UpdateDebianChangelog.py b/BuildTools/UpdateDebianChangelog.py
index 0693461..1d0e3ea 100755
--- a/BuildTools/UpdateDebianChangelog.py
+++ b/BuildTools/UpdateDebianChangelog.py
@@ -14,28 +14,28 @@ project = ""
last_version = ""
m = re.match("([\w-]+) \((.*)-\d+\)", last_version_line)
if m :
- project = m.group(1)
- last_version = m.group(2)
+ project = m.group(1)
+ last_version = m.group(2)
if project == "" :
- project="swift-im"
+ project="swift-im"
if "dev" in version :
- distribution = "development"
+ distribution = "development"
elif "beta" in version or "rc" in version :
- distribution = "beta development"
+ distribution = "beta development"
else :
- distribution = "release beta development"
+ 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()
+ 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 5d084cd..91cd3cc 100755
--- a/BuildTools/scons2ninja.py
+++ b/BuildTools/scons2ninja.py
@@ -24,202 +24,202 @@ SCONS_ARGS = ' '.join(sys.argv[1:])
BINARY_FLAGS = ["-framework", "-arch", "-x", "--output-format", "-isystem", "-include"]
if sys.platform == 'win32' :
- LIB_PREFIX = ""
- LIB_SUFFIX = ""
- EXE_SUFFIX = ".exe"
+ LIB_PREFIX = ""
+ LIB_SUFFIX = ""
+ EXE_SUFFIX = ".exe"
else :
- LIB_PREFIX = "lib"
- LIB_SUFFIX = ".a"
- EXE_SUFFIX = ""
+ LIB_PREFIX = "lib"
+ LIB_SUFFIX = ".a"
+ EXE_SUFFIX = ""
def is_regexp(x) :
- return 'match' in dir(x)
+ return 'match' in dir(x)
def is_list(l) :
- return type(l) is list
+ return type(l) is list
def escape(s) :
- return s.replace(' ', '$ ').replace(':', '$:')
+ return s.replace(' ', '$ ').replace(':', '$:')
def quote_spaces(s) :
- if ' ' in s :
- return '"' + s + '"'
- else :
- return s
+ if ' ' in s :
+ return '"' + s + '"'
+ else :
+ return s
def to_list(l) :
- if not l :
- return []
- if is_list(l) :
- return l
- return [l]
+ if not l :
+ return []
+ if is_list(l) :
+ return l
+ return [l]
def partition(l, f) :
- x = []
- y = []
- for v in l :
- if f(v) :
- x.append(v)
- else :
- y.append(v)
- return (x, y)
+ x = []
+ y = []
+ for v in l :
+ if f(v) :
+ x.append(v)
+ else :
+ y.append(v)
+ return (x, y)
def get_unary_flags(prefix, flags) :
- return [x[len(prefix):] for x in flags if x.lower().startswith(prefix.lower())]
+ return [x[len(prefix):] for x in flags if x.lower().startswith(prefix.lower())]
def extract_unary_flags(prefix, flags) :
- f1, f2 = partition(flags, lambda x : x.lower().startswith(prefix.lower()))
- return ([f[len(prefix):] for f in f1], f2)
+ f1, f2 = partition(flags, lambda x : x.lower().startswith(prefix.lower()))
+ return ([f[len(prefix):] for f in f1], f2)
def extract_unary_flag(prefix, flags) :
- flag, flags = extract_unary_flags(prefix, flags)
- return (flag[0], flags)
+ flag, flags = extract_unary_flags(prefix, flags)
+ return (flag[0], flags)
def extract_binary_flag(prefix, flags) :
- i = flags.index(prefix)
- flag = flags[i + 1]
- del flags[i]
- del flags[i]
- return (flag, flags)
+ i = flags.index(prefix)
+ flag = flags[i + 1]
+ del flags[i]
+ del flags[i]
+ return (flag, flags)
def get_non_flags(flags) :
- skip = False
- result = []
- for f in flags :
- if skip :
- skip = False
- elif f in BINARY_FLAGS :
- skip = True
- elif not f.startswith("/") and not f.startswith("-") :
- result.append(f)
- return result
+ skip = False
+ result = []
+ for f in flags :
+ if skip :
+ skip = False
+ elif f in BINARY_FLAGS :
+ skip = True
+ elif not f.startswith("/") and not f.startswith("-") :
+ result.append(f)
+ return result
def extract_non_flags(flags) :
- non_flags = get_non_flags(flags)
- return (non_flags, filter(lambda x : x not in non_flags, flags))
+ non_flags = get_non_flags(flags)
+ return (non_flags, filter(lambda x : x not in non_flags, flags))
def get_dependencies(target, build_targets) :
- result = []
- queue = list(dependencies.get(target, []))
- while len(queue) > 0 :
- n = queue.pop()
- # Filter out Value() results
- if n in build_targets or os.path.exists(n) :
- result.append(n)
- queue += list(dependencies.get(n, []))
- return result
+ result = []
+ queue = list(dependencies.get(target, []))
+ while len(queue) > 0 :
+ n = queue.pop()
+ # Filter out Value() results
+ if n in build_targets or os.path.exists(n) :
+ result.append(n)
+ queue += list(dependencies.get(n, []))
+ return result
def get_built_libs(libs, libpaths, outputs) :
- canonical_outputs = [os.path.abspath(p) for p in outputs]
- result = []
- for libpath in libpaths :
- for lib in libs :
- lib_libpath = os.path.join(libpath, LIB_PREFIX + lib + LIB_SUFFIX)
- if os.path.abspath(lib_libpath) in canonical_outputs :
- result.append(lib_libpath)
- return result
+ canonical_outputs = [os.path.abspath(p) for p in outputs]
+ result = []
+ for libpath in libpaths :
+ for lib in libs :
+ lib_libpath = os.path.join(libpath, LIB_PREFIX + lib + LIB_SUFFIX)
+ if os.path.abspath(lib_libpath) in canonical_outputs :
+ result.append(lib_libpath)
+ return result
def parse_tool_command(line) :
- command = shlex.split(line, False, False if sys.platform == 'win32' else True)
- flags = command[1:]
- tool = os.path.splitext(os.path.basename(command[0]))[0]
- if tool.startswith('clang++') or tool.startswith('g++') :
- tool = "cxx"
- elif tool.startswith('clang') or tool.startswith('gcc') :
- tool = "cc"
- if tool in ["cc", "cxx"] and not "-c" in flags :
- tool = "glink"
- tool = tool.replace('-qt4', '')
- return tool, command, flags
+ command = shlex.split(line, False, False if sys.platform == 'win32' else True)
+ flags = command[1:]
+ tool = os.path.splitext(os.path.basename(command[0]))[0]
+ if tool.startswith('clang++') or tool.startswith('g++') :
+ tool = "cxx"
+ elif tool.startswith('clang') or tool.startswith('gcc') :
+ tool = "cc"
+ if tool in ["cc", "cxx"] and not "-c" in flags :
+ tool = "glink"
+ tool = tool.replace('-qt4', '')
+ return tool, command, flags
def rglob(pattern, root = '.') :
- return [os.path.join(path, f) for path, dirs, files in os.walk(root) for f in fnmatch.filter(files, pattern)]
+ return [os.path.join(path, f) for path, dirs, files in os.walk(root) for f in fnmatch.filter(files, pattern)]
################################################################################
# Helper for building Ninja files
################################################################################
class NinjaBuilder :
- def __init__(self) :
- self._header = ""
- self.variables = ""
- self.rules = ""
- self._build = ""
- self.pools = ""
- self._flags = {}
- self.targets = []
-
- def header(self, text) :
- self._header += text + "\n"
-
- def rule(self, name, **kwargs) :
- self.rules += "rule " + name + "\n"
- for k, v in kwargs.iteritems() :
- self.rules += " " + str(k) + " = " + str(v) + "\n"
- self.rules += "\n"
-
- def pool(self, name, **kwargs) :
- self.pools += "pool " + name + "\n"
- for k, v in kwargs.iteritems() :
- self.pools += " " + str(k) + " = " + str(v) + "\n"
- self.pools += "\n"
-
- def variable(self, name, value) :
- self.variables += str(name) + " = " + str(value) + "\n"
-
- def build(self, target, rule, sources = None, **kwargs) :
- self._build += "build " + self.to_string(target) + ": " + rule
- if sources :
- self._build += " " + self.to_string(sources)
- if 'deps' in kwargs and kwargs['deps'] :
- self._build += " | " + self.to_string(kwargs["deps"])
- if 'order_deps' in kwargs :
- self._build += " || " + self.to_string(kwargs['order_deps'])
- self._build += "\n"
- for var, value in kwargs.iteritems() :
- if var in ['deps', 'order_deps'] :
- continue
- value = self.to_string(value, quote = True)
- if var.endswith("flags") :
- value = self.get_flags_variable(var, value)
- self._build += " " + var + " = " + value + "\n"
- self.targets += to_list(target)
-
- def header_targets(self) :
- return [x for x in self.targets if x.endswith('.h') or x.endswith('.hh')]
-
- def serialize(self) :
- result = ""
- result += self._header + "\n"
- result += self.variables + "\n"
- for prefix in self._flags.values() :
- for k, v in prefix.iteritems() :
- result += v + " = " + k + "\n"
- 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])
- else :
- 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] = {}
- type_flags = self._flags[flags_type]
- if flags not in type_flags :
- type_flags[flags] = flags_type + "_" + str(len(type_flags))
- return "$" + type_flags[flags]
+ def __init__(self) :
+ self._header = ""
+ self.variables = ""
+ self.rules = ""
+ self._build = ""
+ self.pools = ""
+ self._flags = {}
+ self.targets = []
+
+ def header(self, text) :
+ self._header += text + "\n"
+
+ def rule(self, name, **kwargs) :
+ self.rules += "rule " + name + "\n"
+ for k, v in kwargs.iteritems() :
+ self.rules += " " + str(k) + " = " + str(v) + "\n"
+ self.rules += "\n"
+
+ def pool(self, name, **kwargs) :
+ self.pools += "pool " + name + "\n"
+ for k, v in kwargs.iteritems() :
+ self.pools += " " + str(k) + " = " + str(v) + "\n"
+ self.pools += "\n"
+
+ def variable(self, name, value) :
+ self.variables += str(name) + " = " + str(value) + "\n"
+
+ def build(self, target, rule, sources = None, **kwargs) :
+ self._build += "build " + self.to_string(target) + ": " + rule
+ if sources :
+ self._build += " " + self.to_string(sources)
+ if 'deps' in kwargs and kwargs['deps'] :
+ self._build += " | " + self.to_string(kwargs["deps"])
+ if 'order_deps' in kwargs :
+ self._build += " || " + self.to_string(kwargs['order_deps'])
+ self._build += "\n"
+ for var, value in kwargs.iteritems() :
+ if var in ['deps', 'order_deps'] :
+ continue
+ value = self.to_string(value, quote = True)
+ if var.endswith("flags") :
+ value = self.get_flags_variable(var, value)
+ self._build += " " + var + " = " + value + "\n"
+ self.targets += to_list(target)
+
+ def header_targets(self) :
+ return [x for x in self.targets if x.endswith('.h') or x.endswith('.hh')]
+
+ def serialize(self) :
+ result = ""
+ result += self._header + "\n"
+ result += self.variables + "\n"
+ for prefix in self._flags.values() :
+ for k, v in prefix.iteritems() :
+ result += v + " = " + k + "\n"
+ 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])
+ else :
+ 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] = {}
+ type_flags = self._flags[flags_type]
+ if flags not in type_flags :
+ type_flags[flags] = flags_type + "_" + str(len(type_flags))
+ return "$" + type_flags[flags]
################################################################################
@@ -231,7 +231,7 @@ scons_cmd = "scons"
scons_dependencies = ['SConstruct'] + rglob('SConscript')
def ninja_custom_command(ninja, line) :
- return False
+ return False
CONFIGURATION_FILE = '.scons2ninja.conf'
execfile(CONFIGURATION_FILE)
@@ -248,104 +248,104 @@ ninja = NinjaBuilder()
ninja.pool('scons_pool', depth = 1)
if sys.platform == 'win32' :
- 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',
- description = 'LINK $out')
-
- ninja.rule('lib',
- command = '$lib $libflags /out:$out $in',
- description = 'AR $out')
-
- ninja.rule('rc',
- command = '$rc $rcflags /Fo$out $in',
- description = 'RC $out')
-
- # SCons doesn't touch files if they didn't change, which makes
- # ninja rebuild the file over and over again. There's no touch on Windows :(
- # Could implement it with a script, but for now, delete the file if
- # this problem occurs. I'll fix it if it occurs too much.
- ninja.rule('scons',
- command = scons_cmd + " ${scons_args} $out",
- pool = 'scons_pool',
- description = 'GEN $out')
-
- ninja.rule('install', command = 'cmd /c copy $in $out')
- ninja.rule('run', command = '$in')
+ 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',
+ description = 'LINK $out')
+
+ ninja.rule('lib',
+ command = '$lib $libflags /out:$out $in',
+ description = 'AR $out')
+
+ ninja.rule('rc',
+ command = '$rc $rcflags /Fo$out $in',
+ description = 'RC $out')
+
+ # SCons doesn't touch files if they didn't change, which makes
+ # ninja rebuild the file over and over again. There's no touch on Windows :(
+ # Could implement it with a script, but for now, delete the file if
+ # this problem occurs. I'll fix it if it occurs too much.
+ ninja.rule('scons',
+ command = scons_cmd + " ${scons_args} $out",
+ pool = 'scons_pool',
+ description = 'GEN $out')
+
+ ninja.rule('install', command = 'cmd /c copy $in $out')
+ ninja.rule('run', command = '$in')
else :
- ninja.rule('cxx',
- deps = 'gcc',
- depfile = '$out.d',
- command = '$cxx -MMD -MF $out.d $cxxflags -c $in -o $out',
- description = 'CXX $out')
+ ninja.rule('cxx',
+ deps = 'gcc',
+ depfile = '$out.d',
+ command = '$cxx -MMD -MF $out.d $cxxflags -c $in -o $out',
+ description = 'CXX $out')
- ninja.rule('cc',
- deps = 'gcc',
- depfile = '$out.d',
- command = '$cc -MMD -MF $out.d $ccflags -c $in -o $out',
- description = 'CC $out')
+ ninja.rule('cc',
+ deps = 'gcc',
+ depfile = '$out.d',
+ command = '$cc -MMD -MF $out.d $ccflags -c $in -o $out',
+ description = 'CC $out')
- ninja.rule('link',
- command = '$glink -o $out $in $linkflags',
- description = 'LINK $out')
+ ninja.rule('link',
+ command = '$glink -o $out $in $linkflags',
+ description = 'LINK $out')
- ninja.rule('ar',
- command = 'ar $arflags $out $in && ranlib $out',
- description = 'AR $out')
+ ninja.rule('ar',
+ command = 'ar $arflags $out $in && ranlib $out',
+ description = 'AR $out')
- # SCons doesn't touch files if they didn't change, which makes
- # ninja rebuild the file over and over again. Touching solves this.
- ninja.rule('scons',
- command = scons_cmd + " $out && touch $out",
- pool = 'scons_pool',
- description = 'GEN $out')
+ # SCons doesn't touch files if they didn't change, which makes
+ # ninja rebuild the file over and over again. Touching solves this.
+ ninja.rule('scons',
+ command = scons_cmd + " $out && touch $out",
+ pool = 'scons_pool',
+ description = 'GEN $out')
- ninja.rule('install', command = 'install $in $out')
- ninja.rule('run', command = './$in')
+ ninja.rule('install', command = 'install $in $out')
+ ninja.rule('run', command = './$in')
ninja.rule('moc',
- command = '$moc $mocflags -o $out $in',
- description = 'MOC $out')
+ command = '$moc $mocflags -o $out $in',
+ description = 'MOC $out')
ninja.rule('rcc',
- command = '$rcc $rccflags -name $name -o $out $in',
- description = 'RCC $out')
+ command = '$rcc $rccflags -name $name -o $out $in',
+ description = 'RCC $out')
ninja.rule('uic',
- command = '$uic $uicflags -o $out $in',
- description = 'UIC $out')
+ command = '$uic $uicflags -o $out $in',
+ description = 'UIC $out')
ninja.rule('lrelease',
- command = '$lrelease $lreleaseflags $in -qm $out',
- description = 'LRELEASE $out')
+ command = '$lrelease $lreleaseflags $in -qm $out',
+ description = 'LRELEASE $out')
ninja.rule('ibtool',
- command = '$ibtool $ibtoolflags --compile $out $in',
- description = 'IBTOOL $out')
+ command = '$ibtool $ibtoolflags --compile $out $in',
+ description = 'IBTOOL $out')
ninja.rule('dsymutil',
- command = '$dsymutil $dsymutilflags -o $out $in',
- description = 'DSYMUTIL $out')
+ command = '$dsymutil $dsymutilflags -o $out $in',
+ description = 'DSYMUTIL $out')
ninja.rule('generator',
- command = "python " + SCRIPT + " ${scons_args}",
- depfile = ".scons2ninja.deps",
- pool = 'scons_pool',
- generator = '1',
- description = 'Regenerating build.ninja')
+ command = "python " + SCRIPT + " ${scons_args}",
+ depfile = ".scons2ninja.deps",
+ pool = 'scons_pool',
+ generator = '1',
+ description = 'Regenerating build.ninja')
ninja.rule('sdef',
- command = 'sdef $in | sdp -fh --basename $basename -o $outdir',
- description = 'SDEF $out')
+ command = 'sdef $in | sdp -fh --basename $basename -o $outdir',
+ description = 'SDEF $out')
################################################################################
# Build Statements
@@ -365,235 +365,235 @@ 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
- 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) :
- stage = "build"
- else :
- print line
-
- elif stage == "build" :
- if line.startswith('+-') :
- stage = "dependencies"
- elif re.match("^Using tempfile", line) :
- # Ignore response files from MSVS
- skip_nth_line = 2
- else :
- build_lines.append(line)
-
- # Already detect targets that will need 'mt'
- tool, _, flags = parse_tool_command(line)
- if tool == 'mt' :
- target = get_unary_flags("-outputresource:", flags)[0]
- target = target[0:target.index(';')]
- mtflags[target] = flags
-
- 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]
-
- # 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 :
- raise Exception("Internal Error" )
- stack.append(previous_filename)
-
- # 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
+ line = line.rstrip()
+
+ # Skip lines if requested from previous command
+ if skip_nth_line >= 0 :
+ 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) :
+ stage = "build"
+ else :
+ print line
+
+ elif stage == "build" :
+ if line.startswith('+-') :
+ stage = "dependencies"
+ elif re.match("^Using tempfile", line) :
+ # Ignore response files from MSVS
+ skip_nth_line = 2
+ else :
+ build_lines.append(line)
+
+ # Already detect targets that will need 'mt'
+ tool, _, flags = parse_tool_command(line)
+ if tool == 'mt' :
+ target = get_unary_flags("-outputresource:", flags)[0]
+ target = target[0:target.index(';')]
+ mtflags[target] = flags
+
+ 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]
+
+ # 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 :
+ raise Exception("Internal Error" )
+ stack.append(previous_filename)
+
+ # 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 f.stderr.read()
- exit(-1)
+ 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 :
- out = [x[1:-1] for x in m.group(2).split(',')]
- for x in out :
- # 'Note' = To be more correct, deps should also include $scons_dependencies,
- # but this regenerates a bit too often, so leaving it out for now.
- ninja.build(x, 'scons', None, deps = sorted(get_dependencies(x, ninja.targets)))
- continue
-
-
- # TextFile
- m = re.match("^Creating '([^']+)'", line)
- if m :
- out = m.group(1)
- # Note: To be more correct, deps should also include $scons_dependencies,
- # but this regenerates a bit too often, so leaving it out for now.
- ninja.build(out, 'scons', None, deps = sorted(get_dependencies(out, ninja.targets)))
- continue
-
- # Install
- m = re.match('^Install file: "(.*)" as "(.*)"', line)
- if m :
- ninja.build(m.group(2), 'install', m.group(1))
- continue
-
- m = re.match('^Install directory: "(.*)" as "(.*)"', line)
- if m :
- for source in rglob('*', m.group(1)) :
- if os.path.isdir(source) :
- continue
- target = os.path.join(m.group(2), os.path.relpath(source, m.group(1)))
- ninja.build(target, 'install', source)
- continue
-
- # Tools
- tool, command, flags = parse_tool_command(line)
- tools[tool] = command[0]
-
- ############################################################
- # clang/gcc tools
- ############################################################
-
- if tool == 'cc':
- out, flags = extract_binary_flag("-o", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'cc', files, order_deps = '_generated_headers', ccflags = flags)
-
- elif tool == 'cxx':
- out, flags = extract_binary_flag("-o", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'cxx', files, order_deps = '_generated_headers', cxxflags = flags)
-
- elif tool == 'glink':
- out, flags = extract_binary_flag("-o", flags)
- files, flags = extract_non_flags(flags)
- libs = get_unary_flags('-l', flags)
- libpaths = get_unary_flags("-L", flags)
- deps = get_built_libs(libs, libpaths, ninja.targets)
- ninja.build(out, 'link', files, deps = sorted(deps), linkflags = flags)
-
- elif tool == 'ar':
- objects, flags = partition(flags, lambda x: x.endswith('.o'))
- libs, flags = partition(flags, lambda x: x.endswith('.a'))
- out = libs[0]
- ninja.build(out, 'ar', objects, arflags = flags)
-
- elif tool == 'ranlib':
- pass
-
-
- ############################################################
- # MSVC tools
- ############################################################
-
- elif tool == 'cl':
- out, flags = extract_unary_flag("/Fo", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'cl', files, order_deps = '_generated_headers', clflags = flags)
-
- elif tool == 'lib':
- out, flags = extract_unary_flag("/out:", flags)
- files, flags = extract_non_flags(flags)
- 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),
- libs = libs, linkflags = flags, mtflags = mtflags[out])
- else :
- 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
- pass
-
- ############################################################
- # Qt tools
- ############################################################
-
- elif tool == 'moc':
- out, flags = extract_binary_flag("-o", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'moc', files, mocflags = flags)
-
- elif tool == 'uic':
- out, flags = extract_binary_flag("-o", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'uic', files, uicflags = flags)
-
- elif tool == 'lrelease':
- out, flags = extract_binary_flag("-qm", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'lrelease', files, lreleaseflags = flags)
-
- elif tool == 'rcc':
- out, flags = extract_binary_flag("-o", flags)
- name, flags = extract_binary_flag("-name", flags)
- files, flags = extract_non_flags(flags)
- deps = list(set(get_dependencies(out, ninja.targets)) - set(files))
- ninja.build(out, 'rcc', files, deps = sorted(deps), name = name, rccflags = flags)
-
- ############################################################
- # OS X tools
- ############################################################
-
- elif tool == 'ibtool':
- out, flags = extract_binary_flag("--compile", flags)
- files, flags = extract_non_flags(flags)
- ninja.build(out, 'ibtool', files, ibtoolflags = flags)
-
- 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],
- basename = basename,
- outdir = outdir)
-
-
- elif not ninja_custom_command(ninja, line) :
- raise Exception("Unknown tool: '" + line + "'")
+ # Custom python function
+ m = re.match('^(\w+)\(\[([^\]]*)\]', line)
+ if m :
+ out = [x[1:-1] for x in m.group(2).split(',')]
+ for x in out :
+ # 'Note' = To be more correct, deps should also include $scons_dependencies,
+ # but this regenerates a bit too often, so leaving it out for now.
+ ninja.build(x, 'scons', None, deps = sorted(get_dependencies(x, ninja.targets)))
+ continue
+
+
+ # TextFile
+ m = re.match("^Creating '([^']+)'", line)
+ if m :
+ out = m.group(1)
+ # Note: To be more correct, deps should also include $scons_dependencies,
+ # but this regenerates a bit too often, so leaving it out for now.
+ ninja.build(out, 'scons', None, deps = sorted(get_dependencies(out, ninja.targets)))
+ continue
+
+ # Install
+ m = re.match('^Install file: "(.*)" as "(.*)"', line)
+ if m :
+ ninja.build(m.group(2), 'install', m.group(1))
+ continue
+
+ m = re.match('^Install directory: "(.*)" as "(.*)"', line)
+ if m :
+ for source in rglob('*', m.group(1)) :
+ if os.path.isdir(source) :
+ continue
+ target = os.path.join(m.group(2), os.path.relpath(source, m.group(1)))
+ ninja.build(target, 'install', source)
+ continue
+
+ # Tools
+ tool, command, flags = parse_tool_command(line)
+ tools[tool] = command[0]
+
+ ############################################################
+ # clang/gcc tools
+ ############################################################
+
+ if tool == 'cc':
+ out, flags = extract_binary_flag("-o", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'cc', files, order_deps = '_generated_headers', ccflags = flags)
+
+ elif tool == 'cxx':
+ out, flags = extract_binary_flag("-o", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'cxx', files, order_deps = '_generated_headers', cxxflags = flags)
+
+ elif tool == 'glink':
+ out, flags = extract_binary_flag("-o", flags)
+ files, flags = extract_non_flags(flags)
+ libs = get_unary_flags('-l', flags)
+ libpaths = get_unary_flags("-L", flags)
+ deps = get_built_libs(libs, libpaths, ninja.targets)
+ ninja.build(out, 'link', files, deps = sorted(deps), linkflags = flags)
+
+ elif tool == 'ar':
+ objects, flags = partition(flags, lambda x: x.endswith('.o'))
+ libs, flags = partition(flags, lambda x: x.endswith('.a'))
+ out = libs[0]
+ ninja.build(out, 'ar', objects, arflags = flags)
+
+ elif tool == 'ranlib':
+ pass
+
+
+ ############################################################
+ # MSVC tools
+ ############################################################
+
+ elif tool == 'cl':
+ out, flags = extract_unary_flag("/Fo", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'cl', files, order_deps = '_generated_headers', clflags = flags)
+
+ elif tool == 'lib':
+ out, flags = extract_unary_flag("/out:", flags)
+ files, flags = extract_non_flags(flags)
+ 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),
+ libs = libs, linkflags = flags, mtflags = mtflags[out])
+ else :
+ 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
+ pass
+
+ ############################################################
+ # Qt tools
+ ############################################################
+
+ elif tool == 'moc':
+ out, flags = extract_binary_flag("-o", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'moc', files, mocflags = flags)
+
+ elif tool == 'uic':
+ out, flags = extract_binary_flag("-o", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'uic', files, uicflags = flags)
+
+ elif tool == 'lrelease':
+ out, flags = extract_binary_flag("-qm", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'lrelease', files, lreleaseflags = flags)
+
+ elif tool == 'rcc':
+ out, flags = extract_binary_flag("-o", flags)
+ name, flags = extract_binary_flag("-name", flags)
+ files, flags = extract_non_flags(flags)
+ deps = list(set(get_dependencies(out, ninja.targets)) - set(files))
+ ninja.build(out, 'rcc', files, deps = sorted(deps), name = name, rccflags = flags)
+
+ ############################################################
+ # OS X tools
+ ############################################################
+
+ elif tool == 'ibtool':
+ out, flags = extract_binary_flag("--compile", flags)
+ files, flags = extract_non_flags(flags)
+ ninja.build(out, 'ibtool', files, ibtoolflags = flags)
+
+ 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],
+ basename = basename,
+ outdir = outdir)
+
+
+ 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
@@ -607,11 +607,11 @@ ninja.header("# This file is generated by " + SCRIPT)
ninja.variable("ninja_required_version", "1.3")
ninja.variable("scons_args", SCONS_ARGS)
for k, v in tools.iteritems() :
- ninja.variable(k, v)
+ ninja.variable(k, v)
# Extra customizations
if 'ninja_post' in dir() :
- ninja_post(ninja)
+ ninja_post(ninja)
################################################################################