From 989b3711186d7fe9766dffa9334d70de78666db3 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 22 Feb 2014 12:33:59 +0000
Subject: Make git and wix wrappers in build system more convenient for use by
 other projects

Change-Id: I173f42bfe2dde7d18be3d54976649aa1bac13dbf

diff --git a/BuildTools/SCons/Tools/wix.py b/BuildTools/SCons/Tools/wix.py
index 69622f6..7b62508 100644
--- a/BuildTools/SCons/Tools/wix.py
+++ b/BuildTools/SCons/Tools/wix.py
@@ -20,7 +20,7 @@ def generate(env) :
 		return [ "" + include for include in includes ]
 
 	heat_builder = SCons.Builder.Builder(
- 		action = '"$WIX_HEAT" dir Swift\\QtUI\\Swift -cg Files $WIX_HEAT_OPTIONS -o ${TARGET} -t Swift\\Packaging\\WiX\\include.xslt',
+ 		action = '"$WIX_HEAT" dir "$WIX_SOURCE_OBJECT_DIR" -cg Files $WIX_HEAT_OPTIONS -o ${TARGET} -t Swift\\Packaging\\WiX\\include.xslt',
 		suffix = '.wxi')
 
 
@@ -38,7 +38,7 @@ def generate(env) :
 
 
 	light_builder = SCons.Builder.Builder(
- 		action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b Swift\\QtUI\\Swift ${SOURCES} -o ${TARGET}',
+ 		action = '"$WIX_LIGHT" $WIX_LIGHT_OPTIONS -b "$WIX_SOURCE_OBJECT_DIR" ${SOURCES} -o ${TARGET}',
 		src_suffix = '.wixobj',
  		src_builder = candle_builder)
 
diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py
index 607b6f7..f98a8b9 100644
--- a/BuildTools/SCons/Version.py
+++ b/BuildTools/SCons/Version.py
@@ -1,19 +1,23 @@
 import subprocess, os, datetime, re, os.path
 
-def getGitBuildVersion(project) :
-  tag = git("describe --tags --exact --match \"" + project + "-*\"")
+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 + "-*\"")
+  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) :
-  p = subprocess.Popen("git " + cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
+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()
   return gitVersion if p.wait() == 0 else None
 
@@ -25,7 +29,7 @@ def getBuildVersion(root, project) :
     f.close()
     return version
 
-  gitVersion = getGitBuildVersion(project) 
+  gitVersion = getGitBuildVersion(root, project) 
   if gitVersion :
     return gitVersion
 
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 24fb371..56d2d1b 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -429,6 +429,7 @@ if env["PLATFORM"] == "win32" :
         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')
-- 
cgit v0.10.2-6-g49f6