[gtk-doc] scan: make the generated section file more deterministic



commit 84b58c06e1214c984f12af4067b6520d16707fe1
Author: Stefan Kost <ensonic users sf net>
Date:   Thu Aug 25 19:45:26 2011 +0200

    scan: make the generated section file more deterministic
    
    Sort the section and the symbols with the section.

 gtkdoc-scan.in |   41 +++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index cce2d5d..c3ae7e5 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -138,8 +138,7 @@ if ($REBUILD_TYPES) {
         || die "Can't open $new_types";
 }
 
-my $main_list = "";
-my $object_list = "";
+my %section_list = ();
 my $file;
 
 my @get_types = ();
@@ -151,16 +150,23 @@ my %seen_headers;
 
 # The header files to scan are passed in as command-line args.
 for $file (@ARGV) {
-    &ScanHeader ($file, \$object_list, \$main_list);
+    &ScanHeader ($file, \%section_list);
 }
 
 for my $dir (@SOURCE_DIRS) {
-    &ScanHeaders ($dir, \$object_list, \$main_list);
+    &ScanHeaders ($dir, \%section_list);
+}
+
+## FIXME: sort by key and output
+#print DECLLIST $section_list;
+my $section;
+foreach $section (sort(keys %section_list)) {
+    print DECLLIST "$section_list{$section}\n";
 }
 
-print DECLLIST $object_list, $main_list;
 close (DECLLIST);
 close (DECL);
+
 if ($REBUILD_TYPES) {
     my $func;
 
@@ -200,13 +206,11 @@ if (! -e $overrides_file) {
 # Description : This scans a directory tree looking for header files.
 #
 # Arguments   : $source_dir - the directory to scan.
-#                $object_list - a reference to the list of object functions &
-#                        declarations.
-#                $main_list - a reference to the list of other declarations.
+#               $section_list - a reference to the hashmap of sections.
 #############################################################################
 
 sub ScanHeaders {
-    my ($source_dir, $object_list, $main_list) = @_;
+    my ($source_dir, $section_list) = @_;
     @TRACE@("Scanning source directory: $source_dir");
 
     # This array holds any subdirectories found.
@@ -221,7 +225,7 @@ sub ScanHeaders {
         } elsif (-d "$source_dir/$file") {
             push (@subdirs, $file);
         } elsif ($file =~ m/\.h$/) {
-            &ScanHeader ("$source_dir/$file", $object_list, $main_list);
+            &ScanHeader ("$source_dir/$file", $section_list);
         }
     }
     closedir (SRCDIR);
@@ -230,7 +234,7 @@ sub ScanHeaders {
     my $dir;
     foreach $dir (@subdirs) {
         next if ($IGNORE_HEADERS =~ m/(\s|^)\Q${dir}\E(\s|$)/);
-        &ScanHeaders ("$source_dir/$dir", $object_list, $main_list);
+        &ScanHeaders ("$source_dir/$dir", $section_list);
     }
 }
 
@@ -241,14 +245,12 @@ sub ScanHeaders {
 #                functions, macros, typedefs, structs and unions, which it
 #                outputs to the DECL file.
 # Arguments   : $input_file - the header file to scan.
-#                $object_list - a reference to the list of object functions &
-#                        declarations.
-#                $main_list - a reference to the list of other declarations.
+#               $section_list - a reference to the hashmap of sections.
 # Returns     : it adds declarations to the appropriate list.
 #############################################################################
 
 sub ScanHeader {
-    my ($input_file, $object_list, $main_list) = @_;
+    my ($input_file, $section_list) = @_;
 
     my $list = "";                  # Holds the resulting list of declarations.
     my ($in_comment) = 0;                  # True if we are in a comment.
@@ -828,7 +830,10 @@ sub ScanHeader {
     }
 
     @TRACE@("Scanning $input_file done\n\n\n");
-
+    
+    # sort the symbols
+    $list=join("\n",sort(split("\n",$list)))."\n";
+   
 
     # Try to separate the standard macros and functions, placing them at the
     # end of the current section, in a subsection named 'Standard'.
@@ -858,11 +863,11 @@ sub ScanHeader {
         }
 
         if ($list ne "") {
-            $$object_list .= "<SECTION>\n<FILE>$file_basename</FILE>\n$list</SECTION>\n\n";
+            $$section_list{$file_basename} .= "<SECTION>\n<FILE>$file_basename</FILE>\n$list</SECTION>\n\n";
         }
     } else {
         if ($list ne "") {
-            $$main_list .= "<SECTION>\n<FILE>$file_basename</FILE>\n$list</SECTION>\n\n";
+            $$section_list{$file_basename} .= "<SECTION>\n<FILE>$file_basename</FILE>\n$list</SECTION>\n\n";
         }
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]