summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-08-28 19:56:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-28 19:56:51 (GMT)
commitca35957a3090dc38cfb71496e9d2d4016bb1bc9b (patch)
tree008bedd0de3e98be046524f572a196eadbe5e1ba /BuildTools
parent17444b1ad6e3a14b3fb3c194ba60042ad29c2c03 (diff)
downloadswift-ca35957a3090dc38cfb71496e9d2d4016bb1bc9b.zip
swift-ca35957a3090dc38cfb71496e9d2d4016bb1bc9b.tar.bz2
Add SCons tool to dump build version in a file.
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/SCons/Tools/AppBundle.py15
-rw-r--r--BuildTools/SCons/Tools/BuildVersion.py17
-rw-r--r--BuildTools/SCons/Tools/WriteVal.py14
-rw-r--r--BuildTools/SCons/Version.py10
4 files changed, 43 insertions, 13 deletions
diff --git a/BuildTools/SCons/Tools/AppBundle.py b/BuildTools/SCons/Tools/AppBundle.py
index 17a7e4f..2849435 100644
--- a/BuildTools/SCons/Tools/AppBundle.py
+++ b/BuildTools/SCons/Tools/AppBundle.py
@@ -1,18 +1,7 @@
import SCons.Util
def generate(env) :
- # WriteVal helper builder
- def writeVal(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(writeVal, cmdstr = "$GENCOMSTR"),
- single_source = True)
-
- # createAppBundle
- def createAppBundle(env, bundle, resources = [], info = {}) :
+ def createAppBundle(env, bundle, version = "1.0", resources = [], info = {}) :
bundleContentsDir = bundle + ".app" + "/Contents"
resourcesDir = bundleContentsDir + "/Resources"
env.Install(bundleContentsDir + "/MacOS", bundle)
@@ -26,7 +15,7 @@ def generate(env) :
"CFBundleName" : bundle,
"CFBundlePackageType" : "APPL",
"CFBundleSignature": "\77\77\77\77",
- "CFBundleVersion" : "1.0",
+ "CFBundleVersion" : version,
"CFBundleIconFile" : bundle,
"NSPrincipalClass" : "NSApplication",
"NSHumanReadableCopyright" : unichr(0xA9) + " 2009 Swift Development Team.\nAll Rights Reserved."
diff --git a/BuildTools/SCons/Tools/BuildVersion.py b/BuildTools/SCons/Tools/BuildVersion.py
new file mode 100644
index 0000000..530ef8a
--- /dev/null
+++ b/BuildTools/SCons/Tools/BuildVersion.py
@@ -0,0 +1,17 @@
+import SCons.Util
+
+import Version
+
+def generate(env) :
+ def createBuildVersion(env, target, version = None) :
+ buildVersion = """#pragma once
+
+static const char* buildVersion = \"%(buildVersion)s\";\n
+""" % { "buildVersion" : Version.getBuildVersion(version) }
+ env.WriteVal(target, env.Value(buildVersion))
+
+ env.AddMethod(createBuildVersion, "BuildVersion")
+
+
+def exists(env) :
+ return true
diff --git a/BuildTools/SCons/Tools/WriteVal.py b/BuildTools/SCons/Tools/WriteVal.py
new file mode 100644
index 0000000..e39ad82
--- /dev/null
+++ b/BuildTools/SCons/Tools/WriteVal.py
@@ -0,0 +1,14 @@
+import SCons.Util
+
+def generate(env) :
+ def writeVal(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(writeVal, cmdstr = "$GENCOMSTR"),
+ single_source = True)
+
+def exists(env) :
+ return True
diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py
new file mode 100644
index 0000000..c707942
--- /dev/null
+++ b/BuildTools/SCons/Version.py
@@ -0,0 +1,10 @@
+import subprocess
+
+def getGitBuildVersion() :
+ p = subprocess.Popen("git rev-parse HEAD", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
+ return p.stdout.read().rstrip()[0:7]
+
+def getBuildVersion(version = None) :
+ if version :
+ return version
+ return getGitBuildVersion()