diff options
author | Kevin Smith <git@kismith.co.uk> | 2014-02-22 12:33:59 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2014-02-22 16:25:27 (GMT) |
commit | 989b3711186d7fe9766dffa9334d70de78666db3 (patch) | |
tree | ca282e67d6da17430f0119362fa907357c32e0bb /BuildTools/SCons/Version.py | |
parent | be45135a1b1051eab02003fe54ee7e87f5f1558e (diff) | |
download | swift-989b3711186d7fe9766dffa9334d70de78666db3.zip swift-989b3711186d7fe9766dffa9334d70de78666db3.tar.bz2 |
Make git and wix wrappers in build system more convenient for use by other projects
Change-Id: I173f42bfe2dde7d18be3d54976649aa1bac13dbf
Diffstat (limited to 'BuildTools/SCons/Version.py')
-rw-r--r-- | BuildTools/SCons/Version.py | 16 |
1 files changed, 10 insertions, 6 deletions
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 |