bldsystemtools/commonbldutils/relnotes.pl
branchRCL_3
changeset 24 d90029decf65
parent 20 a9d4531388d0
child 33 54aa4a06a075
child 34 5e522efbae7b
equal deleted inserted replaced
20:a9d4531388d0 24:d90029decf65
     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 #
       
    16 #!perl
       
    17 
       
    18 # Release notes generator
       
    19 # 07/10/1999 - 18/11/99 RH
       
    20 
       
    21 use strict;
       
    22 
       
    23 sub PrintLines { print OUTFILE join("\n",@_),"\n"; }	
       
    24 
       
    25 if (@ARGV!=2 || ! -e $ARGV[0])
       
    26   {
       
    27 #........1.........2.........3.........4.........5.........6.........7.....
       
    28   print <<USAGE_EOF;
       
    29 
       
    30 --------------------------------------------------------------------------
       
    31 Usage
       
    32 -----
       
    33   perl relnotes.pl <listfile> <path>
       
    34 
       
    35 Generates an HTML document containing release notes for each
       
    36 component.
       
    37 
       
    38 <listfile> is a file containing a list of components and locations
       
    39   in the format:
       
    40     COMPNAME DIRECTORY [CH#1 CH#2]
       
    41   eg
       
    42     AGNMODEL AGNMODEL
       
    43   Release documentation is collexted for all relevant changelists
       
    44   in the range specified by <CH#1> and <CH#2>.
       
    45 
       
    46   The first line of the file must contain the default values for
       
    47   <CH#1> and <CH#2> separated by spaces.
       
    48 
       
    49 <path> is a path specifier (which may include wildcards)that,
       
    50   combined with the current view and the directory information in
       
    51   <listfile>, gives unambiguous access to component source on the
       
    52   appropriate branch(es) in the repository.
       
    53 
       
    54 The file name of the component list is assumed to be the same as the
       
    55 name of the target product.
       
    56 
       
    57 It is also assumed that revision specifier <CH#1> is earlier than
       
    58 revision specifier <CH#2>.
       
    59 
       
    60 Note
       
    61 ----
       
    62 Before using this utility, you must switch to a client that gives
       
    63 visibility to those branches of the repository that contain the
       
    64 submissions for which you want to extract release note documentation. 
       
    65 
       
    66 Example for Crystal
       
    67 -------------------
       
    68   Switch to a client that gives visibility to only //EPOC/Main/generic
       
    69   and //EPOC/Main/Crystal. Then type:
       
    70 
       
    71   perl relnotes.pl crystal.dat //EPOC/Main
       
    72 
       
    73   This generates release notes in a file named Crystal.html
       
    74 --------------------------------------------------------------------------
       
    75 
       
    76 USAGE_EOF
       
    77   exit 1;
       
    78   }
       
    79 
       
    80 my $listfile = $ARGV[0];
       
    81 my $srcpath = $ARGV[1];
       
    82 my $productname = $listfile;
       
    83 
       
    84 $productname =~ s#.*[\\\/]##;    # lose any leading path
       
    85 $productname =~ s#\.[^\.]+$##;   # lose any trailing extension
       
    86 
       
    87 $productname = ucfirst lc $productname;  # capitalise only first letter
       
    88 $productname =~ s/_os_/_OS_/i;   # Just making sure that OS is in caps
       
    89 $productname =~ s/_gt$/_GT/i;    # Just making sure that GT is in caps
       
    90 $productname =~ s/_tv$/_TV/i;    # Just making sure that TV is in caps
       
    91 
       
    92 $srcpath =~ s/\/\.\.\.$//;		# remove trailing /..., which slows things down
       
    93 
       
    94 open INFILE, "< $listfile" or die "ERROR: Can't read $listfile\n";
       
    95 
       
    96 
       
    97 my @listfile = <INFILE>;
       
    98 my $firstline = shift @listfile;
       
    99 
       
   100 $firstline =~ m/^\s*(\d+)\s+(\d+)/;
       
   101 my $default_firstchange = $1;
       
   102 my $default_lastchange = $2;
       
   103 
       
   104 if (!($default_firstchange > 0) || !($default_lastchange > 0))
       
   105   {
       
   106   die "ERROR: First line of $listfile must contain non-zero changelist numbers only\n";
       
   107   }
       
   108 
       
   109 my ( $s, $min, $hour, $mday, $mon, $year, $w, $y, $i)= localtime(time);
       
   110 $year+= 1900;
       
   111 $mon++;
       
   112 
       
   113 open OUTFILE, "> $productname.html" or die "ERROR: Can't open $productname.html for output";
       
   114 print OUTFILE <<HEADING_EOF;
       
   115 <html>\n\n<head>\n<title>$productname Release Notes</title>\n</head>\n\n
       
   116 <body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#5F9F9F\" vlink=\"5F9F9F\">\n
       
   117 <font face=verdana,arial,helvetica size=4>\n\n<hr>\n\n
       
   118 <a name=\"list\"><h1>$productname Release Notes</h1></a>
       
   119 <p>Created - $mday/$mon/$year\n
       
   120 HEADING_EOF
       
   121 
       
   122 my @newcomponents = ();
       
   123 my @nochangecomponents = ();
       
   124 
       
   125 foreach (@listfile)
       
   126   {
       
   127   my $firstchange = $default_firstchange;
       
   128   my $lastchange = $default_lastchange;
       
   129   
       
   130   my $newComponent = 0;
       
   131   
       
   132   s/\s*#.*$//;                 # remove comments
       
   133   if (/^\s*$/) { next; }       # ignore blank lines
       
   134   
       
   135   if (/^\s*\S+\s+\S+\s+(\d+)\s+(\d+)/) # get any non-default changelist numbers
       
   136     {
       
   137     $firstchange = $1;
       
   138     $lastchange = $2;
       
   139     
       
   140     $newComponent = 1 if ($firstchange == 0);
       
   141     }
       
   142     
       
   143   if (/^\s*(\S+)\s+(\S+)/)     # parse component data
       
   144     {
       
   145     my $compname = uc $1;
       
   146     my $topdir = $2;
       
   147 
       
   148     my $preform = 0;
       
   149     my $changeCount = 0;
       
   150 
       
   151     $firstchange++;         # inc changelist number so we don't include the very first submission - it would have been picked up in the last run of this script
       
   152 
       
   153     print "Processing $compname\n";
       
   154     my @complines = ();
       
   155 
       
   156     my $command = "p4 changes -l -s submitted $srcpath/$topdir/...\@$firstchange,$lastchange";
       
   157     my @compchange = `$command`;
       
   158     die "ERROR: Could not execute: $command\n" if $?;
       
   159 
       
   160     foreach my $line (@compchange)
       
   161       {
       
   162       if ($line !~ /\S/) { next; }      # ignore lines with no text 
       
   163       chomp $line;
       
   164       $line =~ s/\&/&amp;/g;
       
   165       $line =~ s/\</&lt;/g;
       
   166       $line =~ s/\>/&gt;/g;
       
   167       $line =~ s/\"/&quot;/g;
       
   168 
       
   169       if ($line =~ /^Change\s+\d+/i)
       
   170         {
       
   171         $changeCount+=1;
       
   172         $line =~ s/\s+by .*$//;
       
   173         if ($preform) 
       
   174           { 
       
   175           push @complines, "</pre>"; 
       
   176           $preform = 0; 
       
   177           }
       
   178         push @complines, "<p><b>$line</b>";
       
   179         push @complines, "<pre>";
       
   180         $preform = 1;
       
   181         next;
       
   182         }
       
   183 
       
   184       $line =~ s/^\s//;                 # drop first leading whitespace
       
   185       $line =~ s/^\t/  /;               # shorten any leading tab
       
   186       if ($changeCount == 0)
       
   187         {
       
   188         warn "WARNING: Description contains text preceding \"Change\". Printing line to output file:\n$line\n";
       
   189         }
       
   190       push @complines, $line;
       
   191       }
       
   192     if ($changeCount == 0)
       
   193     	{
       
   194     	if ($newComponent)
       
   195     		{
       
   196     		push @newcomponents, $compname;
       
   197     		}
       
   198     	else
       
   199     		{
       
   200     		push @nochangecomponents, $compname;
       
   201     		}
       
   202     	next;
       
   203     	}
       
   204 	# Component with real change descriptions
       
   205 	if ($preform)
       
   206 		{
       
   207 		push @complines, "</pre>";
       
   208 		}
       
   209 	&PrintLines("<h2>$compname</h2>",@complines);
       
   210     }
       
   211   }
       
   212 close INFILE;
       
   213 
       
   214 if (scalar @newcomponents)
       
   215 	{
       
   216 	&PrintLines("<h2>New Components</h2>", join(", ", sort @newcomponents));
       
   217 	}
       
   218 	
       
   219 if (scalar @nochangecomponents)
       
   220 	{
       
   221 	&PrintLines("<h2>Unchanged Components</h2>", join(", ", sort @nochangecomponents));
       
   222 	}
       
   223 	
       
   224 &PrintLines("</BODY></HTML>");
       
   225 close OUTFILE;