From a291848bceeb1dc59a1ae803148b8988d94ace54 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 10 Dec 2008 19:04:21 +0000 Subject: Added perl script to automatically add the build version to Info.plist. --- Scripts/build-version.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 Scripts/build-version.pl (limited to 'Scripts') diff --git a/Scripts/build-version.pl b/Scripts/build-version.pl new file mode 100755 index 00000000..f8cd47ec --- /dev/null +++ b/Scripts/build-version.pl @@ -0,0 +1,32 @@ +#! /usr/bin/perl -w + +## Author: Stuart Connolly (stuconnolly.com) +## Copyright (c) 2008 Stuart Connolly. All rights reserved. +## +## Paramters: +## +## Description: Updates the application/bundle's Info.plist CFBundleVersion to match that of the current +## Subversion revision. + +use strict; + +die "$0: Must be run from within Xcode. Exiting..." unless $ENV{"BUILT_PRODUCTS_DIR"}; + +my $revision = `svnversion -n ./`; +my $info_plist = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{INFOPLIST_PATH}"; + +my $version = $revision; + +($version =~ m/(\d+)[MS]*$/) && ($version = $1); + +die "$0: No Subversion revision found. Exiting..." unless $version; + +open(INFO_FH, "$info_plist") or die "$0: $info_plist: $!"; +my $info = join("", ); +close(INFO_FH); + +$info =~ s/([\t ]+CFBundleVersion<\/key>\n[\t ]+).*?(<\/string>)/$1$version$2/; + +open(INFO_FH, ">$info_plist") or die "$0: $info_plist: $!"; +print INFO_FH $info; +close(INFO_FH); -- cgit v1.2.3