Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / bin / generate_doxygen.pl
blobbd4a20556acb2355c3012af146522bb3197061a0
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
8 require POSIX;
9 require File::Path;
11 use Cwd;
12 use File::Spec;
13 use File::Temp qw/ tempfile tempdir /;
14 use Env qw(ACE_ROOT TAO_ROOT DDS_ROOT);
16 # Configuration and default values
18 if (!defined $TAO_ROOT) {
19 $TAO_ROOT = "$ACE_ROOT/TAO";
22 $is_release = 0;
23 $exclude_ace = 0;
24 $exclude_tao = !-r "$TAO_ROOT/VERSION.txt";
25 $verbose = 0;
26 $perl_path = '/usr/bin/perl';
27 $html_output_dir = '.';
28 $footer = '';
30 $dds = 0;
31 if (defined $DDS_ROOT && -r "$DDS_ROOT/VERSION.txt") {
32 $dds_path = Cwd::abs_path($DDS_ROOT);
33 $cwd_path = Cwd::abs_path(getcwd());
34 if ($dds_path eq $cwd_path) {
35 $dds = $exclude_ace = $exclude_tao = 1;
39 @ACE_DOCS = ('ace',
40 'ace_rmcast',
41 'ace_ssl',
42 'ace_qos',
43 'ace_inet',
44 'acexml');
45 @TAO_DOCS = ('tao'
46 ,'tao_anytypecode'
47 ,'tao_portableserver'
48 ,'tao_pi'
49 ,'tao_pi_server'
50 ,'tao_rtportableserver'
51 ,'tao_compression'
52 ,'tao_transportcurrent'
53 ,'tao_rtcorba'
54 ,'tao_dynamicany'
55 ,'tao_dynamicinterface'
56 ,'tao_iormanip'
57 ,'tao_iortable'
58 ,'tao_ziop'
59 ,'tao_esf'
60 ,'tao_rtevent'
61 ,'tao_cosevent'
62 ,'tao_cosnotification'
63 ,'tao_implrepo'
64 ,'tao_strategies'
65 ,'tao_smartproxies'
66 ,'tao_av'
67 ,'tao_security'
68 ,'tao_ssliop'
69 ,'tao_cosnaming'
70 ,'tao_costime'
71 ,'tao_costrader'
72 ,'tao_portablegroup'
73 ,'tao_ifr');
74 @DDS_DOCS = ('dds');
76 # Modify defaults using the command line arguments
77 &parse_args ();
79 $wrote_configh = 0;
80 if (!-r "$ACE_ROOT/ace/config.h") {
81 open(CONFIG_H, ">$ACE_ROOT/ace/config.h")
82 || die "Cannot create config file\n";
83 print CONFIG_H "#include \"ace/config-doxygen.h\"\n";
84 close(CONFIG_H);
85 $wrote_configh = 1;
88 &generate_doxy_files ('ACE', " $ACE_ROOT", " $ACE_ROOT/VERSION.txt", @ACE_DOCS) if (!$exclude_ace);
89 &generate_doxy_files ('TAO', " $TAO_ROOT", " $TAO_ROOT/VERSION.txt", @TAO_DOCS) if (!$exclude_tao);
90 &generate_doxy_files ('DDS', "$DDS_ROOT", " $DDS_ROOT/VERSION.txt", @DDS_DOCS) if $dds;
92 unlink "$ACE_ROOT/ace/config.h" if $wrote_configh;
94 exit 0;
96 sub parse_args {
97 my @ARGS = ();
98 while ($#ARGV >= 0) {
99 if (!($ARGV[0] =~ m/^-/)) {
100 push @ARGS, $ARGV[0];
101 } elsif ($ARGV[0] eq "-is_release") {
102 $is_release = 1;
103 } elsif ($ARGV[0] eq "-exclude_ace") {
104 $exclude_ace = 1;
105 } elsif ($ARGV[0] eq "-exclude_tao") {
106 $exclude_tao = 1;
107 } elsif ($ARGV[0] eq "-include_dds") {
108 $dds = 1;
109 } elsif ($ARGV[0] eq "-verbose") {
110 $verbose = 1;
111 } elsif ($ARGV[0] eq "-perl_path" && $#ARGV >= 1) {
112 $perl_path = $ARGV[1];
113 shift;
114 } elsif ($ARGV[0] eq "-footer" && $#ARGV >= 1) {
115 $footer = $ARGV[1];
116 shift;
117 } elsif ($ARGV[0] eq "-html_output" && $#ARGV >= 1) {
118 $html_output_dir = $ARGV[1];
119 shift;
120 } else {
121 print "Ignoring option $ARGV[0]\n";
123 shift @ARGV;
125 @ARGV = @ARGS;
128 #is $arg1 the same path as "$arg2/$arg3"?
129 sub same_dir {
130 my $lhs = shift;
131 my $rhs_base = shift;
132 my $rhs_dir = shift;
133 my $rhs = File::Spec->catdir($rhs_base, $rhs_dir);
134 return File::Spec->canonpath($lhs) eq File::Spec->canonpath($rhs);
137 sub generate_doxy_files {
139 my $KIT = shift;
140 my $ROOT_DIR = shift;
141 my $VERSION_FILE= shift;
142 my @DOCS = @_;
144 my $VERSION = 'Snapshot ('.
145 POSIX::strftime("%Y/%m/%d-%H:%M", localtime)
146 .')';
148 my $KIT_path = $KIT;
149 my $translate_paths =
150 ($KIT eq 'TAO' && !same_dir($TAO_ROOT, $ACE_ROOT, 'TAO'));
152 foreach my $i (@DOCS) {
153 if ($is_release) {
154 my ($major, $minor, $beta) = &get_versions ($KIT, $VERSION_FILE);
155 $VERSION = $major.'.'.$minor.'.'.$beta;
158 my $input = "$ROOT_DIR/etc/".$i.".doxygen";
159 ($fh, $output) = tempfile(TEMPLATE => 'XXXXXXXX', SUFFIX => '.doxygen', TMPDIR => 1, DESTROY => 1);
161 open(DOXYINPUT, $input)
162 || die "Cannot open doxygen input file $input\n";
163 open(DOXYOUTPUT, ">$output")
164 || die "Cannot open doxygen output file $output\n";
166 my $generate_man = 0;
167 my $generate_html = 0;
168 my @output_dirs = ();
169 while (<DOXYINPUT>) {
170 chomp;
171 if (/^PROJECT_NUMBER/) {
172 print DOXYOUTPUT "PROJECT_NUMBER = ", $VERSION, "\n";
173 next;
174 } elsif (/^PERL_PATH /) {
175 print DOXYOUTPUT "PERL_PATH = $perl_path\n";
176 next;
177 } elsif (/^QUIET / && $verbose) {
178 print DOXYOUTPUT "QUIET = NO\n";
179 next;
180 } elsif (/^INLINE_SOURCES/ && $is_release) {
181 print DOXYOUTPUT "INLINE_SOURCES = NO\n";
182 next;
183 } elsif (/^SOURCE_BROWSER/ && $is_release) {
184 print DOXYOUTPUT "SOURCE_BROWSER = NO\n";
185 next;
186 } elsif (/^VERBATIM_HEADERS/ && $is_release) {
187 print DOXYOUTPUT "VERBATIM_HEADERS = NO\n";
188 next;
189 } elsif (/^GENERATE_MAN/ && /= YES/) {
190 $generate_man = 1;
191 } elsif (/^GENERATE_HTML/ && /= YES/) {
192 $generate_html = 1;
193 } elsif ($generate_html && /^HTML_OUTPUT/) {
194 my @field = split(' = ');
195 if ($#field >= 1) {
196 my $html_out_dir = "$html_output_dir/$field[1]";
197 push @output_dirs, $html_out_dir;
198 print DOXYOUTPUT "HTML_OUTPUT = $html_out_dir\n";
199 next;
201 } elsif ($generate_html && /^GENERATE_TAGFILE/) {
202 my @field = split(' = ');
203 if ($#field >= 1) {
204 my $html_out_dir = "$html_output_dir/$field[1]";
205 print DOXYOUTPUT "GENERATE_TAGFILE = $html_out_dir\n";
206 next;
208 } elsif ($generate_html && /^TAGFILES\s*=\s*(.*)$/) {
209 my $value = $1;
210 while ($value =~ /\\$/) {
211 chop $value; #removes trailing \
212 my $line = <DOXYINPUT>;
213 chomp $line;
214 $value .= ' ' . $line;
216 my @values = split(' ', $value);
217 print DOXYOUTPUT "HTML_FOOTER = $footer\n";
218 map {$_ = $html_output_dir . '/' . $_; } @values;
219 print DOXYOUTPUT 'TAGFILES = ' . join(' ', @values) . "\n";
220 next;
221 } elsif ($generate_man && /^MAN_OUTPUT/) {
222 my @field = split(' = ');
223 if ($#field >= 1) {
224 push @output_dirs, $field[1];
226 } elsif ($translate_paths && /^(INPUT|INCLUDE_PATH)\s*=\s*(.*)$/) {
227 my $keyword = $1;
228 my $value = $2;
229 while ($value =~ /\\$/) {
230 chop $value; #removes trailing \
231 my $line = <DOXYINPUT>;
232 chomp $line;
233 $value .= ' ' . $line;
235 $value =~ s/$KIT_path/${"${KIT}_ROOT"}/g;
236 print DOXYOUTPUT "$keyword = $value\n";
237 next;
240 print DOXYOUTPUT $_, "\n";
242 close (DOXYOUTPUT);
243 close (DOXYINPUT);
245 foreach my $i (@output_dirs) {
246 File::Path::mkpath($i, 0, 0755);
249 &run_doxy ($output);
251 unlink $output;
254 if ($generate_man) {
255 open(FIND, "find man -type f -print |") or die "Can't run find\n";
256 while (<FIND>) {
257 chomp;
258 my $name_with_whitespace = $_;
259 next unless ($name_with_whitespace =~ /\s/);
260 my $name_without_whitespace = $name_with_whitespace;
261 $name_without_whitespace =~ s/\s+//g;
262 rename $name_with_whitespace, $name_without_whitespace;
264 close FIND;
268 sub run_doxy {
269 my $config = shift;
270 open(DOX,"doxygen $config 2>&1 |")
271 || die "cannot start ACE doxygen process\n";
272 while (<DOX>) {
273 print $_;
275 close (DOX)
276 || die "error while running doxygen on $config\n";
279 ########
280 ######## Retrieve version information from VERSION file(s).
281 ########
282 sub get_versions () {
283 my $KIT = shift;
284 my $VERSION_FILE = shift;
285 my ($major_version, $minor_version, $micro_version);
287 open (VERSION, '<'.$VERSION_FILE) ||
288 die "$0: unable to open $VERSION_FILE\n";
289 while (<VERSION>) {
290 chomp;
291 if (/$KIT version (\d+)\.(\d+)\.(\d+)/) {
292 $major_version = $1;
293 $minor_version = $2;
294 $micro_version = $3;
295 last;
296 } elsif (/$KIT version (\d+)\.(\d+)[^\.]/) {
297 #### Previous release was a minor.
298 $major_version = $1;
299 $minor_version = $2;
300 $micro_version = '0';
301 last;
302 } elsif (/$KIT version (\d+)[^\.]/) {
303 #### Previous release was a major.
304 $major_version = $1;
305 $minor_version = '0';
306 $micro_version = '0';
307 last;
310 close VERSION;
312 return ($major_version, $minor_version, $micro_version);