group/update_version_h.pl
changeset 0 33413c0669b9
child 19 c29f8e059978
child 38 9f4e37332ce5
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # Updates version.h information with current date.
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use Cwd;
       
    20 use POSIX qw(strftime);
       
    21 
       
    22 my $PLATFORM_LONG = "4_2";
       
    23 my $PLATFORM_SHORT = "42";
       
    24 
       
    25 sub update_version_h
       
    26 {
       
    27 	my ($version_path, $platform) = @_;
       
    28 	
       
    29 	# Check path
       
    30 	if (! -e $version_path)
       
    31 	{
       
    32 		die "version.h can't be found from $version_path";
       
    33 	}
       
    34 	
       
    35 	# Form version strings
       
    36 	my $version = strftime($platform."_%y%m%d", localtime());
       
    37 	my $builddate = localtime();
       
    38 	
       
    39 	# Backup
       
    40 	if (-e "$version_path.BACKUP")
       
    41 	{
       
    42 		chmod 0666, "$version_path.BACKUP";
       
    43 		unlink "$version_path.BACKUP";
       
    44 	}
       
    45 	chmod 0666, $version_path;
       
    46 	rename $version_path, "$version_path.BACKUP";
       
    47 	
       
    48 	my ($infile, $outfile);
       
    49 	open $infile, "<$version_path.BACKUP" or die "Can't open $version_path.BACKUP : $!";
       
    50 	open $outfile, ">$version_path" or die "Can't open $version_path : $!";
       
    51 	while (<$infile>)
       
    52 	{
       
    53 		my $line = $_;
       
    54 		my $pattern1 = '_LIT\(KVersion.*?;';
       
    55 		my $replacement1 = "_LIT(KVersion, \"$version\");";
       
    56 		
       
    57 		my $pattern2 = '_LIT\(KBuildDate.*?;';
       
    58 		my $replacement2 = "_LIT(KBuildDate, \"$builddate\");";
       
    59 		
       
    60 		if ($line =~ s/$pattern1/$replacement1/g)
       
    61 		{
       
    62 			print "Updated KVersion\n";
       
    63 		}
       
    64 		elsif ($line =~ s/$pattern2/$replacement2/g)
       
    65 		{
       
    66 			print "Updated KBuildDate\n";
       
    67 		}
       
    68 		print $outfile $line;
       
    69 	}
       
    70 	close $infile;
       
    71 	close $outfile;
       
    72 }
       
    73 
       
    74 
       
    75 my $oldpwd = getcwd();
       
    76 chdir "..";
       
    77 
       
    78 ### VERSION.H ###########
       
    79 
       
    80 # version.h
       
    81 update_version_h(
       
    82     'vpnengine/vpncommon/inc/version.h',
       
    83     $PLATFORM_LONG);
       
    84 
       
    85 chdir $oldpwd;