summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BuildTools/SCons/Tools/WindowsBundle.py100
-rw-r--r--Documentation/BuildingOnWindows.txt5
-rw-r--r--Swift/QtUI/SConscript32
3 files changed, 111 insertions, 26 deletions
diff --git a/BuildTools/SCons/Tools/WindowsBundle.py b/BuildTools/SCons/Tools/WindowsBundle.py
index 2915141..33ace7f 100644
--- a/BuildTools/SCons/Tools/WindowsBundle.py
+++ b/BuildTools/SCons/Tools/WindowsBundle.py
@@ -1,29 +1,115 @@
import SCons.Util, os
+import subprocess
+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
def generate(env) :
- def createWindowsBundle(env, bundle, resources = {}, qtplugins = {}, qtlibs = [], qtversion = '4') :
+ def captureWinDeployQtMapping(release = True):
+ p = False
+ if release:
+ p = subprocess.Popen(['windeployqt', '--release', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ else:
+ p = subprocess.Popen(['windeployqt', '--debug', '--dry-run', '--list', 'mapping', 'Swift.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ 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)
+ 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:
+ 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"):
+ 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 filename[1:] in qtplugins[plugin_folder]:
+ 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"
diff --git a/Documentation/BuildingOnWindows.txt b/Documentation/BuildingOnWindows.txt
index a2d9948..c411d62 100644
--- a/Documentation/BuildingOnWindows.txt
+++ b/Documentation/BuildingOnWindows.txt
@@ -39,18 +39,19 @@ Running tests
scons test=all
for running all tests.
Packaging Swift
---------------
For packaging use:
-- Microsoft Visual C++ Express 2008
+- Microsoft Visual C++ Express 2008 or Microsoft VS 2013 Express
- No OpenSSL
- WiX
+- Download the C++ redistributable package from Microsoft and put it at C:\Program Files (x86)\Common Files\Merge Modules\
- config.py should contain:
qt = "c:\\qt\\4.7.4"
- vcredist = "c:\\Program Files\\Common Files\\Merge Modules"
+ vcredist = "C:\\Program Files (x86)\\Common Files\\Merge Modules\\vcredist_x86.exe"
debug = 1
optimize = 1
wix_bindir = "c:\\program files\\Windows Installer XML v3.5\\bin"
- run
scons dist=1
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 6e90cd4..858df19 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -1,7 +1,7 @@
-import os, shutil, datetime, re, time
+import os, datetime, re, time
import Version
def generateDefaultTheme(dir) :
sourceDir = dir.abspath
result = "<!-- WARNING: This file is automatically generated. Any changes will be overwritten. -->\n"
result += "<RCC version =\"1.0\">"
@@ -355,31 +355,31 @@ if env["PLATFORM"] == "darwin" :
commonResources[""] = commonResources.get("", []) + ["#/Swift/resources/MacOSX/Swift.icns"]
app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = commonResources, frameworks = frameworks, handlesXMPPURIs = True)
if env["DIST"] :
myenv.Command(["#/Packages/Swift/Swift-${SWIFT_VERSION}.dmg"], [app], ["Swift/Packaging/MacOSX/package.sh " + app.path + " Swift/Packaging/MacOSX/Swift.dmg.gz $TARGET $QTDIR"])
dsym = myenv.Command(["Swift-${SWIFT_VERSION}.dSYM"], ["Swift"], ["dsymutil -o ${TARGET} ${SOURCE}"])
myenv.Command(["#/Packages/Swift/Swift-${SWIFT_VERSION}.dSYM.zip"], dsym, ["cd ${SOURCE.dir} && zip -r ${TARGET.abspath} ${SOURCE.name}"])
-
+
if env.get("SWIFT_INSTALLDIR", "") :
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "bin"), swiftProgram + openURIProgram)
env.InstallAs(os.path.join(env["SWIFT_INSTALLDIR"], "share", "pixmaps", "swift.xpm"), "#/Swift/resources/logo/logo-icon-32.xpm")
icons_path = os.path.join(env["SWIFT_INSTALLDIR"], "share", "icons", "hicolor")
env.InstallAs(os.path.join(icons_path, "32x32", "apps", "swift.xpm"), "#/Swift/resources/logo/logo-icon-32.xpm")
env.InstallAs(os.path.join(icons_path, "scalable", "apps", "swift.svg"), "#/Swift/resources/logo/logo-icon.svg")
for i in ["16", "22", "24", "64", "128"] :
env.InstallAs(os.path.join(icons_path, i + "x" + i, "apps", "swift.png"), "#/Swift/resources/logo/logo-icon-" + i + ".png")
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "applications"), "#/Swift/resources/swift.desktop")
- for dir, resource in commonResources.items() :
+ for dir, resource in commonResources.items() :
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift", dir), resource)
-
+
if env["PLATFORM"] == "win32" :
if env["DIST"] or ARGUMENTS.get("dump_trace") :
commonResources[""] = commonResources.get("", []) + [
- #os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),
+ #os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),
#os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"),
- "#/Swift/resources/images",
+ "#/Swift/resources/images",
]
if env["SWIFTEN_DLL"] :
commonResources[""] = commonResources.get("", []) + ["#/Swiften/${SWIFTEN_LIBRARY_FILE}"]
qtplugins = {}
qtplugins["imageformats"] = ["gif", "ico", "jpeg", "mng", "svg", "tiff"]
qtlibs = ["QtCore", "QtGui", "QtNetwork", "QtWebKit", "QtXMLPatterns"]
@@ -389,17 +389,18 @@ if env["PLATFORM"] == "win32" :
else :
qtlibs += ['QtQuick', 'QtQml', 'QtPositioning', 'QtMultimedia', 'QtSql', 'QtSensors', 'QtWidgets', 'QtWebKitWidgets', 'QtMultimediaWidgets', 'QtOpenGL', 'QtPrintSupport']
qtlibs = [lib.replace('Qt', 'Qt5') for lib in qtlibs]
qtlibs += ['icuin51', 'icuuc51', 'icudt51', 'libGLESv2', 'libEGL']
qtplugins["platforms"] = ['windows']
qtplugins["accessible"] = ["taccessiblewidgets"]
- windowsBundleFiles = myenv.WindowsBundle("Swift",
- resources = commonResources,
- qtplugins = qtplugins,
- qtlibs = qtlibs,
- qtversion = qt_version)
+
+ windowsBundleFiles = myenv.WindowsBundle("Swift",
+ resources = commonResources,
+ qtplugins = qtplugins,
+ qtlibs = qtlibs,
+ qtversion = qt_version)
if env["DIST"] :
#myenv.Append(NSIS_OPTIONS = [
# "/DmsvccRedistributableDir=\"" + env["vcredist"] + "\"",
# "/DbuildVersion=" + myenv["SWIFT_VERSION"]
# ])
@@ -412,34 +413,31 @@ if env["PLATFORM"] == "win32" :
for line in infile:
for char in line.decode("utf-8") :
if ord(char) > 127 :
# FIXME: This is incorrect, because it only works for latin1.
# The correct way is \u<decimal utf16 point>? , but this is more
# work
- outfile.write("\\'%X" % ord(char))
+ outfile.write("\\'%X" % ord(char))
else :
outfile.write(char)
outfile.write('\\par ')
outfile.write('}')
outfile.close()
infile.close()
copying = env.Command(["Swift/COPYING.rtf"], ["COPYING"], convertToRTF)
-
wixvariables = {
'VCCRTFile': env["vcredist"],
- 'Version': str(myenv["SWIFT_VERSION_MAJOR"]) + "." + str(myenv["SWIFT_VERSION_MINOR"]) + "." + str(myenv["SWIFT_VERSION_PATCH"])
+ 'Version': str(myenv["SWIFT_VERSION_MAJOR"]) + "." + str(myenv["SWIFT_VERSION_MINOR"]) + "." + str(myenv["SWIFT_VERSION_PATCH"])
}
wixincludecontent = "<Include>"
for key in wixvariables:
wixincludecontent += "<?define %s = \"%s\" ?>" % (key, wixvariables[key])
wixincludecontent += "</Include>"
myenv.WriteVal("..\\Packaging\\Wix\\variables.wxs", env.Value(wixincludecontent))
myenv["WIX_SOURCE_OBJECT_DIR"] = "Swift\\QtUI\\Swift"
myenv.WiX_Heat('..\\Packaging\\WiX\\gen_files.wxs', windowsBundleFiles + copying)
myenv.WiX_Candle('..\\Packaging\\WiX\\Swift.wixobj', '..\\Packaging\\WiX\\Swift.wxs')
myenv.WiX_Candle('..\\Packaging\\WiX\\gen_files.wixobj', '..\\Packaging\\WiX\\gen_files.wxs')
myenv.WiX_Light('#/Packages/Swift/Swift-' + myenv["SWIFT_VERSION"] + '.msi', ['..\\Packaging\\WiX\\gen_files.wixobj','..\\Packaging\\WiX\\Swift.wixobj'])
-
+
if myenv["debug"] :
myenv.InstallAs('#/Packages/Swift/Swift-' + myenv["SWIFT_VERSION"] + '.pdb', "Swift.pdb")
-
-