From d51d1a462876ee547f618eabc21674276e2f3db3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Thu, 13 Aug 2009 17:46:26 +0200
Subject: Fix Windows bundling.


diff --git a/BuildTools/SCons/Tools/WindowsBundle.py b/BuildTools/SCons/Tools/WindowsBundle.py
new file mode 100644
index 0000000..1cada9d
--- /dev/null
+++ b/BuildTools/SCons/Tools/WindowsBundle.py
@@ -0,0 +1,15 @@
+import SCons.Util, os
+
+def generate(env) :
+  def createWindowsBundle(env, bundle, resources = [], qtlibs = []) :
+    env.Install(bundle, bundle + ".exe")
+    for lib in qtlibs :
+      env.Install(bundle, os.path.join(env["QTDIR"], "bin", lib + ".dll"))
+    for resource in resources :
+      env.Install(bundle, resource)
+
+  env.AddMethod(createWindowsBundle, "WindowsBundle")
+
+def exists(env) :
+  return env["PLATFORM"] == "win32"
+
diff --git a/SConstruct b/SConstruct
index bef9fdd..af4d153 100644
--- a/SConstruct
+++ b/SConstruct
@@ -34,6 +34,8 @@ env.Alias("dist", ["."])
 if env["PLATFORM"] == "darwin" :
 	env.Tool("Nib", toolpath = ["#/BuildTools/SCons/Tools"])
 	env.Tool("AppBundle", toolpath = ["#/BuildTools/SCons/Tools"])
+if env["PLATFORM"] == "win32" :
+	env.Tool("WindowsBundle", toolpath = ["#/BuildTools/SCons/Tools"])
 
 # Default compiler flags
 if env["optimize"] :
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 1666c64..8f9e2a0 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -15,17 +15,9 @@ def generateDefaultTheme(env, target, source) :
 	output.write("</qresource>")
 	output.write("</RCC>")
 
-def buildWindowsBundle(env, target, source) :
-	sources = source
-	if not os.path.exists(target[0].abspath) :
-		os.mkdir(target[0].abspath)
-	for source in sources :
-		shutil.copy(source.abspath, target[0].abspath)
-
 Import("env")
 
 myenv = env.Clone()
-myenv["BUILDERS"]["WindowsBundle"] = Builder(action = Action(buildWindowsBundle, cmdstr = "$BUNDLECOMSTR"))
 
 myenv.MergeFlags(env["SWIFT_CONTROLLERS_FLAGS"])
 myenv.MergeFlags(env["SWIFTEN_FLAGS"])
@@ -98,18 +90,12 @@ if env["PLATFORM"] == "darwin" :
     ])
 
 if env["PLATFORM"] == "win32" :
-	if "dist" in COMMAND_LINE_TARGETS or env.GetOption("clean") :
-		myenv.WindowsBundle(Dir("Swift"), [
-				swiftProgram[0],
-				File(os.path.join(env["QTDIR"], "bin", "QtCore4.dll")),
-				File(os.path.join(env["QTDIR"], "bin", "QtGui4.dll")),
-				File(os.path.join(env["QTDIR"], "bin", "QtNetwork4.dll")),
-				File(os.path.join(env["QTDIR"], "bin", "QtWebKit4.dll")),	
-				File(os.path.join(env["QTDIR"], "bin", "phonon4.dll")),	
-				File(os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll")),	
-				File(os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll")),	
-			])
+	myenv.WindowsBundle("Swift", resources = [
+			os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),	
+			os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"),	
+		], qtlibs = ["QtCore4", "QtGui4", "QtNetwork4", "QtWebKit4", "phonon4"])
 
+	if "dist" in COMMAND_LINE_TARGETS or env.GetOption("clean") :
 		myenv.Append(NSIS_OPTIONS = [
 				"/DmsvccRedistributableDir=\"" + env["vcredist"] + "\"", 
 				"/DbuildDate=" + datetime.date.today().strftime("%Y%m%d")
-- 
cgit v0.10.2-6-g49f6