From 1cd59852938964f4ed718d0447c8417c4a5e53aa Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 23 Sep 2017 21:59:25 +0100 Subject: [PATCH] updateversion.pl: Update versions in files as needed --- source/tools/updateversion.pl | 118 ++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 source/tools/updateversion.pl diff --git a/source/tools/updateversion.pl b/source/tools/updateversion.pl new file mode 100755 index 0000000..310a0b7 --- /dev/null +++ b/source/tools/updateversion.pl @@ -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 # +############################################################################# + +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 XSDCAL_VERSION + + if ($file_data_line =~ /^\#define\ XSDCAL_VERSION/){ + my $line_output = "#define XSDCAL_VERSION \""; + $line_output .= $version; + $line_output .= "\""; + $file_data_line = $line_output; + } + + # Look for XSDCAL_USERAGENT + + if ($file_data_line =~ /^\#define\ XSDCAL_USERAGENT/){ + my $line_output = "#define XSDCAL_USERAGENT \"XestiaCalendar/"; + $line_output .= $version; + $line_output .= "\""; + $file_data_line = $line_output; + } + +} + +# Update projects/msw/xestiacalendar.rc + +#$filename = "../../projects/msw/xestiacalendar.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/XestiaCalendar.xcodeproj/project.pbxproj + +$filename = "../../projects/osx/XestiaCalendar.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; + } + +} -- 2.39.2