list-ll_debugs.pl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/usr/bin/env perl
  2. # list_ll_debugs.pl v1.10 (c)2012-2023 Henri Beauchamp.
  3. # Released under the GPL (v2 or later, at your convenience) License:
  4. # http://www.gnu.org/copyleft/gpl.html
  5. #
  6. # This script constructs an XML file containing the LLSD representation of the
  7. # contents of a LLScrollListCtrl with two columns ("tag" and "references"),
  8. # based on the usage of the LL_DEBUGS macro in the viewer source tree.
  9. # The XML file is stored in the application settings directory of the viewer,
  10. # ready to be loaded in the debug tags floater.
  11. $basesourcedir = './indra/';
  12. $settingsdir = $basesourcedir . 'newview/app_settings/';
  13. $debugtagsfile = $settingsdir . 'debug_tags.xml';
  14. $filespattern = '^.*\.cpp\z';
  15. $searchstring1 = '^.*LL_DEBUGS\(\"([^\"]*)\"\).*$';
  16. $searchstring2 = '^.*LL_DEBUGS_ONCE\(\"([^\"]*)\"\).*$';
  17. $searchstring3 = '^.*LL_DEBUGS_SPARSE\(\"([^\"]*)\"\).*$';
  18. unless (-d $settingsdir) {
  19. die("I cannot find directory \"$settingsdir\". This script must be ran from the root of the source tree.\n");
  20. }
  21. # Search for all *.cpp files in the sources tree
  22. use File::Find();
  23. @files = ();
  24. sub wanted {
  25. /$filespattern/s && push(@files, $File::Find::name);
  26. }
  27. File::Find::find({wanted => \&wanted}, $basesourcedir);
  28. # Construct an associative array using the LL_DEBUGS(_ONCE) tags as keys and
  29. # the CSV list of the file names containing each tag as values
  30. %tags = ();
  31. foreach $file (@files) {
  32. open(FILE, $file);
  33. @lines = <FILE>;
  34. close(FILE);
  35. $file =~ s/$basesourcedir//;
  36. foreach $line (@lines) {
  37. chomp($line);
  38. if ($line =~ /$searchstring1/) {
  39. $line =~ s/$searchstring1/\1/;
  40. unless ($tags{$line} =~ /$file/) {
  41. $value = $tags{$line};
  42. if ($value ne '') {
  43. $value = $value . ', ';
  44. }
  45. $tags{$line} = $value . $file;
  46. }
  47. }
  48. if ($line =~ /$searchstring2/) {
  49. $line =~ s/$searchstring2/\1/;
  50. unless ($tags{$line} =~ /$file/) {
  51. $value = $tags{$line};
  52. if ($value ne '') {
  53. $value = $value . ', ';
  54. }
  55. $tags{$line} = $value . $file;
  56. }
  57. }
  58. if ($line =~ /$searchstring3/) {
  59. $line =~ s/$searchstring3/\1/;
  60. unless ($tags{$line} =~ /$file/) {
  61. $value = $tags{$line};
  62. if ($value ne '') {
  63. $value = $value . ', ';
  64. }
  65. $tags{$line} = $value . $file;
  66. }
  67. }
  68. }
  69. }
  70. # Create an XML file holding the LLSD representation of the contents of a
  71. # LLScrollListCtrl with two columns ("tag" and "references"), sorted by tag
  72. # name
  73. open(FILE, ">$debugtagsfile");
  74. print FILE "<llsd>\n";
  75. print FILE " <array>\n";
  76. $i = 1;
  77. foreach $tag (sort((keys(%tags)))) {
  78. print FILE " <map>\n";
  79. print FILE " <key>columns</key>\n";
  80. print FILE " <array>\n";
  81. print FILE " <map>\n";
  82. print FILE " <key>column</key>\n";
  83. print FILE " <string>tag</string>\n";
  84. print FILE " <key>value</key>\n";
  85. print FILE " <string>$tag</string>\n";
  86. print FILE " </map>\n";
  87. print FILE " <map>\n";
  88. print FILE " <key>column</key>\n";
  89. print FILE " <string>references</string>\n";
  90. print FILE " <key>value</key>\n";
  91. print FILE " <string>$tags{$tag}</string>\n";
  92. print FILE " </map>\n";
  93. print FILE " </array>\n";
  94. print FILE " <key>id</key>\n";
  95. print FILE " <integer>$i</integer>\n";
  96. print FILE " </map>\n";
  97. $i++;
  98. }
  99. print FILE " </array>\n";
  100. print FILE "</llsd>\n";
  101. close(FILE);