diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-08-28 19:56:17 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-08-28 19:56:51 (GMT) |
commit | ca35957a3090dc38cfb71496e9d2d4016bb1bc9b (patch) | |
tree | 008bedd0de3e98be046524f572a196eadbe5e1ba | |
parent | 17444b1ad6e3a14b3fb3c194ba60042ad29c2c03 (diff) | |
download | swift-contrib-ca35957a3090dc38cfb71496e9d2d4016bb1bc9b.zip swift-contrib-ca35957a3090dc38cfb71496e9d2d4016bb1bc9b.tar.bz2 |
Add SCons tool to dump build version in a file.
-rw-r--r-- | BuildTools/SCons/Tools/AppBundle.py | 15 | ||||
-rw-r--r-- | BuildTools/SCons/Tools/BuildVersion.py | 17 | ||||
-rw-r--r-- | BuildTools/SCons/Tools/WriteVal.py | 14 | ||||
-rw-r--r-- | BuildTools/SCons/Version.py | 10 | ||||
-rw-r--r-- | SConstruct | 3 | ||||
-rw-r--r-- | Swift/Packaging/nsis/swift.nsi | 2 | ||||
-rw-r--r-- | Swift/QtUI/.gitignore | 1 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 11 |
8 files changed, 55 insertions, 18 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() @@ -1,4 +1,5 @@ import sys, os +sys.path.append(Dir("BuildTools/SCons").abspath) ################################################################################ # Build variables @@ -33,6 +34,8 @@ Help(vars.GenerateHelpText(env)) env.Alias("dist", ["."]) # Default custom tools +env.Tool("WriteVal", toolpath = ["#/BuildTools/SCons/Tools"]) +env.Tool("BuildVersion", toolpath = ["#/BuildTools/SCons/Tools"]) if env["PLATFORM"] == "darwin" : env.Tool("Nib", toolpath = ["#/BuildTools/SCons/Tools"]) env.Tool("AppBundle", toolpath = ["#/BuildTools/SCons/Tools"]) diff --git a/Swift/Packaging/nsis/swift.nsi b/Swift/Packaging/nsis/swift.nsi index afbee3c..6a9f0d2 100644 --- a/Swift/Packaging/nsis/swift.nsi +++ b/Swift/Packaging/nsis/swift.nsi @@ -2,7 +2,7 @@ !define msvccRedistributableExe "vcredist_x86.exe" # define installer name -outFile "Swift-installer-win32-${buildDate}.exe" +outFile "Swift-installer-win32-${buildVersion}.exe" # set desktop as install directory installDir "$PROGRAMFILES\Swift" diff --git a/Swift/QtUI/.gitignore b/Swift/QtUI/.gitignore index c1390ab..b776b0d 100644 --- a/Swift/QtUI/.gitignore +++ b/Swift/QtUI/.gitignore @@ -1 +1,2 @@ Swift +BuildVersion.h diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 384dcd4..43211a9 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -1,4 +1,5 @@ import os, shutil, datetime +import Version def generateDefaultTheme(env, target, source) : sourceDir = source[0].abspath @@ -77,6 +78,8 @@ sources = [ "qrc_Swift.cc", ] +myenv.BuildVersion("BuildVersion.h", version = ARGUMENTS.get("swift_version", None)) + if env["PLATFORM"] == "win32" : myenv.RES("../resources/Windows/Swift.rc") sources += ["../resources/Windows/Swift.res"] @@ -91,10 +94,10 @@ myenv.Uic4("QtAddContactDialog.ui") myenv.Qrc("DefaultTheme.qrc") myenv.Qrc("Swift.qrc") +buildVersion = Version.getBuildVersion(ARGUMENTS.get("swift_version", None)) + if env["PLATFORM"] == "darwin" : - myenv.AppBundle("Swift", resources = [ - "../resources/MacOSX/Swift.icns" - ]) + myenv.AppBundle("Swift", version = buildVersion, resources = ["../resources/MacOSX/Swift.icns"]) if env["PLATFORM"] == "win32" : if "dist" in COMMAND_LINE_TARGETS or env.GetOption("clean") : @@ -106,6 +109,6 @@ if env["PLATFORM"] == "win32" : myenv.Append(NSIS_OPTIONS = [ "/DmsvccRedistributableDir=\"" + env["vcredist"] + "\"", - "/DbuildDate=" + datetime.date.today().strftime("%Y%m%d") + "/DbuildVersion=" + buildVersion ]) myenv.Nsis("../Packaging/nsis/swift.nsi") |