cross-plat-dev-utils/get_baseline.pm
changeset 2 39c28ec933dd
child 6 787612182dd0
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 #!/usr/bin/perl
       
     2 # Copyright (c) 2010 Symbian Foundation Ltd
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Mike Kinghan, mikek@symbian.org, for Symbian Foundation Ltd - initial contribution.
       
    10 
       
    11 # Subroutine to get the mercurial revision from which this package was branched
       
    12 # from the file ../baseline.txt
       
    13 
       
    14 use strict;
       
    15 use File::Spec;
       
    16 use set_epocroot;
       
    17 
       
    18 sub trim($)
       
    19 {
       
    20 	my $string = shift;
       
    21 	$string =~ s/^\s+//;
       
    22 	$string =~ s/\s+$//;
       
    23 	return $string;
       
    24 }
       
    25 
       
    26 sub get_baseline()
       
    27 {
       
    28 	set_epocroot();
       
    29 	my $epocroot = $ENV{'EPOCROOT'};
       
    30 	my $baseline_txt = File::Spec->catfile("$epocroot","build","baseline.txt");
       
    31 	open IN,"<$baseline_txt" or die $!;
       
    32 	my @lines = <IN>;
       
    33 	close IN;
       
    34 	while(@lines and $lines[0] =~ /^\s*#/) {
       
    35 		shift @lines;
       
    36 	}
       
    37 	die "*** Error: can't extract baseline revsion no. from ../baseline.txt ***",
       
    38 		unless(@lines);
       
    39 	return trim($lines[0]);
       
    40 }
       
    41 
       
    42 1;
       
    43 
       
    44