Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / msvc_static_compile.pl
blob4957f6de2a8f6df41c26da036b9dd4c82ce5d3df
1 # Win32 auto_compile script.
2 if (!$ENV{ACE_ROOT}) {
3 $ACE_ROOT = getcwd ()."\\";
4 warn "ACE_ROOT not defined, defaulting to ACE_ROOT=$ACE_ROOT";
6 else {
7 $ACE_ROOT = $ENV{ACE_ROOT};
10 use lib "$ENV{ACE_ROOT}/bin";
12 use File::Find;
13 use PerlACE::Run_Test;
14 use Cwd;
16 @directories = ();
18 @ace_dirs = ("$ACE_ROOT\\ace",
19 "$ACE_ROOT\\ACEXML\\common",
20 "$ACE_ROOT\\ACEXML\\parser",
21 "$ACE_ROOT\\ACEXML\\apps",
22 "$ACE_ROOT\\ACEXML\\tests",
23 "$ACE_ROOT\\ACEXML\\examples",
24 "$ACE_ROOT\\apps",
25 "$ACE_ROOT\\ASNMP",
26 "$ACE_ROOT\\examples",
27 "$ACE_ROOT\\netsvcs",
28 "$ACE_ROOT\\performance-tests",
29 "$ACE_ROOT\\protocols",
30 "$ACE_ROOT\\tests",
31 "$ACE_ROOT\\websvcs");
33 $debug = 0;
34 $verbose = 0;
35 $print_status = 0;
36 $Ignore_errors = 0; # By default, bail out if an error occurs.
37 $Build_LIB = 0;
38 $Build_Debug = 0;
39 $Build_Release = 0;
40 $Build_All = 1;
41 $build_core_only = 0;
42 $Build_Cmd = "/BUILD";
43 $use_custom_dir = 0;
44 $useenv = '';
45 $vc7 = 0;
46 $name_mod = '';
47 $mod_name = 0;
48 $proj_ext = '.dsp';
50 # Build
51 sub Build ($$)
53 my ($project, $config) = @_;
55 if ($debug == 1) {
56 print "$project\n";
57 return 0;
59 else {
60 print "Auto_compiling $project : $config\n";
62 print "Building $project $config\n" if $verbose;
64 return system ("msdev.com $project /MAKE \"$config\" $Build_Cmd $useenv");
68 # Build
69 sub Build_VC7 ($$)
71 my ($project, $config) = @_;
73 if ($debug == 1) {
74 print "$project\n";
75 return 0;
77 else {
78 print "Auto_compiling $project : $config\n";
80 print "Building $project $config\n" if $verbose;
82 return system ("devenv.com $project $Build_Cmd $config $useenv");
86 sub Find_Dsw (@)
88 my (@dir) = @_;
89 @array = ();
91 sub wanted_dsw {
92 $array[++$#array] =
93 $File::Find::name if ($File::Find::name =~ /\.dsw$/i);
96 find (\&wanted_dsw, @dir);
98 print "List of dsw's \n" if ($verbose == 1);
99 return @array;
102 sub Find_Sln (@)
104 my (@dir) = @_;
105 @array = ();
107 sub wanted_sln {
108 $array[++$#array] =
109 $File::Find::name if ($File::Find::name =~ /\.sln$/i);
112 find (\&wanted_sln, @dir);
114 print "List of sln's \n" if ($verbose == 1);
115 return @array;
118 sub Rename_Files ($$)
120 my ($target) = shift;
121 my ($newext) = shift;
122 my (@array) = ();
124 sub wanted_file {
125 my ($text) = shift;
126 my ($next) = shift;
127 if ($File::Find::name =~ /^(.*)$text$/i) {
128 my ($newname) = $1 . $next;
129 rename ($File::Find::name, $newname);
133 find (sub { wanted_file ($target, $newext) }, $ACE_ROOT);
136 # Only builds the core libraries.
137 sub Build_Core ()
139 print STDERR "Building Core of ACE/TAO\n" if ($print_status == 1);
140 print "\nmsvc_static_compile: Building Core of ACE/TAO\n";
142 print "Build \n" if ($verbose);
143 print "Debug " if ($verbose) && ($Build_Debug);
144 print "Release " if ($verbose) && ($Build_Release);
145 print "LIB " if ($verbose) && ($Build_LIB);
146 print "\n" if ($verbose);
148 my @core_list = ();
150 if ($Build_LIB) {
151 push (@file_list, "/bin/msvc_static_order.lst");
153 foreach my$test_lst (@file_list) {
154 my $config_list = new PerlACE::ConfigList;
155 $config_list->load ($ACE_ROOT.$test_lst);
157 foreach $test ($config_list->valid_entries ()) {
158 if ($mod_name) {
159 @plist = split (/\//, $test);
160 $fname = pop @plist;
161 $fname_mod = $name_mod;
162 $fname_mod =~ s/\*/$fname/;
163 push @plist,($fname_mod);
164 push (@core_list, join('/', @plist) . $proj_ext);
166 else {
167 push (@core_list, $test . $proj_ext);
173 if ( $vc7 ) {
174 foreach $c (@core_list) {
175 if ($Build_Debug) {
176 $Status = Build_VC7 ($c, "debug");
177 return if $Status != 0 && !$Ignore_errors;
179 if ($Build_Release) {
180 $Status = Build_VC7 ($c, "release");
181 return if $Status != 0 && !$Ignore_errors;
185 else {
186 foreach $c (@core_list) {
187 if ($Build_Debug) {
188 $Status = Build ($c, "ALL - Win32 Debug");
189 return if $Status != 0 && !$Ignore_errors;
191 if ($Build_Release) {
192 $Status = Build ($c, "ALL - Win32 Release");
193 return if $Status != 0 && !$Ignore_errors;
200 sub Build_All ()
202 my @configurations = Find_Dsw (@directories);
204 print STDERR "Building selected projects\n" if ($print_status == 1);
205 print "\nmsvc_static_compile: Building selected projects\n";
207 $count = 0;
208 foreach $c (@configurations) {
209 print STDERR "Configuration ".$count++." of ".$#configurations."\n" if ($print_status == 1);
210 if ($Build_Debug) {
211 $Status = Build ($c, "ALL - Win32 Debug");
212 return if $Status != 0 && !$Ignore_errors;
214 if ($Build_Release) {
215 $Status = Build ($c, "ALL - Win32 Release");
216 return if $Status != 0 && !$Ignore_errors;
221 sub Build_All_VC7 ()
223 my @configurations = Find_Sln (@directories);
225 print STDERR "Building selected projects\n" if ($print_status == 1);
226 print "\nmsvc_static_compile: Building selected projects\n";
228 $count = 0;
229 foreach $c (@configurations) {
230 print STDERR "Configuration ".$count++." of ".$#configurations."\n" if ($print_status == 1);
231 if ($Build_Debug) {
232 $Status = Build_VC7 ($c, "debug");
233 return if $Status != 0 && !$Ignore_errors;
235 if ($Build_Release) {
236 $Status = Build_VC7 ($c, "release");
237 return if $Status != 0 && !$Ignore_errors;
243 ## Parse command line argument
244 while ( $#ARGV >= 0 && $ARGV[0] =~ /^(-|\/)/ )
246 if ($ARGV[0] =~ '-k') { # Ignore errors
247 print "Ignore errors\n" if ( $verbose );
248 $Ignore_errors = 1;
250 elsif ($ARGV[0] =~ /^-d$/i) { # debug
251 $debug = 1;
253 elsif ($ARGV[0] =~ '-vc7') { # Use VC7 project and solution files.
254 print "Using VC7 files\n" if ( $verbose );
255 $vc7 = 1;
256 $proj_ext = '.vcproj';
258 elsif ($ARGV[0] =~ '-vc8') { # Use VC8 project and solution files.
259 print "Using VC8 files\n" if ( $verbose );
260 $vc7 = 1; # VC8 is like VC7
261 $proj_ext = '.vcproj';
263 elsif ($ARGV[0] =~ '-vc9') { # Use VC9 project and solution files.
264 print "Using VC9 files\n" if ( $verbose );
265 $vc7 = 1; # VC9 is like VC7
266 $proj_ext = '.vcproj';
268 elsif ($ARGV[0] =~ '-v') { # verbose mode
269 $verbose = 1;
271 elsif ($ARGV[0] =~ '-name_modifier') { # use MPC name_modifier for project
272 shift;
273 print "Setting name_modifier $ARGV[0]\n" if ( $verbose );
274 $name_mod = $ARGV[0];
275 $mod_name = 1;
277 elsif ($ARGV[0] =~ '-s') { # status messages
278 $print_status = 1;
280 elsif ($ARGV[0] =~ '-u') { # USEENV
281 print "Using Environment\n" if ($verbose);
282 $useenv = '/USEENV';
284 elsif ($ARGV[0] =~ '-CORE') { # Build the core of ace/tao
285 print "Building only Core\n" if ( $verbose );
286 $build_core_only = 1;
288 elsif ($ARGV[0] =~ '-ACE') { # Build ACE and its programs
289 print "Building ACE\n" if ( $verbose );
290 $use_custom_dir = 1;
291 push @directories, @ace_dirs;
293 elsif ($ARGV[0] =~ '-TAO') { # Build TAO and its programs
294 print "Building TAO\n" if ( $verbose );
295 $use_custom_dir = 1;
296 # Other tests depend on the lib in this dir so we need to force it
297 # to the front of the build list. This is pretty ugly.
298 push @directories, ("$ACE_ROOT\\TAO\\orbsvcs\\tests\\Notify\\lib");
299 push @directories, ("$ACE_ROOT\\TAO");
301 elsif ($ARGV[0] =~ '-dir') { # Compile only a specific directory
302 shift;
303 print "Adding directory $ARGV[0]\n" if ( $verbose );
304 $use_custom_dir = 1;
305 push @directories, $ARGV[0];
307 elsif ($ARGV[0] =~ '-rebuild') { # Rebuild all
308 print "Rebuild all\n" if ( $verbose );
309 $Build_Cmd = "/REBUILD";
311 elsif ($ARGV[0] =~ '-clean') { # Clean
312 print "Cleaning all\n" if ( $verbose );
313 $Build_Cmd = "/CLEAN";
315 elsif ($ARGV[0] =~ '-Debug') { # Debug versions
316 print "Building Debug Version\n" if ( $verbose );
317 $Build_Debug = 1;
318 $Build_All = 0;
320 elsif ($ARGV[0] =~ '-Release') { # Release versions
321 print "Building Release Version\n" if ( $verbose );
322 $Build_Release = 1;
323 $Build_All = 0;
325 elsif ($ARGV[0] =~ '-LIB') { # Build LIB only
326 print "Build LIB only\n" if ( $verbose );
327 $Build_LIB = 1;
328 $Build_All = 0;
330 elsif ($ARGV[0] =~ '-(\?|h)') { # Help information
331 print "Options\n";
332 print "-d = Debug (only print out projects)\n";
333 print "-k = Ignore Errors\n";
334 print "-v = Script verbose Mode\n";
335 print "-s = Print status messages to STDERR\n";
336 print "-u = Tell MSVC to use the environment\n";
337 print "-vc7 = Use MSVC 7 toolset\n";
338 print "-vc8 = Use MSVC 8 toolset\n";
339 print "-name_modifier <mod> = Use MPC name_modifier to match projects\n";
340 print "\n";
341 print "-CORE = Build the Core libraries\n";
342 print "-ACE = Build ACE and its programs\n";
343 print "-TAO = Build TAO and its programs\n";
344 print "-dir <dir> = Compile custom directories\n";
345 print "\n";
346 print "-rebuild = Rebuild All\n";
347 print "-clean = Clean\n";
348 print "-Debug = Compile Debug versions\n";
349 print "-Release = Compile Release versions\n";
350 print "-LIB = Comple LIB Configurations\n";
351 exit;
353 else {
354 warn "$0: error unknown option $ARGV[0]\n";
355 die -1;
357 shift;
360 if (!$Build_DLL && !$Build_LIB) {
361 $Build_DLL = 1;
362 $Build_LIB = 1;
365 if (!$Build_Debug && !$Build_Release) {
366 $Build_Debug = 1;
367 $Build_Release = 1;
370 if ($#directories < 0) {
371 @directories = ($ACE_ROOT);
374 print "msvc_static_compile: Begin\n";
375 print STDERR "Beginning Core Build\n" if ($print_status == 1);
376 if (!$use_custom_dir || $build_core_only) {
377 if ($vc7) {
378 ## devenv is too smart for it's own good. When a .vcproj is specified,
379 ## as is done when building the CORE, it will find the solution to which
380 ## the .vcproj belongs and begin to build additional portions of the
381 ## solution. This is not what we want as dependencies are not set up
382 ## between library projects.
383 my($sln) = '.sln';
384 my($core_sln) = $sln . '.build_core';
386 Rename_Files ($sln, $core_sln);
388 foreach my $sig ('INT', 'TERM') {
389 $SIG{$sig} = sub { print STDERR "Renaming solution files, please be patient...\n";
390 Rename_Files ($core_sln, $sln);
391 exit(1); };
394 Build_Core ();
396 Rename_Files ($core_sln, $sln);
398 foreach my $sig ('INT', 'TERM') {
399 $SIG{$sig} = 'DEFAULT';
402 else {
403 Build_Core ();
406 print STDERR "Beginning Full Build\n" if ($print_status == 1);
407 if ( $vc7 ) {
408 Build_All_VC7 if !$build_core_only;
410 else {
411 Build_All if !$build_core_only;
414 print "msvc_static_compile: End\n";
415 print STDERR "End\n" if ($print_status == 1);