1 # Patch updates build.pl to revision 1.93 which allows parallel builds to occur
3 --- oo_1.1_src/solenv/bin/build.pl.fix-parallel-build 2003-06-24 07:31:50.000000000 -0400
4 +++ oo_1.1_src/solenv/bin/build.pl 2003-10-24 09:42:46.000000000 -0400
7 -eval 'exec perl -S $0 ${1+"$@"}'
10 + eval 'exec perl -S $0 ${1+"$@"}'
12 #*************************************************************************
19 -# last change: $Author$ $Date$
20 +# last change: $Author$ $Date$
22 # The Contents of this file are made available subject to the terms of
23 # either of the following licenses
25 # build - build entire project
36 #use Thread 'yield'; # Should be uncommented if you have Thread.pm (untested)
38 -if (defined $ENV{CWS_WORK_STAMP}) {
39 - require lib; import lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
40 - require Cws; import Cws;
41 - require CvsModule; import CvsModule;
42 - require GenInfoParser; import GenInfoParser;
45 + if (defined $ENV{CWS_WORK_STAMP}) {
46 + require lib; import lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
47 + require Cws; import Cws;
48 + require CvsModule; import CvsModule;
49 + require GenInfoParser; import GenInfoParser;
54 -( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
55 + ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
57 -$id_str = ' $Revision$ ';
58 -$id_str =~ /Revision:\s+(\S+)\s+\$/
59 - ? ($script_rev = $1) : ($script_rev = "-");
60 + $id_str = ' $Revision$ ';
61 + $id_str =~ /Revision:\s+(\S+)\s+\$/
62 + ? ($script_rev = $1) : ($script_rev = "-");
64 -print "$script_name -- version: $script_rev\n";
65 + print "$script_name -- version: $script_rev\n";
67 #########################
71 #########################
74 -$remove_commando = "";
75 -if ( $^O eq 'MSWin32' ) {
76 - $perl = "$ENV{COMSPEC} -c perl5";
77 - $remove_commando = "rmdir /S /Q";
82 - $remove_commando = 'rm -rf';
83 - $nul = '> /dev/null';
86 + $remove_commando = "";
87 + if ( $^O eq 'MSWin32' ) {
88 + $perl = "$ENV{COMSPEC} -c perl5";
89 + $remove_commando = "rmdir /S /Q";
94 + $remove_commando = 'rm -rf';
95 + $nul = '> /dev/null';
98 -$QuantityToBuild = 0;
99 + $QuantityToBuild = 0;
100 # delete $pid when not needed
101 -%projects_deps_hash = (); # hash of undependent projects,
102 - # that could be built now
103 -%broken_build = (); # hash of hashes of the modules,
104 - # where build was broken (error occurred)
105 -%folders_hashes = ();
106 -%running_children = ();
107 -$dependencies_hash = 0;
110 -$BuildAllParents = 0;
113 -%LocalDepsHash = ();
117 -%AliveDependencies = ();
118 -%ParentDepsHash = (); # hash of dependencies of the current project
119 -@UnresolvedParents = ();
124 -$only_dependent = 0;
126 -$build_from_opt = '';
130 -%processes_hash = ();
131 -%module_annonced = ();
132 -$locked = 0; # lock for signal handler
133 -$prepare = ''; # prepare for following incompartible build
135 -@ignored_errors = ();
136 -%incompartibles = ();
137 -%force_deliver = ();
142 - %platforms = &get_platforms;
143 - @modules_built = ();
145 - $deliver_env{'BUILD_SOSL'}++;
146 - $deliver_env{'COMMON_OUTDIR'}++;
147 - $deliver_env{'DLLSUFFIX'}++;
148 - $deliver_env{'GUI'}++;
149 - $deliver_env{'INPATH'}++;
150 - $deliver_env{'OFFENV_PATH'}++;
151 - $deliver_env{'OUTPATH'}++;
152 - $deliver_env{'L10N_framework'}++;
155 -$StandDir = &get_stand_dir();
156 -&provide_consistency if (defined $ENV{CWS_WORK_STAMP});
158 -$deliver_commando = $ENV{DELIVER};
159 -$deliver_commando .= ' '. $dlv_switch if ($dlv_switch);
162 -$check_error_string = '';
166 + %projects_deps_hash = (); # hash of undependent projects,
167 + # that could be built now
168 + %broken_build = (); # hash of hashes of the modules,
169 + # where build was broken (error occurred)
170 + %folders_hashes = ();
171 + %running_children = ();
172 + $dependencies_hash = 0;
174 + $BuildAllParents = 0;
177 + %LocalDepsHash = ();
180 + %PlatformHash = ();
181 + %AliveDependencies = ();
182 + %global_deps_hash = (); # hash of dependencies of the all modules
183 + %broken_modules_hashes = (); # hash of modules hashes, which cannot be built further
184 + @broken_modules_names = (); # array of modules, which cannot be built further
185 + @UnresolvedParents = ();
190 + $only_dependent = 0;
192 + $build_from_opt = '';
196 + %processes_hash = ();
197 + %module_annonced = ();
198 + $prepare = ''; # prepare for following incompartible build
200 + @ignored_errors = ();
201 + %incompartibles = ();
202 + %force_deliver = ();
203 + $only_platform = ''; # the only platform to prepare
204 + $only_common = ''; # the only common output tree to delete when preparing
206 + $maximal_processes = 0; # the max number of the processes run
214 + %platforms = &get_platforms;
215 + @modules_built = ();
217 + $deliver_env{'BUILD_SOSL'}++;
218 + $deliver_env{'COMMON_OUTDIR'}++;
219 + $deliver_env{'DLLSUFFIX'}++;
220 + $deliver_env{'GUI'}++;
221 + $deliver_env{'INPATH'}++;
222 + $deliver_env{'OFFENV_PATH'}++;
223 + $deliver_env{'OUTPATH'}++;
224 + $deliver_env{'L10N_framework'}++;
227 + $StandDir = &get_stand_dir();
228 + &provide_consistency if (defined $ENV{CWS_WORK_STAMP});
230 + $deliver_commando = $ENV{DELIVER};
231 + $deliver_commando .= ' '. $dlv_switch if ($dlv_switch);
233 + %prj_platform = ();
234 + $check_error_string = '';
243 - if (open (CMD_FILE, ">>$cmd_file")) {
246 - $new_line = $echo."\"\"\n";
247 - print "\@$echo off\npushd\n" if ($ENV{GUI} ne 'UNX');
249 - &print_error ("Cannot open file $cmd_file");
255 + unlink ($cmd_file);
257 + if (open (CMD_FILE, ">>$cmd_file")) {
260 + $new_line = $echo."\"\"\n";
261 + print "\@$echo off\npushd\n" if ($ENV{GUI} ne 'UNX');
263 + &print_error ("Cannot open file $cmd_file");
273 -&cancel_build if (scalar keys %broken_build);
274 -@TotenEltern = keys %DeadParents;
275 -if ($#TotenEltern != -1) {
277 - print $new_line.$new_line;
278 - print $echo."WARNING! Project(s):\n";
279 - foreach $DeadPrj (@TotenEltern) {
280 - print $echo."$DeadPrj\n";
283 - print $echo."not found and couldn't be built. Correct build.lsts.\n";
286 -if (($ENV{GUI} ne 'UNX') && $cmd_file) {
292 - print STDOUT "Script $cmd_file generated\n";
294 -exit(0) if (!$ignore);
295 -exit(0) if (!scalar @ignored_errors);
296 -print STDERR "\nERROR: next directories could not be built:\n";
297 -foreach (@ignored_errors) {
298 - print STDERR "\t$_\n";
300 -print STDERR "\nERROR: please check these directories and build the correspondent module(s) anew!!\n\n";
303 + &cancel_build if (scalar keys %broken_build);
304 + @TotenEltern = keys %DeadParents;
305 + if ($#TotenEltern != -1) {
307 + print $new_line.$new_line;
308 + print $echo."WARNING! Project(s):\n";
309 + foreach $DeadPrj (@TotenEltern) {
310 + print $echo."$DeadPrj\n";
313 + print $echo."not found and couldn't be built. Correct build.lsts.\n";
316 + if (($ENV{GUI} ne 'UNX') && $cmd_file) {
322 + print STDOUT "Script $cmd_file generated\n";
324 + exit(0) if (!$ignore);
325 + exit(0) if (!scalar @ignored_errors);
326 + print STDERR "\nERROR: next directories could not be built:\n";
327 + foreach (@ignored_errors) {
328 + print STDERR "\t$_\n";
330 + print STDERR "\nERROR: please check these directories and build the correspondent module(s) anew!!\n\n";
334 #########################
335 @@ -236,73 +243,73 @@
337 # Get dependencies hash of the current and all parent projects
340 - my ($ParentsString, @DepsArray, $Prj, $parent, $prj_link);
341 - my $prj_dir = shift;
342 - my $deps_hash = shift;
343 - $ParentsString = &GetParentsString($prj_dir);
344 - @DepsArray = &GetDependenciesArray($ParentsString);
345 - @UnresolvedParents = @DepsArray;
346 - $$deps_hash{$prj_dir} = [@DepsArray];
347 - while ($Prj = pop(@UnresolvedParents)) {
348 - $prj_link = $Prj . '.lnk';
349 - if (!-d $StandDir.$Prj) {
350 - if (-e $StandDir.$prj_link) {
352 - } elsif (-l $StandDir.$prj_link) {
353 - &print_error("There is no target for link $StandDir$prj_link");
354 + sub GetParentDeps {
355 + my ($ParentsString, @DepsArray, $Prj, $parent, $prj_link);
356 + my $prj_dir = shift;
357 + my $deps_hash = shift;
358 + $ParentsString = &GetParentsString($prj_dir);
359 + @DepsArray = &GetDependenciesArray($ParentsString);
360 + @UnresolvedParents = @DepsArray;
361 + $$deps_hash{$prj_dir} = [@DepsArray];
362 + while ($Prj = pop(@UnresolvedParents)) {
363 + $prj_link = $Prj . '.lnk';
364 + if (!-d $StandDir.$Prj) {
365 + if (-e $StandDir.$prj_link) {
367 + } elsif (-l $StandDir.$prj_link) {
368 + &print_error("There is no target for link $StandDir$prj_link");
369 + } elsif (defined $ENV{CWS_WORK_STAMP}) {
370 + &checkout_module($Prj, 'image');
372 } elsif (defined $ENV{CWS_WORK_STAMP}) {
373 - &checkout_module($Prj, 'image');
374 + &check_module_consistency($Prj);
376 - } elsif (defined $ENV{CWS_WORK_STAMP}) {
377 - &check_module_consistency($Prj);
380 - if (!($ParentsString = &GetParentsString($StandDir.$Prj))) {
381 - $DeadParents{$Prj}++;
382 - $$deps_hash{$Prj} = [];
385 - @DepsArray = &GetDependenciesArray($ParentsString, $Prj);
386 - $$deps_hash{$Prj} = [@DepsArray];
387 - foreach $Parent (@DepsArray) {
388 - if ((!defined($$deps_hash{$Parent})) && (!defined($$deps_hash{$Parent . '.lnk'}))) {
389 - push (@UnresolvedParents, $Parent);
393 - foreach $parent (keys %DeadParents) {
394 - delete $ParentDepsHash{$parent};
395 - &RemoveFromDependencies($parent, $deps_hash);
399 + if (!($ParentsString = &GetParentsString($StandDir.$Prj))) {
400 + $DeadParents{$Prj}++;
401 + $$deps_hash{$Prj} = [];
404 + @DepsArray = &GetDependenciesArray($ParentsString, $Prj);
405 + $$deps_hash{$Prj} = [@DepsArray];
406 + foreach $Parent (@DepsArray) {
407 + if ((!defined($$deps_hash{$Parent})) && (!defined($$deps_hash{$Parent . '.lnk'}))) {
408 + push (@UnresolvedParents, $Parent);
412 + foreach $parent (keys %DeadParents) {
413 + delete $global_deps_hash{$parent};
414 + &RemoveFromDependencies($parent, $deps_hash);
419 # Build everything that should be built
422 - if ($BuildAllParents) {
423 - my ($Prj, $PrjDir, $orig_prj);
424 - &GetParentDeps( $CurrentPrj, \%ParentDepsHash);
425 - &prepare_build_from(\%ParentDepsHash) if ($build_from);
426 - &prepare_incompartible_build(\%ParentDepsHash) if ($incompartible);
427 - if ($build_from_opt || $build_since) {
428 - &prepare_build_from_opt(\%ParentDepsHash);
430 - if ($QuantityToBuild) {
431 - &build_multiprocessing;
434 - while ($Prj = &PickPrjToBuild(\%ParentDepsHash)) {
436 - my $module_type = &module_classify($Prj);
438 - &print_annonce($Prj) if ($module_type eq 'lnk');
440 + if ($BuildAllParents) {
441 + my ($Prj, $PrjDir, $orig_prj);
442 + &GetParentDeps( $CurrentPrj, \%global_deps_hash);
443 + &prepare_build_from(\%global_deps_hash) if ($build_from);
444 + &prepare_incompartible_build(\%global_deps_hash) if ($incompartible);
445 + if ($build_from_opt || $build_since) {
446 + &prepare_build_from_opt(\%global_deps_hash);
448 + if ($QuantityToBuild) {
449 + &build_multiprocessing;
452 + while ($Prj = &PickPrjToBuild(\%global_deps_hash)) {
454 + my $module_type = &module_classify($Prj);
456 + &print_annonce($Prj) if ($module_type eq 'lnk');
457 &print_annonce($Prj . '.incomp') if ($module_type eq 'img');
458 if ($module_type eq 'mod') {
459 if (scalar keys %broken_build) {
460 print $echo. "Skipping project $Prj because of error(s)\n";
461 - &RemoveFromDependencies($Prj, \%ParentDepsHash);
462 + &RemoveFromDependencies($Prj, \%global_deps_hash);
465 &print_annonce($Prj);
468 print $check_error_string;
470 - &RemoveFromDependencies($Prj, \%ParentDepsHash);
471 + &RemoveFromDependencies($Prj, \%global_deps_hash);
475 @@ -367,26 +374,19 @@
476 if (!$cmd_file && !$show) {
479 - $error_code = system ("$dmake") if (!scalar keys %broken_build);
480 + $error_code = system ("$dmake");
481 if ($error_code && $ignore) {
482 push(@ignored_errors, &CorrectPath($StandDir . $PathHash{$folder_nick}));
485 - if ($error_code && ($error_code != -1)) {
487 - if ($incompartible) {
488 - $broken_build{$error_code} = &CorrectPath($StandDir . $PathHash{$folder_nick});
490 - &print_error("Error $? occurred while making $BuildDir");
496 my $oldfh = select STDERR;
498 _exit($? >> 8) if ($? && ($? != -1));
500 + } elsif ($error_code && ($error_code != -1)) {
501 + &print_error("Error $? occurred while making $BuildDir");
507 if ($_ =~ /\:+\s+/) {
510 + return &pick_for_build_type($');
515 open (BUILD_LST, 'prj/build.lst');
517 while (<BUILD_LST>) {
523 @@ -468,19 +468,19 @@
527 - if ($_ =~ /nmake/) {
528 + if ($_ =~ /nmake/o) {
529 my ($Platform, $Dependencies, $Dir, $DirAlias, @Array);
532 - $dummy =~ /(\S+)\s+(\S+)/;
533 + $dummy =~ /(\S+)\s+(\S+)/o;
535 - $Dependencies =~ /(\w+)/;
536 + $Dependencies =~ /(\w+)/o;
539 - while ($Dependencies =~ /,(\w+)/) {
540 + while ($Dependencies =~ /,(\w+)/o) {
543 - $Dependencies =~ /\s+(\S+)\s+/;
544 + $Dependencies =~ /\s+(\S+)\s+/o;
546 if (!&CheckPlatform($Platform)) {
547 $DeadDependencies{$DirAlias}++;
550 $PlatformHash{$DirAlias}++;
552 + &print_error("$PrjToBuild/prj/build.lst has wrong written dependencies string:\n$_\n") if (!$Dependencies);
553 @Array = &GetDependenciesArray($Dependencies);
554 $$dependencies_hash{$DirAlias} = [@Array];
555 $BuildQueue{$DirAlias}++;
558 my ($Prj, $DepsHash);
560 + &handle_dead_children if ($QuantityToBuild);
561 $Prj = &FindIndepPrj($DepsHash);
562 - delete $$DepsHash{$Prj};# if (defined $$DepsHash{$Prj});
563 + delete $$DepsHash{$Prj};
567 @@ -672,12 +674,12 @@
568 return $Prj if ($#PrjDeps == -1);
570 # If there are only dependent projects in hash - generate error
571 - return '' if ($BuildAllParents);
572 + return '' if ($BuildAllParents && !$children);
577 - print STDERR "\nError: projects";
578 + print STDERR "\nFatal error:";
579 foreach $Prj (keys %$Dependencies) {
580 if (&IsHashNative($Prj)) {
582 @@ -713,12 +715,12 @@
584 $string = $DepString;
586 - while (!($DepString =~ /^NULL/)) {
587 + while ($DepString !~ /^NULL/o) {
588 &print_error("Project $prj has wrong written dependencies string:\n $string") if (!$DepString);
589 - $DepString =~ /(\S+)\s*/;
590 + $DepString =~ /(\S+)\s*/o;
593 - if ($ParentPrj =~ /\.(\w+)$/) {
594 + if ($ParentPrj =~ /\.(\w+)$/o) {
596 if (($prj_platform{$ParentPrj} ne $1) &&
597 ($prj_platform{$ParentPrj} ne 'all')) {
598 @@ -761,14 +763,15 @@
601 print STDERR "\nbuild\n";
602 - print STDERR "Syntax: build [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2]|[--since|-c prj_name] [--with_branches|-b]|[--prepare|-p]] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [-- dmake_options] \n";
603 + print STDERR "Syntax: build [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2] [prj_name3 [...]]]|[--since|-c prj_name] [--with_branches|-b]|[--prepare|-p][:platform]] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [--mode|-m OOo[,SO[,EXT]] [-- dmake_options] \n";
604 print STDERR "Example: build --from sfx2\n";
605 print STDERR " - build projects including current one from sfx2\n";
606 print STDERR "Example: build --all:sfx2\n";
607 print STDERR " - the same as --all, but skip all projects that have been already built when using \"--all\" switch before sfx2\n";
608 print STDERR "Keys: --all - build all projects from very beginning till current one\n";
609 print STDERR " --from - build all projects dependent from the specified (including it) till current one\n";
610 - print STDERR " --prepare- clear all projects for incompartible build from prj_name till current one (cws version)\n";
611 + print STDERR " --mode OOo - build only projects needed for OpenOffice.org\n";
612 + print STDERR " --prepare- clear all projects for incompartible build from prj_name till current one [for platform] (cws version)\n";
613 print STDERR " --with_branches- build all projects in neighbour branches and current branch starting from actual project\n";
614 print STDERR " --since - build all projects beginning from the specified till current one (the same as \"--all:prj_name\", but skipping prj_name)\n";
615 print STDERR " --show - show what is going to be built\n";
618 $arg =~ /^--prepare$/ and $prepare = 1 and next;
619 $arg =~ /^-p$/ and $prepare = 1 and next;
620 + $arg =~ /^--prepare:/ and $prepare = 1 and $only_platform = $' and next;
621 + $arg =~ /^-p:/ and $prepare = 1 and $only_platform = $' and next;
622 $arg =~ /^--since$/ and $BuildAllParents = 1
623 and $build_since = shift @ARGV and next;
624 $arg =~ /^-c$/ and $BuildAllParents = 1
626 $arg =~ /^-i$/ and $ignore = 1 and next;
627 $arg =~ /^--version$/ and exit(0);
628 $arg =~ /^-V$/ and exit(0);
629 + $arg =~ /^-m$/ and &get_modes and next;
630 + $arg =~ /^--mode$/ and &get_modes and next;
631 if ($arg =~ /^--$/) {
635 # print "Ignored...";
636 # $incompartible = '';
638 + if ($only_platform) {
639 + $only_common = 'common';
640 + $only_common .= '.pro' if ($only_platform =~ /\.pro$/);
645 @@ -888,11 +899,23 @@
646 # cancel build when one of children has error exit code
649 + if ($BuildAllParents) {
651 + print STDERR scalar @broken_modules_names;
652 + print STDERR " module(s): ";
653 + foreach (@broken_modules_names) {
654 + print STDERR "\n\t$_";
655 + &RemoveFromDependencies($_, \%global_deps_hash);
657 + print STDERR "\nneed(s) to be rebuilt\n\nReason(s):\n\n";
658 + foreach (keys %broken_build) {
659 + print STDERR "ERROR: error " . $broken_build{$_} . " occurred while making $_\n";
661 + print STDERR "\nAttention: if you build and deliver the above module(s) you may prolongue your build from module " . &PickPrjToBuild(\%global_deps_hash) . "\n";
666 - foreach (keys %broken_build) {
667 - print STDERR "ERROR: error $_ occurred while making ", $broken_build{$_}, "\n";
669 - kill 9 => -$$ if (!$BuildAllParents);
673 @@ -902,22 +925,23 @@
675 my ($pid, $error_code) = @_;
676 my $child_nick = $processes_hash{$pid};
677 - $broken_build {$error_code} = &CorrectPath($StandDir . $PathHash{$child_nick});
678 + $broken_modules_hashes{$folders_hashes{$child_nick}}++;
679 + $broken_build{&CorrectPath($StandDir . $PathHash{$child_nick})} = $error_code;
680 &cancel_build if (!$BuildAllParents);
684 # child handler (clears (or stores info about) the terminated child)
686 -sub handle_dead_child {
688 -# yield; # Should be uncommented if you have Thread.pm (untested)
689 +sub handle_dead_children {
691 - foreach (keys %processes_hash) {
692 - if (($pid = waitpid($_, &WNOHANG)) > 0) {
693 - &store_error($pid, $?) if ($?);
694 - &clear_from_child($pid);
696 + if (($pid = waitpid( -1, &WNOHANG)) > 0) {
697 + &store_error($pid, $?) if ($?);
698 + &clear_from_child($pid);
700 + while(&children_number() >= $QuantityToBuild) {
702 + &handle_dead_children;
706 @@ -932,41 +956,31 @@
710 -# Register signal handler & unblock SIGALRM
712 -sub register_signal_handler {
713 - $sigaction = POSIX::SigAction->new('main::handle_dead_child');
714 - sigaction(SIGCHLD, $sigaction);
719 # Build the entire project according to queue of dependencies
722 $dependencies_hash = shift;
725 + $running_children{$dependencies_hash} = 0 if (!defined $running_children{$dependencies_hash});
726 while ($child_nick = &PickPrjToBuild($dependencies_hash)) {
727 - if (($QuantityToBuild) ) { # multyprocessing not for $BuildAllParents (-all etc)!!
728 - ®ister_signal_handler if (!$handler_set);
729 + if (($QuantityToBuild)) { # multyprocessing not for $BuildAllParents (-all etc)!!
731 + &handle_dead_children;
732 + return if (defined $broken_modules_hashes{$dependencies_hash});
733 # start current child & all
734 # that could be started now
735 - &start_child($child_nick) if ($child_nick);
736 - sleep if (&children_number() >= $QuantityToBuild);
737 + &start_child($child_nick) if ($child_nick);
738 $child_nick = &PickPrjToBuild($dependencies_hash);
739 while ($only_dependent) {
740 return if ($BuildAllParents);
743 $child_nick = &PickPrjToBuild($dependencies_hash);
745 } while (!$no_projects);
746 return if ($BuildAllParents);
747 - while (&children_number()) {
750 - print STDERR "Multiprocessing build is finished\n";
751 + &handle_dead_children while (&children_number());
754 &dmake_dir($child_nick);
756 @@ -975,21 +989,29 @@
759 sub children_number {
760 - return scalar (keys %processes_hash);
761 + return scalar keys %processes_hash;
765 my $child_nick = shift;
767 + my $children_running;
768 + my $oldfh = select STDOUT;
770 if ($pid = fork) { # parent
772 $processes_hash{$pid} = $child_nick;
773 - print 'Running processes: ', &children_number(), "\n";
774 + $children_running = &children_number;
775 + print 'Running processes: ', $children_running, "\n";
776 + $maximal_processes = $children_running if ($children_running > $maximal_processes);
777 $folders_hashes{$child_nick} = $dependencies_hash;
778 $running_children{$dependencies_hash}++;
779 - sleep(1) if ($BuildAllParents);
780 +# sleep(1) if ($BuildAllParents);
781 } elsif (defined $pid) { # child
784 &dmake_dir($child_nick);
789 @@ -1001,31 +1023,44 @@
790 my @build_queue = (); # array, containing queue of projects
793 - while ($Prj = &PickPrjToBuild(\%ParentDepsHash)) {
794 + while ($Prj = &PickPrjToBuild(\%global_deps_hash)) {
795 my $module_type = &module_classify($Prj);
797 if ($module_type eq 'lnk') {
798 &print_annonce($Prj);
799 - &RemoveFromDependencies($Prj, \%ParentDepsHash);
800 + &RemoveFromDependencies($Prj, \%global_deps_hash);
804 if ($module_type eq 'img') {
805 &print_annonce($Prj . '.incomp');
806 - &RemoveFromDependencies($Prj, \%ParentDepsHash);
807 + &RemoveFromDependencies($Prj, \%global_deps_hash);
810 + &mark_force_deliver($Prj, &CorrectPath($StandDir.$Prj)) if (defined $ENV{CWS_WORK_STAMP});
811 push @build_queue, $Prj;
812 $projects_deps_hash{$Prj} = {};
813 &get_deps_hash(&CorrectPath($StandDir.$Prj), $projects_deps_hash{$Prj});
816 &build_actual_queue(\@build_queue);
817 - } while (scalar (keys %ParentDepsHash));
818 + if (scalar keys %broken_modules_hashes) {
821 + &handle_dead_children;
822 + &build_actual_queue(\@build_queue);
823 + } while (&children_number());
826 + } while (scalar (keys %global_deps_hash));
827 # Let all children finish their work
828 - sleep(1) while (&children_number());
829 &cancel_build if (scalar keys %broken_build);
830 - print STDERR "Multiprocessing build is finished\n";
834 +sub mp_success_exit {
835 + print STDERR "\nMultiprocessing build is finished\n";
836 + print STDERR "Maximal number of processes run: $maximal_processes\n";
840 @@ -1038,19 +1073,27 @@
842 while ($i <= (scalar(@$build_queue) - 1)) {
843 $Prj = $$build_queue[$i];
844 + if (defined $broken_modules_hashes{$projects_deps_hash{$Prj}}) {
845 + push (@broken_modules_names, $Prj);
846 + splice (@$build_queue, $i, 1);
849 &annonce_module($Prj) if (!(defined $module_annonced{$Prj}));
852 &BuildDependent($projects_deps_hash{$Prj});
853 - if ($no_projects && ($running_children{$projects_deps_hash{$Prj}} == 0)) {
854 + if ($no_projects &&
855 + !$running_children{$projects_deps_hash{$Prj}} &&
856 + !defined $broken_modules_hashes{$projects_deps_hash{$Prj}})
858 chdir(&CorrectPath($StandDir.$Prj));
859 - system (&get_deliver_commando($Prj)) if (!$show && ($Prj ne $CurrentPrj));
860 - delete $projects_deps_hash{$Prj};
861 - &RemoveFromDependencies($Prj, \%ParentDepsHash);
862 + system (&get_deliver_commando($Prj)) if (!$show && ($Prj ne $CurrentPrj));
863 + &RemoveFromDependencies($Prj, \%global_deps_hash);
864 splice (@$build_queue, $i, 1);
868 + &handle_dead_children;
871 } while (!&are_all_dependent($build_queue));
872 @@ -1341,9 +1384,13 @@
874 $dir =~ /([\w\d\.]+)$/;
876 - return '1' if (/^common$/);
877 - return '1' if (/^common\.pro$/);
878 return '1' if (defined $platforms{$_});
879 + if ($only_common) {
880 + return '1' if ($_ eq $only_common);
882 + return '1' if (/^common$/);
883 + return '1' if (/^common\.pro$/);
888 @@ -1464,19 +1511,35 @@
894 + while ($option = shift @ARGV) {
895 + if ($option =~ /^-+/) {
896 + unshift(@ARGV, $option);
899 + if ($option =~ /,/) {
900 + $build_modes{$`}++;
901 + unshift(@ARGV, $') if ($');
902 + } else {$build_modes{$option}++;};
905 + $build_modes{$option}++;
908 sub get_incomp_projects {
910 while ($option = shift @ARGV) {
911 if ($option =~ /^-+/) {
912 unshift(@ARGV, $option);
916 if ($option =~ /(:)/) {
918 &print_error("-from switch collision") if ($build_from_opt);
919 $build_from_opt = $';
921 - $incompartibles{$option}++;
922 + $incompartibles{$option}++;
926 @@ -1493,9 +1556,11 @@
928 foreach (@platforms_conf) {
930 + next if ($only_platform && ($only_platform ne $_));
931 my $s_path = $solver . '/' . $_;
932 $platforms{$_}++ if (-e $s_path);
935 + &print_error("There is no platform found!!") if (!scalar keys %platforms);
939 @@ -1641,13 +1706,13 @@
941 sub mark_force_deliver {
942 my ($module_name, $module_path) = @_;
943 - my $cws_tag_string = 'Tcws_' . lc($ENV{WORK_STAMP}.'_'.$ENV{CWS_WORK_STAMP});
944 +# my $cws_tag_string = 'Tcws_' . lc($ENV{WORK_STAMP}.'_'.$ENV{CWS_WORK_STAMP});
945 my $cvs_tag_file = $module_path . '/CVS/Tag';
946 return if (!open CVSTAG, "<$cvs_tag_file");
949 $tag[0] =~ /^(\S+)/o;
950 - $force_deliver{$module_name}++ if ($1 eq $cws_tag_string);
951 + $force_deliver{$module_name}++ if ($1 =~ /^Tcws_/o);
954 sub get_deliver_commando {
955 @@ -1656,3 +1721,37 @@
956 return $deliver_commando . ' -force';
960 +# Store all available build modi in %build_modes
962 +sub get_build_modes {
963 + return if (scalar keys %build_modes);
964 + if (defined $ENV{BUILD_TYPE}) {
965 + if ($ENV{BUILD_TYPE} =~ /_/o) {
966 + my @build_modes = split (/_/, $ENV{BUILD_TYPE});
967 + $build_modes{$_}++ foreach (@build_modes)
969 + $build_modes{$ENV{BUILD_TYPE}}++;
973 + $build_modes{'OOo'}++;
977 +# pick only the modules, that should be built for
978 +# build types from %build_modes
980 +sub pick_for_build_type {
981 + my $modules = shift;
982 + my @mod_array = split(/\s+/, $modules);
983 + my $new_modules = '';
984 + foreach (@mod_array) {
985 + if (/(\w+):(\S+)/o) {
986 + $new_modules .= $2 . ' ' if (defined $build_modes{$1});
989 + $new_modules .= $_ . ' '
991 + return $new_modules;