Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | # |
| 3 | # Program: GenLibDeps.pl |
| 4 | # |
| 5 | # Synopsis: Generate HTML output that shows the dependencies between a set of |
| 6 | # libraries. The output of this script should periodically replace |
| 7 | # the similar content in the UsingLibraries.html document. |
| 8 | # |
Reid Spencer | 1bc6864 | 2006-07-27 23:00:30 +0000 | [diff] [blame] | 9 | # Syntax: GenLibDeps.pl [-flat] <directory_with_libraries_in_it> [path_to_nm_binary] |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 10 | # |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 11 | use strict; |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 12 | use warnings; |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 13 | # Parse arguments... |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 14 | my $FLAT = 0; |
| 15 | my $WHY = 0; |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 16 | my $PEROBJ = 0; |
| 17 | my $PEROBJINCL = 0; |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 18 | while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) { |
| 19 | shift; |
| 20 | last if /^--$/; # Stop processing arguments on -- |
| 21 | |
| 22 | # List command line options here... |
| 23 | if (/^-flat$/) { $FLAT = 1; next; } |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 24 | if (/^-why/) { $WHY = 1; $FLAT = 1; next; } |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 25 | if (/^-perobj$/) { $PEROBJ = 1; next; } |
| 26 | if (/^-perobjincl/) { $PEROBJINCL = 1; next;} |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 27 | print "Unknown option: $_ : ignoring!\n"; |
| 28 | } |
| 29 | |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 30 | # Give first option a name. |
| 31 | my $Directory = $ARGV[0]; |
Reid Spencer | d0fa46a | 2006-08-03 19:10:03 +0000 | [diff] [blame] | 32 | if (!defined($Directory) || ! -d "$Directory") { |
| 33 | die "First argument must specify the directory containing LLVM libs\n"; |
Reid Spencer | 9bf2e7f | 2006-08-01 08:09:03 +0000 | [diff] [blame] | 34 | } |
Reid Spencer | d0fa46a | 2006-08-03 19:10:03 +0000 | [diff] [blame] | 35 | |
Reid Spencer | 1bc6864 | 2006-07-27 23:00:30 +0000 | [diff] [blame] | 36 | my $nmPath = $ARGV[1]; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 37 | |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 38 | # Find the "dot" program |
Reid Spencer | dd73e7f | 2006-05-13 02:48:45 +0000 | [diff] [blame] | 39 | my $DotPath=""; |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 40 | if (!$FLAT) { |
Reid Spencer | dd73e7f | 2006-05-13 02:48:45 +0000 | [diff] [blame] | 41 | chomp($DotPath = `which dot`); |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 42 | die "Can't find 'dot'" if (! -x "$DotPath"); |
| 43 | } |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 44 | |
Duncan Sands | 7e0842f | 2009-06-12 14:23:42 +0000 | [diff] [blame] | 45 | if (defined($ENV{NM})) { |
| 46 | chomp($nmPath=$ENV{NM}); |
| 47 | } |
| 48 | |
Reid Spencer | 9bf2e7f | 2006-08-01 08:09:03 +0000 | [diff] [blame] | 49 | if (!defined($nmPath) || $nmPath eq "") { |
| 50 | chomp($nmPath=`which nm`); |
| 51 | die "Can't find 'nm'" if (! -x "$nmPath"); |
Reid Spencer | 1bc6864 | 2006-07-27 23:00:30 +0000 | [diff] [blame] | 52 | } |
Reid Spencer | dd73e7f | 2006-05-13 02:48:45 +0000 | [diff] [blame] | 53 | |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 54 | my $ranlibPath; |
| 55 | if ($PEROBJ) { |
| 56 | $ranlibPath = $ARGV[2]; |
| 57 | if (defined($ENV{RANLIB})) { |
| 58 | chomp($ranlibPath=$ENV{RANLIB}); |
| 59 | } |
| 60 | |
| 61 | if (!defined($ranlibPath) || $ranlibPath eq "") { |
| 62 | chomp($ranlibPath=`which ranlib`); |
| 63 | die "Can't find 'ranlib'" if (! -x "$ranlibPath"); |
| 64 | } |
| 65 | } |
| 66 | |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 67 | # Open the directory and read its contents, sorting by name and differentiating |
| 68 | # by whether its a library (.a) or an object file (.o) |
| 69 | opendir DIR,$Directory; |
| 70 | my @files = readdir DIR; |
| 71 | closedir DIR; |
Oscar Fuentes | e40db4a | 2008-11-12 20:39:06 +0000 | [diff] [blame] | 72 | my @libs = grep(/libLLVM.*\.(dylib|so|a)$/,sort(@files)); |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 73 | my @objs = grep(/LLVM.*\.o$/,sort(@files)); |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 74 | |
| 75 | # Declare the hashes we will use to keep track of the library and object file |
| 76 | # symbol definitions. |
| 77 | my %libdefs; |
| 78 | my %objdefs; |
| 79 | |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 80 | my %libobjs; |
| 81 | my %objdeps=(); |
| 82 | # Gather library definitions at object file granularity (optional) |
| 83 | if ($PEROBJ) { |
| 84 | foreach my $lib (@libs ) { |
| 85 | `$ranlibPath $Directory/$lib`; |
| 86 | my $libpath = $lib; |
| 87 | $libpath =~ s/^libLLVM(.*)\.a/$1/; |
| 88 | $libpath =~ s/(.+)CodeGen$/Target\/$1/; |
| 89 | $libpath =~ s/(.+)AsmPrinter$/Target\/$1\/AsmPrinter/; |
| 90 | $libpath =~ s/(.+)AsmParser$/Target\/$1\/AsmParser/; |
| 91 | $libpath =~ s/(.+)Info$/Target\/$1\/TargetInfo/; |
| 92 | $libpath =~ s/(.+)Disassembler$/Target\/$1\/Disassembler/; |
| 93 | $libpath =~ s/SelectionDAG/CodeGen\/SelectionDAG/; |
| 94 | $libpath =~ s/^AsmPrinter/CodeGen\/AsmPrinter/; |
| 95 | $libpath =~ s/^BitReader/Bitcode\/Reader/; |
| 96 | $libpath =~ s/^BitWriter/Bitcode\/Writer/; |
| 97 | $libpath =~ s/^CBackend/Target\/CBackend/; |
| 98 | $libpath =~ s/^CppBackend/Target\/CppBackend/; |
| 99 | $libpath =~ s/^MSIL/Target\/MSIL/; |
| 100 | $libpath =~ s/^Core/VMCore/; |
| 101 | $libpath =~ s/^Instrumentation/Transforms\/Instrumentation/; |
| 102 | $libpath =~ s/^Interpreter/ExecutionEngine\/Interpreter/; |
| 103 | $libpath =~ s/^JIT/ExecutionEngine\/JIT/; |
| 104 | $libpath =~ s/^ScalarOpts/Transforms\/Scalar/; |
| 105 | $libpath =~ s/^TransformUtils/Transforms\/Utils/; |
| 106 | $libpath =~ s/^ipa/Analysis\/IPA/; |
| 107 | $libpath =~ s/^ipo/Transforms\/IPO/; |
| 108 | $libpath =~ s/^pic16passes/Target\/PIC16\/PIC16Passes/; |
| 109 | $libpath = "lib/".$libpath."/"; |
| 110 | open DEFS, "$nmPath -sg $Directory/$lib|"; |
| 111 | while (<DEFS>) { |
| 112 | chomp; |
| 113 | if (/^([^ ]*) in ([^ ]*)/) { |
| 114 | my $objfile = $libpath.$2; |
| 115 | $objdefs{$1} = $objfile; |
| 116 | $objdeps{$objfile} = {}; |
| 117 | $libobjs{$lib}{$objfile}=1; |
| 118 | # my $p = "../llvm/".$objfile; |
| 119 | # $p =~ s/Support\/reg(.*).o/Support\/reg$1.c/; |
| 120 | # $p =~ s/.o$/.cpp/; |
| 121 | # unless (-e $p) { |
| 122 | # die "$p\n" |
| 123 | # } |
| 124 | } |
| 125 | } |
| 126 | close DEFS or die "nm failed"; |
| 127 | } |
| 128 | foreach my $lib (@libs ) { |
| 129 | my $libpath = $lib; |
| 130 | $libpath =~ s/^libLLVM(.*)\.a/$1/; |
| 131 | $libpath =~ s/(.+)CodeGen$/Target\/$1/; |
| 132 | $libpath =~ s/(.+)AsmPrinter$/Target\/$1\/AsmPrinter/; |
| 133 | $libpath =~ s/(.+)AsmParser$/Target\/$1\/AsmParser/; |
| 134 | $libpath =~ s/(.+)Info$/Target\/$1\/TargetInfo/; |
| 135 | $libpath =~ s/(.+)Disassembler$/Target\/$1\/Disassembler/; |
| 136 | $libpath =~ s/SelectionDAG/CodeGen\/SelectionDAG/; |
| 137 | $libpath =~ s/^AsmPrinter/CodeGen\/AsmPrinter/; |
| 138 | $libpath =~ s/^BitReader/Bitcode\/Reader/; |
| 139 | $libpath =~ s/^BitWriter/Bitcode\/Writer/; |
| 140 | $libpath =~ s/^CBackend/Target\/CBackend/; |
| 141 | $libpath =~ s/^CppBackend/Target\/CppBackend/; |
| 142 | $libpath =~ s/^MSIL/Target\/MSIL/; |
| 143 | $libpath =~ s/^Core/VMCore/; |
| 144 | $libpath =~ s/^Instrumentation/Transforms\/Instrumentation/; |
| 145 | $libpath =~ s/^Interpreter/ExecutionEngine\/Interpreter/; |
| 146 | $libpath =~ s/^JIT/ExecutionEngine\/JIT/; |
| 147 | $libpath =~ s/^ScalarOpts/Transforms\/Scalar/; |
| 148 | $libpath =~ s/^TransformUtils/Transforms\/Utils/; |
| 149 | $libpath =~ s/^ipa/Analysis\/IPA/; |
| 150 | $libpath =~ s/^ipo/Transforms\/IPO/; |
| 151 | $libpath =~ s/^pic16passes/Target\/PIC16\/PIC16Passes/; |
| 152 | $libpath = "lib/".$libpath."/"; |
| 153 | open UDEFS, "$nmPath -Aup $Directory/$lib|"; |
| 154 | while (<UDEFS>) { |
| 155 | chomp; |
| 156 | if (/:([^:]+):/) { |
| 157 | my $obj = $libpath.$1; |
| 158 | s/[^ ]+: *U //; |
| 159 | if (defined($objdefs{$_})) { |
| 160 | $objdeps{$obj}{$objdefs{$_}}=1; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | close UDEFS or die "nm failed" |
| 165 | } |
| 166 | } else { |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 167 | # Gather definitions from the libraries |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 168 | foreach my $lib (@libs ) { |
| 169 | open DEFS, "$nmPath -g $Directory/$lib|"; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 170 | while (<DEFS>) { |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 171 | next if (! / [ABCDGRST] /); |
| 172 | s/^[^ ]* [ABCDGRST] //; |
Ted Kremenek | ec9e716 | 2007-12-24 08:04:39 +0000 | [diff] [blame] | 173 | s/\015?\012//; # not sure if <DEFS> is in binmode and uses LF or CRLF. |
| 174 | # this strips both LF and CRLF. |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 175 | $libdefs{$_} = $lib; |
| 176 | } |
Anton Korobeynikov | 8d8fbf2 | 2009-04-21 16:04:14 +0000 | [diff] [blame] | 177 | close DEFS or die "nm failed"; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 178 | } |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 179 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 180 | |
| 181 | # Gather definitions from the object files. |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 182 | foreach my $obj (@objs ) { |
| 183 | open DEFS, "$nmPath -g $Directory/$obj |"; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 184 | while (<DEFS>) { |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 185 | next if (! / [ABCDGRST] /); |
| 186 | s/^[^ ]* [ABCDGRST] //; |
Ted Kremenek | ec9e716 | 2007-12-24 08:04:39 +0000 | [diff] [blame] | 187 | s/\015?\012//; # not sure if <DEFS> is in binmode and uses LF or CRLF. |
| 188 | # this strips both LF and CRLF. |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 189 | $objdefs{$_} = $obj; |
| 190 | } |
Anton Korobeynikov | 8d8fbf2 | 2009-04-21 16:04:14 +0000 | [diff] [blame] | 191 | close DEFS or die "nm failed"; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | # Generate one entry in the <dl> list. This generates the <dt> and <dd> elements |
| 195 | # for one library or object file. The <dt> provides the name of the library or |
| 196 | # object. The <dd> provides a list of the libraries/objects it depends on. |
| 197 | sub gen_one_entry { |
| 198 | my $lib = $_[0]; |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 199 | my $lib_ns = $lib; |
| 200 | $lib_ns =~ s/(.*)\.[oa]/$1/; |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 201 | if ($FLAT) { |
| 202 | print "$lib:"; |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 203 | if ($WHY) { print "\n"; } |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 204 | } else { |
| 205 | print " <dt><b>$lib</b</dt><dd><ul>\n"; |
| 206 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 207 | open UNDEFS, |
Duncan Sands | 7e0842f | 2009-06-12 14:23:42 +0000 | [diff] [blame] | 208 | "$nmPath -u $Directory/$lib | sed -e 's/^[ 0]* U //' | sort | uniq |"; |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 209 | my %DepLibs; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 210 | while (<UNDEFS>) { |
| 211 | chomp; |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 212 | my $lib_printed = 0; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 213 | if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 214 | $DepLibs{$libdefs{$_}} = [] unless exists $DepLibs{$libdefs{$_}}; |
| 215 | push(@{$DepLibs{$libdefs{$_}}}, $_); |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 216 | } elsif (defined($objdefs{$_}) && $objdefs{$_} ne $lib) { |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 217 | if ($PEROBJ && !$PEROBJINCL) { |
| 218 | # -perobjincl makes .a files depend on .o files they contain themselves |
| 219 | # default is don't depend on these. |
| 220 | next if defined $libobjs{$lib}{$objdefs{$_}}; |
| 221 | } |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 222 | my $libroot = $lib; |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 223 | $libroot =~ s/lib(.*).a/$1/; |
| 224 | if ($objdefs{$_} ne "$libroot.o") { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 225 | $DepLibs{$objdefs{$_}} = [] unless exists $DepLibs{$objdefs{$_}}; |
| 226 | push(@{$DepLibs{$objdefs{$_}}}, $_); |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | } |
Anton Korobeynikov | 8d8fbf2 | 2009-04-21 16:04:14 +0000 | [diff] [blame] | 230 | close UNDEFS or die "nm failed"; |
Chris Lattner | 8d59af3 | 2008-10-04 18:03:46 +0000 | [diff] [blame] | 231 | unless(keys %DepLibs) { |
| 232 | # above failed |
Duncan Sands | 7e0842f | 2009-06-12 14:23:42 +0000 | [diff] [blame] | 233 | open UNDEFS, "$nmPath -u $Directory/$lib |"; |
Chris Lattner | 8d59af3 | 2008-10-04 18:03:46 +0000 | [diff] [blame] | 234 | while (<UNDEFS>) { |
| 235 | # to bypass non-working sed |
| 236 | if (' ' eq substr($_,0,2) and index($_,'U ')) { |
| 237 | $_ = substr($_,index($_,'U ')+2) |
| 238 | }; |
| 239 | $_ = substr($_,index($_,' *U ')+5) if -1!=index($_,' *U '); |
| 240 | |
| 241 | chomp; |
| 242 | my $lib_printed = 0; |
| 243 | if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) { |
| 244 | $DepLibs{$libdefs{$_}} = [] unless exists $DepLibs{$libdefs{$_}}; |
| 245 | push(@{$DepLibs{$libdefs{$_}}}, $_); |
| 246 | } elsif (defined($objdefs{$_}) && $objdefs{$_} ne $lib) { |
| 247 | my $libroot = $lib; |
| 248 | $libroot =~ s/lib(.*).a/$1/; |
| 249 | if ($objdefs{$_} ne "$libroot.o") { |
| 250 | $DepLibs{$objdefs{$_}} = [] unless exists $DepLibs{$objdefs{$_}}; |
| 251 | push(@{$DepLibs{$objdefs{$_}}}, $_); |
| 252 | } |
| 253 | } |
| 254 | } |
Anton Korobeynikov | 8d8fbf2 | 2009-04-21 16:04:14 +0000 | [diff] [blame] | 255 | close UNDEFS or die "nm failed"; |
Chris Lattner | 8d59af3 | 2008-10-04 18:03:46 +0000 | [diff] [blame] | 256 | } |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 257 | if ($PEROBJINCL) { |
| 258 | # include the .a's objects |
| 259 | for my $obj (keys %{$libobjs{$lib}}) { |
| 260 | $DepLibs{$obj} = ["<.a object>"] unless exists $DepLibs{$obj}; |
| 261 | } |
| 262 | my $madechange = 1; |
| 263 | while($madechange) { |
| 264 | $madechange = 0; |
| 265 | my %temp = %DepLibs; |
| 266 | foreach my $obj (keys %DepLibs) { |
| 267 | foreach my $objdeps (keys %{$objdeps{$obj}}) { |
| 268 | next if defined $temp{$objdeps}; |
| 269 | push(@{$temp{$objdeps}}, $obj); |
| 270 | $madechange = 1; |
| 271 | } |
| 272 | } |
| 273 | %DepLibs = %temp; |
| 274 | } |
| 275 | } |
Chris Lattner | 8d59af3 | 2008-10-04 18:03:46 +0000 | [diff] [blame] | 276 | |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 277 | for my $key (sort keys %DepLibs) { |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 278 | if ($FLAT) { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 279 | print " $key"; |
| 280 | if ($WHY) { |
| 281 | print "\n"; |
| 282 | my @syms = @{$DepLibs{$key}}; |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 283 | foreach my $sym (@syms) { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 284 | print " $sym\n"; |
| 285 | } |
| 286 | } |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 287 | } else { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 288 | print " <li>$key</li>\n"; |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 289 | } |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 290 | my $suffix = substr($key,length($key)-1,1); |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 291 | $key =~ s/(.*)\.[oa]/$1/; |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 292 | if ($suffix eq "a") { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 293 | if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=0 ];\n" }; |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 294 | } else { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 295 | if (!$FLAT) { print DOT "$lib_ns -> $key [ weight=10];\n" }; |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 296 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 297 | } |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 298 | if ($FLAT) { |
Reid Spencer | c152efd | 2006-07-25 19:12:06 +0000 | [diff] [blame] | 299 | if (!$WHY) { |
| 300 | print "\n"; |
| 301 | } |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 302 | } else { |
| 303 | print " </ul></dd>\n"; |
| 304 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | # Make sure we flush on write. This is slower but correct based on the way we |
| 308 | # write I/O in gen_one_entry. |
| 309 | $| = 1; |
| 310 | |
| 311 | # Print the definition list tag |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 312 | if (!$FLAT) { |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 313 | print "<dl>\n"; |
| 314 | |
| 315 | open DOT, "| $DotPath -Tgif > libdeps.gif"; |
| 316 | |
Reid Spencer | 9bf2e7f | 2006-08-01 08:09:03 +0000 | [diff] [blame] | 317 | print DOT "digraph LibDeps {\n"; |
| 318 | print DOT " size=\"40,15\"; \n"; |
| 319 | print DOT " ratio=\"1.33333\"; \n"; |
| 320 | print DOT " margin=\"0.25\"; \n"; |
| 321 | print DOT " rankdir=\"LR\"; \n"; |
| 322 | print DOT " mclimit=\"50.0\"; \n"; |
| 323 | print DOT " ordering=\"out\"; \n"; |
| 324 | print DOT " center=\"1\";\n"; |
| 325 | print DOT "node [shape=\"box\",\n"; |
| 326 | print DOT " color=\"#000088\",\n"; |
| 327 | print DOT " fillcolor=\"#FFFACD\",\n"; |
| 328 | print DOT " fontcolor=\"#3355BB\",\n"; |
| 329 | print DOT " style=\"filled\",\n"; |
| 330 | print DOT " fontname=\"sans\",\n"; |
| 331 | print DOT " fontsize=\"24\"\n"; |
| 332 | print DOT "];\n"; |
| 333 | print DOT "edge [dir=\"forward\",style=\"solid\",color=\"#000088\"];\n"; |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 334 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 335 | |
| 336 | # Print libraries first |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 337 | foreach my $lib (@libs) { |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 338 | gen_one_entry($lib); |
| 339 | } |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 340 | |
Torok Edwin | 18743f4 | 2010-02-04 09:31:35 +0000 | [diff] [blame] | 341 | if ($PEROBJ) { |
| 342 | foreach my $obj (keys %objdeps) { |
| 343 | print "$obj:"; |
| 344 | if (!$PEROBJINCL) { |
| 345 | foreach my $dep (keys %{$objdeps{$obj}}) { |
| 346 | print " $dep"; |
| 347 | } |
| 348 | } |
| 349 | print "\n"; |
| 350 | } |
| 351 | } |
| 352 | |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 353 | if (!$FLAT) { |
| 354 | print DOT "}\n"; |
| 355 | close DOT; |
| 356 | open DOT, "| $DotPath -Tgif > objdeps.gif"; |
Reid Spencer | 9bf2e7f | 2006-08-01 08:09:03 +0000 | [diff] [blame] | 357 | print DOT "digraph ObjDeps {\n"; |
| 358 | print DOT " size=\"8,10\";\n"; |
| 359 | print DOT " margin=\"0.25\";\n"; |
| 360 | print DOT " rankdir=\"LR\";\n"; |
| 361 | print DOT " mclimit=\"50.0\";\n"; |
| 362 | print DOT " ordering=\"out\";\n"; |
| 363 | print DOT " center=\"1\";\n"; |
| 364 | print DOT "node [shape=\"box\",\n"; |
| 365 | print DOT " color=\"#000088\",\n"; |
| 366 | print DOT " fillcolor=\"#FFFACD\",\n"; |
| 367 | print DOT " fontcolor=\"#3355BB\",\n"; |
| 368 | print DOT " fontname=\"sans\",\n"; |
| 369 | print DOT " style=\"filled\",\n"; |
| 370 | print DOT " fontsize=\"24\"\n"; |
| 371 | print DOT "];\n"; |
| 372 | print DOT "edge [dir=\"forward\",style=\"solid\",color=\"#000088\"];\n"; |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 373 | } |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 374 | |
| 375 | # Print objects second |
Ted Kremenek | 8330b0e | 2007-11-27 19:31:11 +0000 | [diff] [blame] | 376 | foreach my $obj (@objs) { |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 377 | gen_one_entry($obj); |
| 378 | } |
| 379 | |
Reid Spencer | 44fa691 | 2006-04-20 23:09:57 +0000 | [diff] [blame] | 380 | if (!$FLAT) { |
| 381 | print DOT "}\n"; |
| 382 | close DOT; |
Reid Spencer | 6234582 | 2005-01-05 17:29:29 +0000 | [diff] [blame] | 383 | |
Reid Spencer | 579b8de | 2004-12-30 23:07:56 +0000 | [diff] [blame] | 384 | # Print end tag of definition list element |
Reid Spencer | 0bf1177 | 2006-03-19 22:08:01 +0000 | [diff] [blame] | 385 | print "</dl>\n"; |
| 386 | } |