diff options
Diffstat (limited to 'bin/libsize.pl')
-rwxr-xr-x | bin/libsize.pl | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/bin/libsize.pl b/bin/libsize.pl deleted file mode 100755 index 57df3565fdf..00000000000 --- a/bin/libsize.pl +++ /dev/null @@ -1,177 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# $Id$ -# -# Provides size breakdown of libACE.a or libTAO. -# -# Assumes (or builds) the lib with debug=0. Allows other make args, -# such as -j 4, to be passed on the command line. - -$usage="$0 [-h, for html output] [-v] [make args]"; - -#### -#### Configuration parameters. -#### -$build_args = - 'debug=0 optimize=1 static_libs_only=1 DEFFLAGS=-DACE_USE_RCSID=0'; -$ACE_COMPONENTS = - 'OS Utils Logging Threads Demux Connection Sockets IPC Svcconf ' . - 'Streams Memory Token Other'; -$TAO_COMPONENTS = - 'POA Pluggable_Protocols Default_Resources Interpretive_Marshaling ' . - 'IDL_Compiler ORB_Core Dynamic_Any'; - -#### The following are only used for VxWorks libraries, and -#### only if the corresponding environment variable isn't set. -$default_toolenv = '386'; -$default_wind_base = '/project/doc/pkg/wind'; -$default_host_type = 'sun4-solaris2'; - -#### Use gmake if it's on the user's PATH, otherwise use make. Use -#### sh -c to avoid warning if gmake isn't found. -$make = - system ("sh -c \"gmake --version\" > /dev/null 2>&1") ? 'make' : 'gmake'; - -$ACE_ROOT = $ENV{'ACE_ROOT'} || - die "$0: ACE_ROOT was not set!\n"; - -chop ($pwd = `pwd`); - -if ($pwd =~ m%/ace$%) { - #### Default: libACE - $tao = 0; -} elsif ($pwd =~ m%/tao$%) { - $tao = 1; -} else { - die "$0: unsupported directory; $pwd\n"; -} - -$html = $verbose = 0; - -#### -#### Process command line args. -#### -foreach my $arg (@ARGV) { - if ($arg eq '-h') { - $html = 1; - chop ($sysname = `uname -s`); - chop ($sysrev = `uname -r`); - shift; - } elsif ($arg eq '-v') { - $verbose = 1; - shift; - } elsif ($arg eq '-?') { - print "$usage"; - exit; - } else { - #### Pass remaining args to make. - } -} - -$make_args = join (' ', @ARGV) . $build_args; - -if ($tao) { - $COMPONENTS = "$TAO_COMPONENTS"; - $LIB_COMPONENTS = 'TAO_COMPONENTS'; - $libname = TAO; -} else { - $COMPONENTS = "$ACE_COMPONENTS"; - $LIB_COMPONENTS = 'ACE_COMPONENTS'; - $libname = ACE; -} - -$lib = "lib${libname}.a"; - - -#### -#### Select the size command based on ACE_ROOT setting. -#### -if ($ACE_ROOT =~ /vxworks/) { - $TOOLENV = $ENV{'TOOLENV'} || $default_toolenv; - $WIND_BASE = $ENV{'WIND_BASE'} || $default_wind_base; - $WIND_HOST_TYPE = $ENV{'WIND_HOST_TYPE'} || $default_host_type; - $size = "$WIND_BASE/host/$WIND_HOST_TYPE/bin/size$TOOLENV"; -} else { - $size = 'size'; -} - - -#### -#### Measure the size of the entire library. -#### -$sizeTotal = build_lib ("${libname}_COMPONENTS=\"$COMPONENTS\""); -$components = " <th>Platform\n <th>Component\n <th>Total"; -$componentSize = " <th>Size, bytes\n <td align=center>$sizeTotal"; -$componentPercentage = - " <th>Percentage of<br>total size\n <td align=center>100"; -print "Total $sizeTotal (100)\n" unless $html; - - -#### -#### Measure the size of each library component. -#### -foreach my $i (split (' ', $COMPONENTS)) { - $sizeLib = build_lib ("$LIB_COMPONENTS=\"$i\""); - $components .= "\n <th>$i"; - $componentSize .= "\n <td align=center>$sizeLib"; - $thisPercentage = percentage ($sizeLib, $sizeTotal); - $componentPercentage .= "\n <td align=center>$thisPercentage"; - print "$i $sizeLib ($thisPercentage)\n" unless $html; -} - -#### -#### Produce HTML output, if requested. -#### -if ($html) { - print '<center><table cellpadding=4 border=4>' . "\n"; - print ' <tr>' . "\n"; - print "$echoArgs $components\n"; - print ' <tr>' . "\n"; - print " <th rowspan=2>$sysname $sysrev $ACE_ROOT\n"; - print "$echoArgs $componentSize\n"; - print ' <tr>' . "\n"; - print "$echoArgs $componentPercentage\n"; - print '</table></center><p>' . "\n"; -} - - -#### -#### Build library with componnents specified in argument. -#### -sub build_lib () -{ - my ($lib_components) = @_; - - unlink "$lib"; - - print "$make $make_args $lib_components\n" if $verbose; - - system ("$make $make_args $lib_components >> make.log 2>&1") && - die "$0: command failed; $make $make_args $lib_components\n"; - - my $libSize = 0; - - open (SIZE, "$size $lib |") || - die "$0: unable to open $size\n"; - while (<SIZE>) { - my (@field) = split; - $libSize += $field[3]; - } - close (SIZE); - - $libSize; -} - - -#### -#### Return percentage of first argument as fraction of second. -#### Returns a string with two-decimal place precision. -#### -sub percentage () -{ - my ($size, $total) = @_; - - sprintf ("%.2f", $size * 100 / $total); -} |