Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
updateversion.pl: Easily update the version in certain files
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 11 Mar 2017 16:01:11 +0000 (16:01 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 11 Mar 2017 16:01:11 +0000 (16:01 +0000)
source/tools/updateversion.pl [new file with mode: 0755]

diff --git a/source/tools/updateversion.pl b/source/tools/updateversion.pl
new file mode 100755 (executable)
index 0000000..1f7dc3e
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/perl
+
+#############################################################################
+# Xestia Address Book: Version Updater                                     #
+# (c) 2017 Xestia Address Book                                             #
+#############################################################################
+# This file is part of Xestia Address Book.                                #
+#                                                                          #
+# Xestia Address Book is free software: you can redistribute it and/or      #
+# modify it under the terms of the GNU General Public License as published  #
+# by the Free Software Foundation, version 3 of the license.               #
+#                                                                          #
+# Xestia Address Book is distributed in the hope that it will be useful,    #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License along   #
+# with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>     #
+#############################################################################
+
+use strict;
+use warnings;
+use Tie::File;
+
+# Get the version number.
+
+if (!$ARGV[0]){
+       print "Error: No version specified!\n";
+       exit;
+}
+
+my $version = $ARGV[0];
+
+my $filename;
+my $file_handle;
+my @file_data;
+
+# Split the version information down.
+
+my @version_split = split(/(\.)/, $version);
+
+my $version_major = $version_split[0];
+my $version_minor = $version_split[2];
+
+# Update source/version.h
+
+$filename = "../version.h";
+
+tie(@file_data, 'Tie::File', $filename);
+foreach my $file_data_line(@file_data) {
+
+       # Look for XSDAB_VERSION
+
+       if ($file_data_line =~ /^\#define\ XSDAB_VERSION/){
+               my $line_output = "#define XSDAB_VERSION \"";
+               $line_output .= $version;
+               $line_output .= "\"";
+               $file_data_line = $line_output;
+       }       
+
+       # Look for XSDAB_USERAGENT
+
+       if ($file_data_line =~ /^\#define\ XSDAB_USERAGENT/){
+               my $line_output = "#define XSDAB_USERAGENT \"XestiaAddressBook/";
+               $line_output .= $version;
+               $line_output .= "\"";
+               $file_data_line = $line_output;
+       }       
+
+}
+
+# Update projects/msw/xestiaab.rc
+
+$filename = "../../projects/msw/xestiaab.rc";
+tie(@file_data, 'Tie::File', $filename);
+foreach my $file_data_line(@file_data) {
+
+       # Look for FILEVERSION
+
+       if ($file_data_line =~ /^    FILEVERSION/){
+               my $line_output = "    FILEVERSION     ";
+               $line_output .= $version_major;
+               $line_output .= ",";
+               $line_output .= $version_minor;
+               $line_output .= ",0,0";
+               $file_data_line = $line_output;
+       }       
+
+       # Look for PRODUCTVERSION
+
+       if ($file_data_line =~ /^    PRODUCTVERSION/){
+               my $line_output = "    PRODUCTVERSION  ";
+               $line_output .= $version_major;
+               $line_output .= ",";
+               $line_output .= $version_minor;
+               $line_output .= ",0,0";
+               $file_data_line = $line_output;
+       }       
+
+}
+
+# Update projects/osx/XestiaAddressBook.xcodeproj/project.pbxproj
+
+$filename = "../../projects/osx/XestiaAddressBook.xcodeproj/project.pbxproj";
+tie(@file_data, 'Tie::File', $filename);
+foreach my $file_data_line(@file_data) {
+
+       # Look for PRODUCT_VERSION
+
+       if ($file_data_line =~ /^\t\t\t\tPRODUCT_VERSION/){
+               my $line_output = "\t\t\t\tPRODUCT_VERSION = ";
+               $line_output .= $version;
+               $line_output .= ";";
+               $file_data_line = $line_output;
+       }
+
+}
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy