1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
#
# Provides size breakdown of ACE, TAO, or orbsvcs libs.
#
# 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] [-s, for shared libs] [-v] [make arguments]\n";
####
#### Configuration parameters.
####
$build_args =
'debug=0 optimize=1 static_libs_only=1';
$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';
$ORBSVCS_COMPONENTS =
'Naming ImplRepo Time Concurrency Property Trader LifeCycle Sched ' .
'Event CosEvent Event2 AV';
#### 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";
$html = $verbose = 0;
$lib_extension = 'a';
####
#### Process command line args.
####
while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) {
if ($ARGV[0] eq '-h') {
$html = 1;
chop ($sysname = `uname -s`);
chop ($sysrev = `uname -r`);
shift;
} elsif ($ARGV[0] eq '-s') {
$lib_extension = 'so';
$build_args =~ s/ static_libs_only=1//;
shift;
} elsif ($ARGV[0] eq '-v') {
$verbose = 1;
shift;
} elsif ($ARGV[0] eq '-?') {
print "$usage";
exit;
} else {
#### Pass remaining args to make.
}
}
$make_args = join (' ', @ARGV) . $build_args;
chop ($pwd = `pwd`);
if ($pwd =~ m%/ace$%) {
#### libACE
$COMPONENTS = "$ACE_COMPONENTS";
$LIB_COMPONENTS = 'ACE_COMPONENTS';
$libname = 'ACE';
} elsif ($pwd =~ m%/tao$%) {
$COMPONENTS = "$TAO_COMPONENTS";
$LIB_COMPONENTS = 'TAO_COMPONENTS';
$libname = 'TAO';
} elsif ($pwd =~ m%/orbsvcs/orbsvcs$%) {
$COMPONENTS = "$ORBSVCS_COMPONENTS";
$LIB_COMPONENTS = 'TAO_ORBSVCS';
$libname = 'orbsvcs';
} else {
die "$0: unsupported directory; $pwd\n";
}
$lib = "lib${libname}.$lib_extension";
####
#### 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";
} elsif ($ACE_ROOT =~ /lynx-ppc/) {
$size = '/usr/lynx/3.0.0/ppc/cdk/sunos-xcoff-ppc/bin/size';
} elsif ($ACE_ROOT =~ /lynx/) {
$size = '/usr/lynx/3.0.0/x86/cdk/sunos-coff-x86/bin/size';
} else {
$size = 'size';
}
####
#### Measure the size of the entire library.
####
$sizeTotal = build_lib ("$LIB_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 components 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] if $field[3] =~ /\d/; #### Skip size header line.
}
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);
}
|