diff mbox

Improving mklog [was: Re: RFC Asan instrumentation control]

Message ID 52B2E3CD.8060106@samsung.com
State New
Headers show

Commit Message

Yury Gribov Dec. 19, 2013, 12:17 p.m. UTC
> In my experience mklog is pretty much useless, e.g. if you
> add a new function, it will list the previous function as being modified
> rather than the new one, etc.

In my experience it prints both the old and the new one. If that's a 
problem we could probably fix it (I mean I can volunteer).

Here's a draft patch for mklog which splits generated ChangeLog entry 
into several parts (so no more spurious gcc/ or gcc/testsuite/). I can 
continue working on this if people find it useful.

-Y

Comments

Yury Gribov Dec. 19, 2013, 1:04 p.m. UTC | #1
On 12/19/2013 04:17 PM, Yury Gribov wrote:
 >> In my experience mklog is pretty much useless, e.g. if you
 >> add a new function, it will list the previous function as being modified
 >> rather than the new one, etc.
 >
 > In my experience it prints both the old and the new one. If that's a
 > problem we could probably fix it (I mean I can volunteer).
 >
 > Here's a draft patch for mklog which splits generated ChangeLog entry
 > into several parts (so no more spurious gcc/ or gcc/testsuite/).
 > I can continue working on this if people find it useful.

Removed Kostya and Max, added Diego as original author of mklog.
diff mbox

Patch

diff --git a/contrib/mklog b/contrib/mklog
index a874c72..a9bf276 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -34,6 +34,10 @@  $name = @n[1]; chop($name);
 $addr = $username . "\@my.domain.org";
 $date = `date +%Y-%m-%d`; chop ($date);
 
+$gcc_root = $0;
+$gcc_root =~ s/[^\\\/]+$/../;
+chdir $gcc_root;
+
 
 #-----------------------------------------------------------------------------
 # Program starts here. You should not need to edit anything below this
@@ -53,13 +57,26 @@  $basename = `basename $diff`; chop ($basename);
 $cl = `mktemp /tmp/$basename.XXXXXX` || exit 1; chop ($cl);
 $hdrline = "$date  $name  <$addr>";
 
-open (CLFILE, ">$cl") or die "Could not open file $cl for writing";
-
-print CLFILE "$hdrline\n\n";
+my %clog_entries;
+
+sub get_clogname($) {
+	my $dirname = $_[0];
+	while ($dirname) {
+		my $clogname = "$dirname/ChangeLog";
+		if (-f $clogname) {
+			my $filename_rel = substr ($_[0], length ($dirname) + 1);
+			return ($filename_rel, $clogname);
+		} else {
+			$dirname =~ s/[\/\\]?[^\/\\]*$//;
+		} 
+	}
+	return ($_[0], 'Unknown Changelog');
+}
 
 # For every file in the .diff print all the function names in ChangeLog
 # format.
 $bof = 0;
+$clogname = get_clogname('');
 open (DFILE, $diff) or die "Could not open file $diff for reading";
 while (<DFILE>) {
     # Check if we found a new file.
@@ -68,10 +85,11 @@  while (<DFILE>) {
 	# $bof == 1), we just write out a ':' before starting the next
 	# file.
 	if ($bof == 1) {
-	    print CLFILE ":\n";
+		$clog_entries{$clogname} .= ":\n";
 	}
 	$filename = $2;
-	print CLFILE "\t* $filename";
+	($filename_rel, $clogname) = get_clogname ($filename);
+	$clog_entries{$clogname} .= "\t* $filename_rel";
 	$bof = 1;
     }
 
@@ -122,13 +140,13 @@  while (<DFILE>) {
 	    # to the filename, so we need an extra space before the opening
 	    # brace.
 	    if ($bof) {
-		print CLFILE " ";
+		$clog_entries{$clogname} .= " ";
 		$bof = 0;
 	    } else {
-		print CLFILE "\t";
+		$clog_entries{$clogname} .= "\t";
 	    }
 
-	    print CLFILE "($fn):\n";
+		$clog_entries{$clogname} .= "($fn):\n";
 	    $seen_names{$fn} = 1;
 	}
     }
@@ -138,10 +156,15 @@  while (<DFILE>) {
 # write out a ':'. This happens when there is only one file with no
 # functions.
 if ($bof == 1) {
-    print CLFILE ":\n";
+	$clog_entries{$clogname} .= ":\n";
+}
+
+open (CLFILE, ">$cl") or die "Could not open file $cl for writing";
+
+foreach my $clogname (keys %clog_entries) {
+	print CLFILE "$clogname:\n\n$hdrline\n\n$clog_entries{$clogname}\n";
 }
 
-print CLFILE "\n";
 close (DFILE);
 
 # Concatenate the ChangeLog template and the original .diff file.