#!/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 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; } }