5 $ACE_ROOT = getcwd
()."\\";
6 print STDERR
"Error: ACE_ROOT not defined\n";
10 $ACE_ROOT = $ENV{ACE_ROOT
};
13 use lib
"$ACE_ROOT/bin";
14 use PerlACE
::MSProject
::DSP
;
15 use PerlACE
::MSProject
::VCP
;
16 use File
::DosGlob
'glob';
20 ################################################################################
35 ################################################################################
37 # Parse command line arguments
41 if ($ARGV[0] =~ m/^-list/i) {
44 elsif ($ARGV[0] =~ m/^-evc3/i) {
47 elsif ($ARGV[0] =~ m/^-msvc7/i) {
48 $extension = "vcproj";
50 elsif ($ARGV[0] =~ m/^-config/i) {
51 push @configs, $ARGV[1];
54 elsif ($ARGV[0] =~ m/^-r/i) {
57 elsif ($ARGV[0] =~ m/^-v/i) {
60 elsif ($ARGV[0] =~ m/^-auto_compile/i) {
63 elsif ($ARGV[0] =~ m/^-clean/i) {
66 elsif ($ARGV[0] =~ m/^-useroot/i) {
67 push @roots, $ARGV[1];
70 elsif ($ARGV[0] =~ m/^-aceroot/i) {
73 elsif ($ARGV[0] =~ m/^-(\?|h)/i) { # Help information
75 print "-list - Prints out the list of project files\n";
76 print "-config <c> - Use <c> as a configuration\n";
77 print "-evc3 - Looks for eMbedded Visual C++ 3.0 projects\n";
78 print "-msvc7 - Looks for Visual C++ 7.0 projects\n";
79 print "-clean - Clean instead of building\n";
80 print "-recurse - Recurse into directories\n";
81 print "-verbose - Make some noise\n";
82 print "-auto_compile - Print out auto_compile info during build\n";
83 print "-useroot <dir> - Use <dir> as a root to look for dependencies\n";
84 print "-aceroot - Use %ACE_ROOT% as a dependency root\n";
87 elsif ($ARGV[0] =~ m/^-/) {
88 warn "$0: unknown option $ARGV[0]\n";
92 push @arguments, $ARGV[0];
98 if (defined $ENV{WINMAKE_CONFIGS
}) {
99 @configs = split /:/, $ENV{WINMAKE_CONFIGS
};
101 elsif (defined $ENV{PIPPEN_CONFIGS
}) {
102 @configs = split /:/, $ENV{PIPPEN_CONFIGS
};
105 print STDERR
"Error: No config specified\n";
110 if (!defined $extension) {
112 if (defined $ENV{WINMAKE_COMPILER
}) {
113 $compiler = $ENV{WINMAKE_COMPILER
};
115 elsif (defined $ENV{PIPPEN_COMPILER
}) {
116 $compiler = $ENV{PIPPEN_COMPILER
};
119 print STDERR
"Error: No compiler specified\n";
123 if ($compiler eq "evc3") {
126 elsif ($compiler eq "msvc7") {
127 $extension = "vcproj";
131 ################################################################################
133 # I like these variables
135 # %projects->{$file}->{BUILD} <- Are we supposed to build this file?
136 # ->{PROJ} <- MSProject object
137 # ->{CONFIGS}->{$config}->{DEPS} <- List of dependencies
138 # ->{DONE} <- Have we compiled it yet?
142 # %names->{$output} <- points to the $file used in the above %projects
146 ################################################################################
148 # Expand all the files/directories passed in on the command line
150 sub ProjectSearch
($@
)
155 while ($#targets >= 0) {
156 my $target = $targets[0];
158 print " Reading Directory $target\n" if ($verbose);
160 my $dh = new DirHandle
($target);
163 foreach my $entry ($dh->read ()) {
164 if (-d
"$target/$entry" && $entry ne "." && $entry ne "..") {
165 $entry =~ s/^.\\//; # / <- fix for color coding in devenv
166 push @targets, ($target . "\\". $entry);
171 print STDERR
"Error: Cannot read $target: $!\n";
175 foreach my $t (glob ($target . "\\*." . $extension)) {
176 print " Adding project $t\n" if ($verbose);
177 %projects->{$t}->{BUILD
} = $build;
181 foreach my $t (glob ($target)) {
182 print " Adding project $t\n" if ($verbose);
183 %projects->{$t}->{BUILD
} = $build;
190 print "=== Expanding Command line Arguments\n" if ($verbose);
192 if ($#arguments < 0) {
193 print " No files specified, defaulting to \".\"\n" if ($verbose);
194 push @arguments, (".");
197 ProjectSearch
(1, @arguments);
199 print "=== Expanding Root Arguments\n" if ($verbose);
201 ProjectSearch
(0, @roots);
204 my $oldrecurse = $recurse;
206 my @aceroots = ($ENV{ACE_ROOT
}."\\ace",
207 $ENV{ACE_ROOT
}."\\apps\\gperf\\src",
208 $ENV{ACE_ROOT
}."\\TAO\\TAO_IDL",
209 $ENV{ACE_ROOT
}."\\TAO\\tao",
210 $ENV{ACE_ROOT
}."\\TAO\\orbsvcs\\orbsvcs");
211 ProjectSearch
(0, @aceroots);
212 $recurse = $oldrecurse;
215 ################################################################################
217 # Read each project file to gather dependency and output information
219 print "=== Reading Project Files\n" if ($verbose);
221 foreach my $project (keys %projects) {
224 if ($project =~ m/\.dsp$/i) {
225 $proj = new PerlACE
::MSProject
::DSP
($project);
227 elsif ($project =~ m/\.vcp$/i) {
228 $proj = new PerlACE
::MSProject
::VCP
($project);
230 elsif ($project =~ m/\.vcproj$/i) {
231 print STDERR
"Error: MSVC7 not supported yet\n";
234 print STDERR
"Error: Unrecognized file: $project\n";
237 print " Loading $project:" if ($verbose);
241 foreach my $config (@configs) {
242 foreach my $proj_config ($proj->Configs ()) {
243 if ($proj_config =~ m/\Q$config\E/i) {
244 print " \"$proj_config\"" if ($verbose);
245 my $name = $proj->DepOutputFile ($proj_config);
247 %names->{lc $name} = $project;
248 my @deps = split / /, $proj->Libs ($proj_config);
250 foreach my $dep (@deps) {
251 # $dep =~ s/.*[\/\\]//g;
252 push (@
{%projects->{$project}->{CONFIGS
}->{$proj_config}->{DEPS
}}, $dep);
254 if ($proj->UsesTAOIDL () == 1) {
255 push @
{%projects->{$project}->{CONFIGS
}->{$proj_config}->{DEPS
}}, ("gperf.exe", "tao_idl.exe");
261 print "\n" if ($verbose);
263 %projects->{$project}->{PROJ
} = $proj;
266 ################################################################################
268 # Clean out the dependency lists, we only keep the libraries which we know
271 print "=== Cleaning out Dependency Lists\n" if ($verbose);
273 foreach my $project (keys %projects) {
274 foreach my $config (keys %{%projects->{$project}->{CONFIGS
}}) {
275 print " Cleaning Dependencies: $project ($config)\n" if ($verbose);
276 print " Before:", join (" ", @
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}}), "\n" if ($verbose);
278 foreach my $dep (@
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}}) {
279 $dep =~ s/.*[\/\\]//g
;
281 if (defined %names->{lc $dep}) {
285 print " After:", join (" ", @newdeps), "\n" if ($verbose);
286 @
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}} = @newdeps;
290 ################################################################################
292 # Make sure to build any dependencies found
294 print "=== Walking Dependency Lists\n" if ($verbose);
300 foreach my $project (keys %projects) {
301 foreach my $config (keys %{%projects->{$project}->{CONFIGS
}}) {
302 if (%projects->{$project}->{BUILD
} == 1) {
303 foreach my $dep (@
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}}) {
304 if (%projects->{%names->{lc $dep}}->{BUILD
} != 1) {
305 %projects->{%names->{lc $dep}}->{BUILD
} = 1;
313 } while (!$finished);
316 ################################################################################
318 # Output a list, if requested
321 print "List of Dependencies\n";
322 print "--------------------\n";
323 foreach my $project (keys %projects) {
324 print "=== $project\n";
325 foreach my $config (keys %{%projects->{$project}->{CONFIGS
}}) {
326 print " Config: $config\n";
327 print " Depends: ", join (" ", @
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}}), "\n";
332 print "List of Outputs\n";
333 print "---------------\n";
335 foreach my $name (keys %names) {
340 ################################################################################
344 print "=== Compiling\n" if ($verbose);
346 my $compilations; # Keep track of the number of compiles done during a pass
354 foreach my $project (keys %projects) {
355 if (%projects->{$project}->{BUILD
} == 1) {
356 foreach my $config (keys %{%projects->{$project}->{CONFIGS
}}) {
357 if (%projects->{$project}->{CONFIGS
}->{$config}->{DONE
} != 1) {
359 foreach my $dep (@
{%projects->{$project}->{CONFIGS
}->{$config}->{DEPS
}}) {
360 if (%projects->{%names->{lc $dep}}->{CONFIGS
}->{$config}->{DONE
} != 1) {
365 if ($depsleft == 0) {
367 print "Auto_compiling $project : $config\n" if ($auto_compile);
377 print "$project : $config\n";
379 elsif ($clean == 1) {
380 %projects->{$project}->{PROJ
}->Clean ($config);
383 %projects->{$project}->{PROJ
}->Build ($config);
386 %projects->{$project}->{CONFIGS
}->{$config}->{DONE
} = 1;
396 print " === Loop $loop: $compilations compiles, $unfinished left\n" if ($verbose);
398 } while ($compilations != 0);
400 # Loop through and see if anything wasn't compiled. If so, this means either there is
401 # an error in the script or that there are circular dependencies
403 foreach my $project (keys %projects) {
404 if (%projects->{$project}->{BUILD
} == 1) {
405 foreach my $config (keys %{%projects->{$project}->{CONFIGS
}}) {
406 if (%projects->{$project}->{CONFIGS
}->{$config}->{DONE
} != 1) {
407 print STDERR
"Error: Project not compiled: $project - $config\n",