1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
6 # Provides size breakdown of ACE, TAO, or orbsvcs libs.
8 # Assumes (or builds) the lib with debug=0. Allows other make args,
9 # such as -j 4, to be passed on the command line.
12 "$0 [-h, for html output] [-s, for shared libs] [-v] [make arguments]\n";
15 #### Configuration parameters.
18 'debug=0 optimize=1 static_libs_only=1';
20 'OS Utils Logging Threads Demux Connection Sockets IPC Svcconf ' .
21 'Streams Memory Token Other';
23 'POA Pluggable_Protocols Default_Resources Interpretive_Marshaling ' .
24 'IDL_Compiler ORB_Core Dynamic_Any';
26 'Naming ImplRepo Time Concurrency Property Trader LifeCycle Sched ' .
27 'Event CosEvent Event2 AV';
30 #### The following are only used for VxWorks libraries, and
31 #### only if the corresponding environment variable isn't set.
32 $default_toolenv = '386';
33 $default_wind_base = '/project/doc/pkg/wind';
34 $default_host_type = 'sun4-solaris2';
36 #### Use gmake if it's on the user's PATH, otherwise use make. Use
37 #### sh -c to avoid warning if gmake isn't found.
39 system ("sh -c \"gmake --version\" > /dev/null 2>&1") ?
'make' : 'gmake';
41 $ACE_ROOT = $ENV{'ACE_ROOT'} ||
42 die "$0: ACE_ROOT was not set!\n";
49 #### Process command line args.
51 while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) {
52 if ($ARGV[0] eq '-h') {
54 chop ($sysname = `uname -s`);
55 chop ($sysrev = `uname -r`);
57 } elsif ($ARGV[0] eq '-s') {
58 $lib_extension = 'so';
59 $build_args =~ s/ static_libs_only=1//;
61 } elsif ($ARGV[0] eq '-v') {
64 } elsif ($ARGV[0] eq '-?') {
68 #### Pass remaining args to make.
72 $make_args = join (' ', @ARGV) . $build_args;
76 if ($pwd =~ m
%/ace
$%) {
78 $COMPONENTS = "$ACE_COMPONENTS";
79 $LIB_COMPONENTS = 'ACE_COMPONENTS';
81 } elsif ($pwd =~ m
%/tao
$%) {
82 $COMPONENTS = "$TAO_COMPONENTS";
83 $LIB_COMPONENTS = 'TAO_COMPONENTS';
85 } elsif ($pwd =~ m
%/orbsvcs/orbsvcs
$%) {
86 $COMPONENTS = "$ORBSVCS_COMPONENTS";
87 $LIB_COMPONENTS = 'TAO_ORBSVCS';
90 die "$0: unsupported directory; $pwd\n";
93 $lib = "lib${libname}.$lib_extension";
97 #### Select the size command based on ACE_ROOT setting.
99 if ($ACE_ROOT =~ /vxworks/) {
100 $TOOLENV = $ENV{'TOOLENV'} || $default_toolenv;
101 $WIND_BASE = $ENV{'WIND_BASE'} || $default_wind_base;
102 $WIND_HOST_TYPE = $ENV{'WIND_HOST_TYPE'} || $default_host_type;
103 $size = "$WIND_BASE/host/$WIND_HOST_TYPE/bin/size$TOOLENV";
104 } elsif ($ACE_ROOT =~ /lynx-ppc/) {
105 $size = '/usr/lynx/3.0.0/ppc/cdk/sunos-xcoff-ppc/bin/size';
106 } elsif ($ACE_ROOT =~ /lynx/) {
107 $size = '/usr/lynx/3.0.0/x86/cdk/sunos-coff-x86/bin/size';
114 #### Measure the size of the entire library.
116 $sizeTotal = build_lib
("$LIB_COMPONENTS=\"$COMPONENTS\"");
117 $components = " <th>Platform\n <th>Component\n <th>Total";
118 $componentSize = " <th>Size, bytes\n <td align=center>$sizeTotal";
119 $componentPercentage =
120 " <th>Percentage of<br>total size\n <td align=center>100";
121 print "Total $sizeTotal (100)\n" unless $html;
125 #### Measure the size of each library component.
127 foreach my $i (split (' ', $COMPONENTS)) {
128 $sizeLib = build_lib
("$LIB_COMPONENTS=\"$i\"");
129 $components .= "\n <th>$i";
130 $componentSize .= "\n <td align=center>$sizeLib";
131 $thisPercentage = percentage
($sizeLib, $sizeTotal);
132 $componentPercentage .= "\n <td align=center>$thisPercentage";
133 print "$i $sizeLib ($thisPercentage)\n" unless $html;
137 #### Produce HTML output, if requested.
140 print '<center><table cellpadding=4 border=4>' . "\n";
141 print ' <tr>' . "\n";
142 print "$echoArgs $components\n";
143 print ' <tr>' . "\n";
144 print " <th rowspan=2>$sysname $sysrev $ACE_ROOT\n";
145 print "$echoArgs $componentSize\n";
146 print ' <tr>' . "\n";
147 print "$echoArgs $componentPercentage\n";
148 print '</table></center><p>' . "\n";
153 #### Build library with components specified in argument.
157 my ($lib_components) = @_;
161 print "$make $make_args $lib_components\n" if $verbose;
163 system ("$make $make_args $lib_components >> make.log 2>&1") &&
164 die "$0: command failed; $make $make_args $lib_components\n";
168 open (SIZE
, "$size $lib |") ||
169 die "$0: unable to open $size\n";
172 $libSize += $field[3] if $field[3] =~ /\d/; #### Skip size header line.
181 #### Return percentage of first argument as fraction of second.
182 #### Returns a string with two-decimal place precision.
186 my ($size, $total) = @_;
188 sprintf ("%.2f", $size * 100 / $total);