]> git.pld-linux.org Git - packages/libreoffice.git/blob - openoffice-fix-parallel-build.patch
- DON'T hardcode java paths!
[packages/libreoffice.git] / openoffice-fix-parallel-build.patch
1 # Patch updates build.pl to revision 1.93 which allows parallel builds to occur
2
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
5 @@ -1,13 +1,13 @@
6 -:
7 -eval 'exec perl -S $0 ${1+"$@"}'
8 -    if 0;
9 +    :
10 +    eval 'exec perl -S $0 ${1+"$@"}'
11 +        if 0;
12  #*************************************************************************
13  #
14  #   $RCSfile$
15  #
16 -#   $Revision$
17 +#   $Revision$
18  #
19 -#   last change: $Author$ $Date$
20 +#   last change: $Author$ $Date$
21  #
22  #   The Contents of this file are made available subject to the terms of
23  #   either of the following licenses
24 @@ -67,28 +67,28 @@
25  # build - build entire project 
26  #
27  
28 -use Config;
29 -use POSIX;
30 -use Cwd;
31 -use File::Path;
32 +    use Config;
33 +    use POSIX;
34 +    use Cwd;
35 +    use File::Path;
36  #use Thread 'yield';   # Should be uncommented if you have Thread.pm (untested) 
37 -    
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;
43 -};
44 +        
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;
50 +    };
51  
52  #### script id #####
53  
54 -( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/; 
55 +    ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/; 
56  
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 = "-");
63  
64 -print "$script_name -- version: $script_rev\n";
65 +    print "$script_name -- version: $script_rev\n";
66  
67  #########################
68  #                       #
69 @@ -96,135 +96,142 @@
70  #                       #
71  #########################
72  
73 -$perl = "";
74 -$remove_commando = "";
75 -if ( $^O eq 'MSWin32' ) {
76 -       $perl = "$ENV{COMSPEC} -c perl5";
77 -       $remove_commando = "rmdir /S /Q";
78 -       $nul = '> NULL';
79 -} else {
80 -       use Cwd 'chdir';
81 -       $perl = 'perl';
82 -       $remove_commando = 'rm -rf';
83 -       $nul = '> /dev/null';
84 -};
85 +    $perl = "";
86 +    $remove_commando = "";
87 +    if ( $^O eq 'MSWin32' ) {
88 +        $perl = "$ENV{COMSPEC} -c perl5";
89 +        $remove_commando = "rmdir /S /Q";
90 +        $nul = '> NULL';
91 +    } else {
92 +        use Cwd 'chdir';
93 +        $perl = 'perl';
94 +        $remove_commando = 'rm -rf';
95 +        $nul = '> /dev/null';
96 +    };
97  
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;
108 -$handler_set = 0;
109 -$cmd_file = '';
110 -$BuildAllParents = 0;
111 -$show = 0;
112 -$deliver = 0;
113 -%LocalDepsHash = ();
114 -%BuildQueue = ();
115 -%PathHash = ();
116 -%PlatformHash = ();
117 -%AliveDependencies = ();
118 -%ParentDepsHash = (); # hash of dependencies of the current project
119 -@UnresolvedParents = ();
120 -@dmake_args = ();
121 -%DeadParents = ();
122 -$CurrentPrj = '';
123 -$no_projects = 0;
124 -$only_dependent = 0;
125 -$build_from = '';
126 -$build_from_opt = '';
127 -$build_since = '';
128 -$dlv_switch = '';
129 -$child = 0;
130 -%processes_hash = ();
131 -%module_annonced = ();
132 -$locked = 0; # lock for signal handler
133 -$prepare = ''; # prepare for following incompartible build
134 -$ignore = '';
135 -@ignored_errors = ();
136 -%incompartibles = ();
137 -%force_deliver = ();
138 -
139 -&get_options;
140 -%deliver_env = ();
141 -if ($prepare) {
142 -       %platforms = &get_platforms;
143 -       @modules_built = ();
144 -       
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'}++;
153 -};
154 -
155 -$StandDir = &get_stand_dir();
156 -&provide_consistency if (defined $ENV{CWS_WORK_STAMP});
157 -
158 -$deliver_commando = $ENV{DELIVER};
159 -$deliver_commando .= ' '. $dlv_switch if ($dlv_switch);
160 -$ENV{mk_tmp}++;
161 -%prj_platform = ();
162 -$check_error_string = '';
163 -$dmake = '';
164 -$echo = '';
165 -$new_line = "\n";
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;
173 +    $cmd_file = '';
174 +    $BuildAllParents = 0;
175 +    $show = 0;
176 +    $deliver = 0;
177 +    %LocalDepsHash = ();
178 +    %BuildQueue = ();
179 +    %PathHash = ();
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 = ();
186 +    @dmake_args = ();
187 +    %DeadParents = ();
188 +    $CurrentPrj = '';
189 +    $no_projects = 0;
190 +    $only_dependent = 0;
191 +    $build_from = '';
192 +    $build_from_opt = '';
193 +    $build_since = '';
194 +    $dlv_switch = '';
195 +    $child = 0;
196 +    %processes_hash = ();
197 +    %module_annonced = ();
198 +    $prepare = ''; # prepare for following incompartible build
199 +    $ignore = '';
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
205 +    %build_modes = ();
206 +    $maximal_processes = 0; # the max number of the processes run
207 +
208 +### main ###
209 +
210 +    &get_options;
211 +    &get_build_modes;
212 +    %deliver_env = ();
213 +    if ($prepare) {
214 +        %platforms = &get_platforms;
215 +        @modules_built = ();
216 +        
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'}++;
225 +    };
226 +
227 +    $StandDir = &get_stand_dir();
228 +    &provide_consistency if (defined $ENV{CWS_WORK_STAMP});
229 +
230 +    $deliver_commando = $ENV{DELIVER};
231 +    $deliver_commando .= ' '. $dlv_switch if ($dlv_switch);
232 +    $ENV{mk_tmp}++;
233 +    %prj_platform = ();
234 +    $check_error_string = '';
235 +    $dmake = '';
236 +    $echo = '';
237 +    $new_line = "\n";
238  #### main ####
239  
240 -&get_commands();
241 -unlink ($cmd_file);
242 -if ($cmd_file) {
243 -       if (open (CMD_FILE, ">>$cmd_file")) {
244 -               select CMD_FILE;
245 -               $echo = 'echo ';
246 -               $new_line = $echo."\"\"\n";
247 -               print "\@$echo off\npushd\n" if ($ENV{GUI} ne 'UNX');
248 -       } else {
249 -               &print_error ("Cannot open file $cmd_file");
250 -       };
251 -} elsif ($show) {
252 -       select STDERR;
253 -};
254 +    &get_commands();
255 +    unlink ($cmd_file);
256 +    if ($cmd_file) {
257 +        if (open (CMD_FILE, ">>$cmd_file")) {
258 +            select CMD_FILE;
259 +            $echo = 'echo ';
260 +            $new_line = $echo."\"\"\n";
261 +            print "\@$echo off\npushd\n" if ($ENV{GUI} ne 'UNX');
262 +        } else {
263 +            &print_error ("Cannot open file $cmd_file");
264 +        };
265 +    } elsif ($show) {
266 +        select STDERR;
267 +    };
268  
269 -print $new_line;
270 +    print $new_line;
271  
272 -&BuildAll();
273 -&cancel_build if (scalar keys %broken_build);
274 -@TotenEltern = keys %DeadParents;
275 -if ($#TotenEltern != -1) {
276 -       my ($DeadPrj);
277 -       print $new_line.$new_line;
278 -       print $echo."WARNING! Project(s):\n";
279 -       foreach $DeadPrj (@TotenEltern) {
280 -               print $echo."$DeadPrj\n";
281 -       };
282 -       print $new_line;
283 -       print $echo."not found and couldn't be built. Correct build.lsts.\n";
284 -       print $new_line;
285 -};
286 -if (($ENV{GUI} ne 'UNX') && $cmd_file) {
287 -       print "popd\n";
288 -};
289 -$ENV{mk_tmp} = '';
290 -if ($cmd_file) {
291 -       close CMD_FILE;
292 -       print STDOUT "Script $cmd_file generated\n";
293 -};
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";
299 -};
300 -print STDERR "\nERROR: please check these directories and build the correspondent module(s) anew!!\n\n";
301 -exit(1);
302 +    &BuildAll();
303 +    &cancel_build if (scalar keys %broken_build);
304 +    @TotenEltern = keys %DeadParents;
305 +    if ($#TotenEltern != -1) {
306 +        my ($DeadPrj);
307 +        print $new_line.$new_line;
308 +        print $echo."WARNING! Project(s):\n";
309 +        foreach $DeadPrj (@TotenEltern) {
310 +            print $echo."$DeadPrj\n";
311 +        };
312 +        print $new_line;
313 +        print $echo."not found and couldn't be built. Correct build.lsts.\n";
314 +        print $new_line;
315 +    };
316 +    if (($ENV{GUI} ne 'UNX') && $cmd_file) {
317 +        print "popd\n";
318 +    };
319 +    $ENV{mk_tmp} = '';
320 +    if ($cmd_file) {
321 +        close CMD_FILE;
322 +        print STDOUT "Script $cmd_file generated\n";
323 +    };
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";
329 +    };
330 +    print STDERR "\nERROR: please check these directories and build the correspondent module(s) anew!!\n\n";
331 +    exit(1);
332  
333  
334  #########################
335 @@ -236,73 +243,73 @@
336  #
337  # Get dependencies hash of the current and all parent projects
338  #
339 -sub GetParentDeps {
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) {
351 -                $Prj = $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) {
366 +                    $Prj = $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');
371 +                };
372              } elsif (defined $ENV{CWS_WORK_STAMP}) {
373 -                &checkout_module($Prj, 'image');
374 +                &check_module_consistency($Prj);
375              };
376 -        } elsif (defined $ENV{CWS_WORK_STAMP}) {
377 -                       &check_module_consistency($Prj);
378 -               };
379 -               my @DepsArray;
380 -               if (!($ParentsString = &GetParentsString($StandDir.$Prj))) {
381 -                       $DeadParents{$Prj}++;
382 -                       $$deps_hash{$Prj} = [];
383 -                       next;
384 -               };
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);
390 -                       };
391 -               };
392 -       };
393 -       foreach $parent (keys %DeadParents) {
394 -               delete $ParentDepsHash{$parent};
395 -               &RemoveFromDependencies($parent, $deps_hash);   
396 -       };
397 -};
398 +            my @DepsArray;
399 +            if (!($ParentsString = &GetParentsString($StandDir.$Prj))) {
400 +                $DeadParents{$Prj}++;
401 +                $$deps_hash{$Prj} = [];
402 +                next;
403 +            };
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);
409 +                };
410 +            };
411 +        };
412 +        foreach $parent (keys %DeadParents) {
413 +            delete $global_deps_hash{$parent};
414 +            &RemoveFromDependencies($parent, $deps_hash);      
415 +        };
416 +    };
417  
418  #
419  # Build everything that should be built 
420  #
421 -sub BuildAll {
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);
429 -               };
430 -               if ($QuantityToBuild) {
431 -                       &build_multiprocessing;
432 -                       return;
433 -               };
434 -               while ($Prj = &PickPrjToBuild(\%ParentDepsHash)) {
435 -                       print $new_line;
436 -            my $module_type = &module_classify($Prj);
437 -            
438 -            &print_annonce($Prj) if ($module_type eq 'lnk');
439 +    sub BuildAll {
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);
447 +            };
448 +            if ($QuantityToBuild) {
449 +                &build_multiprocessing;
450 +                return;
451 +            };
452 +            while ($Prj = &PickPrjToBuild(\%global_deps_hash)) {
453 +                print $new_line;
454 +                my $module_type = &module_classify($Prj);
455 +                
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);
463                                         next;
464                                 };
465                     &print_annonce($Prj);
466 @@ -318,7 +325,7 @@
467                             };
468                             print $check_error_string;
469              };
470 -            &RemoveFromDependencies($Prj, \%ParentDepsHash);
471 +            &RemoveFromDependencies($Prj, \%global_deps_hash);
472                 $no_projects = 0;
473                 };
474         } else {
475 @@ -367,26 +374,19 @@
476         if (!$cmd_file && !$show) {
477                 chdir $BuildDir;
478                 cwd();
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}));
483              $error_code = 0;
484          };
485 -               if ($error_code && ($error_code != -1)) {
486 -                       if (!$child) {
487 -                               if ($incompartible) {
488 -                                       $broken_build{$error_code} = &CorrectPath($StandDir . $PathHash{$folder_nick});
489 -                               } else {
490 -                                       &print_error("Error $? occurred while making $BuildDir");
491 -                               };
492 -                       };
493 -               };
494         };
495      if ($child) {
496          my $oldfh = select STDERR;
497          $| = 1;
498          _exit($? >> 8) if ($? && ($? != -1));
499                 _exit(0);
500 +    } elsif ($error_code && ($error_code != -1)) {
501 +               &print_error("Error $? occurred while making $BuildDir");
502      };
503  };
504  
505 @@ -409,7 +409,7 @@
506                 s/\r\n//;
507                 if ($_ =~ /\:+\s+/) {
508                         close BUILD_LST;
509 -                       return $';
510 +                       return &pick_for_build_type($');
511                 };
512         };
513         close BUILD_LST;
514 @@ -460,7 +460,7 @@
515         open (BUILD_LST, 'prj/build.lst');
516         &get_prj_platform;
517         while (<BUILD_LST>) {
518 -               if ($_ =~ /#/) {
519 +               if ($_ =~ /#/o) {
520                         if ($`) {
521                                 $_ = $`;
522                         } else {
523 @@ -468,19 +468,19 @@
524                         };
525                 };
526                 s/\r\n//;
527 -               if ($_ =~ /nmake/) {
528 +               if ($_ =~ /nmake/o) {
529                         my ($Platform, $Dependencies, $Dir, $DirAlias, @Array);
530                         $Dependencies = $';
531                         $dummy = $`;
532 -                       $dummy =~ /(\S+)\s+(\S+)/;
533 +                       $dummy =~ /(\S+)\s+(\S+)/o;
534                         $Dir = $2;
535 -                       $Dependencies =~ /(\w+)/; 
536 +                       $Dependencies =~ /(\w+)/o; 
537                         $Platform = $1;
538                         $Dependencies = $';
539 -                       while ($Dependencies =~ /,(\w+)/) {
540 +                       while ($Dependencies =~ /,(\w+)/o) {
541                                 $Dependencies = $';     
542                         };
543 -                       $Dependencies =~ /\s+(\S+)\s+/;
544 +                       $Dependencies =~ /\s+(\S+)\s+/o;
545                         $DirAlias = $1;
546                         if (!&CheckPlatform($Platform)) {
547                                 $DeadDependencies{$DirAlias}++;
548 @@ -488,6 +488,7 @@
549                         };
550                         $PlatformHash{$DirAlias}++;
551                         $Dependencies = $';
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}++;
556 @@ -614,8 +615,9 @@
557  sub PickPrjToBuild {
558         my ($Prj, $DepsHash);
559         $DepsHash = shift;
560 +    &handle_dead_children if ($QuantityToBuild);
561         $Prj = &FindIndepPrj($DepsHash);
562 -       delete $$DepsHash{$Prj};# if (defined $$DepsHash{$Prj});
563 +       delete $$DepsHash{$Prj};
564         return $Prj;
565  };
566  
567 @@ -672,12 +674,12 @@
568                         return $Prj if ($#PrjDeps == -1);
569                 };
570                 # If there are only dependent projects in hash - generate error
571 -               return '' if ($BuildAllParents);
572 +               return '' if ($BuildAllParents && !$children);
573          if ($children) {
574              $only_dependent = 1;
575              return '';
576          };
577 -               print STDERR "\nError: projects";
578 +               print STDERR "\nFatal error:";
579                 foreach $Prj (keys %$Dependencies) {
580                         if (&IsHashNative($Prj)) {
581                                 next;
582 @@ -713,12 +715,12 @@
583         $DepString = shift;
584         $string = $DepString;
585         $prj = shift;
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;
591                 $ParentPrj = $1;
592                 $DepString = $';
593 -               if ($ParentPrj =~ /\.(\w+)$/) {
594 +               if ($ParentPrj =~ /\.(\w+)$/o) {
595                         $ParentPrj = $`;
596                         if (($prj_platform{$ParentPrj} ne $1) && 
597                                 ($prj_platform{$ParentPrj} ne 'all')) {
598 @@ -761,14 +763,15 @@
599  
600  sub usage {
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";
616 @@ -816,6 +819,8 @@
617                 };
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 
625 @@ -828,6 +833,8 @@
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 =~ /^--$/) {
632              &get_dmake_args;
633              next;
634 @@ -854,6 +861,10 @@
635  #        print "Ignored...";
636  #        $incompartible = '';
637  #    };
638 +    if ($only_platform) {
639 +        $only_common = 'common';
640 +        $only_common .= '.pro' if ($only_platform =~ /\.pro$/);
641 +    };
642         @ARGV = @dmake_args;
643  };
644  
645 @@ -888,11 +899,23 @@
646  # cancel build when one of children has error exit code
647  #
648  sub cancel_build {
649 +    if ($BuildAllParents) {
650 +               print STDERR "\n";
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);
656 +        };
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";
660 +               };
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";
662 +    } else {
663 +        kill 9 => -$$;
664 +    };
665         print STDERR "\n";
666 -       foreach (keys %broken_build) {
667 -               print STDERR "ERROR: error $_ occurred while making ", $broken_build{$_}, "\n";
668 -       };
669 -    kill 9 => -$$ if (!$BuildAllParents);
670      exit(1);
671  };
672  
673 @@ -902,22 +925,23 @@
674  sub store_error {
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);
681  };
682  
683  #
684  # child handler (clears (or stores info about) the terminated child)
685  #
686 -sub handle_dead_child {
687 -    lock $locked;
688 -#    yield;      # Should be uncommented if you have Thread.pm (untested) 
689 +sub handle_dead_children {
690      my $pid = 0;
691 -    foreach (keys %processes_hash) {
692 -        if (($pid = waitpid($_, &WNOHANG)) > 0) {
693 -                       &store_error($pid, $?) if ($?);
694 -                       &clear_from_child($pid);
695 -        };
696 +    if (($pid = waitpid( -1, &WNOHANG)) > 0) {
697 +               &store_error($pid, $?) if ($?);
698 +               &clear_from_child($pid);
699 +    };
700 +       while(&children_number() >= $QuantityToBuild) {
701 +        sleep 1;
702 +        &handle_dead_children;
703      };
704  };
705  
706 @@ -932,41 +956,31 @@
707  };
708  
709  #
710 -# Register signal handler & unblock SIGALRM
711 -# 
712 -sub register_signal_handler {
713 -       $sigaction = POSIX::SigAction->new('main::handle_dead_child');
714 -       sigaction(SIGCHLD, $sigaction);
715 -       $handler_set = 1;
716 -};
717 -
718 -#
719  # Build the entire project according to queue of dependencies
720  #
721  sub BuildDependent {
722         $dependencies_hash = shift;
723         my $pid = 0;
724         my $child_nick = '';
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 -                       &register_signal_handler if (!$handler_set);
729 +        if (($QuantityToBuild)) { # multyprocessing not for $BuildAllParents (-all etc)!!
730              do {
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);
741 -                                       sleep; 
742 +                                       sleep 1; 
743                             $child_nick = &PickPrjToBuild($dependencies_hash);
744                                 };
745              } while (!$no_projects);
746                         return if ($BuildAllParents);
747 -            while (&children_number()) {
748 -                sleep(5);
749 -            };
750 -            print STDERR "Multiprocessing build is finished\n";
751 +            &handle_dead_children while (&children_number());
752 +            &mp_success_exit;
753          } else {
754                     &dmake_dir($child_nick);
755          };
756 @@ -975,21 +989,29 @@
757  };
758  
759  sub children_number {
760 -       return scalar (keys %processes_hash);
761 +       return scalar keys %processes_hash;
762  };
763  
764  sub start_child {
765         my $child_nick = shift;
766         my $pid;
767 +    my $children_running;
768 +    my $oldfh = select STDOUT;
769 +    $| = 1;
770         if ($pid = fork) { # parent
771 +        select $oldfh;
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
782 +        select $oldfh;
783                 $child = 1;
784                 &dmake_dir($child_nick);
785 +        exit(1);
786         };
787  };
788  
789 @@ -1001,31 +1023,44 @@
790         my @build_queue = ();           # array, containing queue of projects
791                                                                 # to build
792         do {
793 -               while ($Prj = &PickPrjToBuild(\%ParentDepsHash)) {
794 +               while ($Prj = &PickPrjToBuild(\%global_deps_hash)) {
795              my $module_type = &module_classify($Prj);
796              
797              if ($module_type eq 'lnk') {
798                  &print_annonce($Prj);
799 -                               &RemoveFromDependencies($Prj, \%ParentDepsHash);
800 +                               &RemoveFromDependencies($Prj, \%global_deps_hash);
801                  next;
802              };
803  
804              if ($module_type eq 'img') {
805                  &print_annonce($Prj . '.incomp');
806 -                               &RemoveFromDependencies($Prj, \%ParentDepsHash);
807 +                               &RemoveFromDependencies($Prj, \%global_deps_hash);
808                  next;
809              }
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});
814                 };
815                 sleep(1) if (!$Prj);
816                 &build_actual_queue(\@build_queue);
817 -       } while (scalar (keys %ParentDepsHash));
818 +        if (scalar keys %broken_modules_hashes) {
819 +            do {
820 +                sleep(1);
821 +                &handle_dead_children;
822 +                       &build_actual_queue(\@build_queue);
823 +            } while (&children_number());
824 +            &cancel_build;
825 +        };
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";
831 +    &mp_success_exit;
832 +};
833 +
834 +sub mp_success_exit {
835 +    print STDERR "\nMultiprocessing build is finished\n";
836 +    print STDERR "Maximal number of processes run: $maximal_processes\n";
837         exit(0);
838  };
839  
840 @@ -1038,19 +1073,27 @@
841         do {
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);
847 +                next;
848 +            };
849                         &annonce_module($Prj) if (!(defined $module_annonced{$Prj}));
850                         $only_dependent = 0;
851                         $no_projects = 0;
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}})
857 +            {
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);
865                                 next;
866                         };
867                         $i++;
868 +            &handle_dead_children;
869                 };
870                 $i = 0;
871         } while (!&are_all_dependent($build_queue));
872 @@ -1341,9 +1384,13 @@
873         my $dir = shift;
874         $dir =~ /([\w\d\.]+)$/;
875         $_ = $1;
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);
881 +    } else {
882 +        return '1' if (/^common$/);
883 +           return '1' if (/^common\.pro$/);
884 +    };
885         return '';
886  };
887  
888 @@ -1464,19 +1511,35 @@
889         };
890  };
891  
892 +sub get_modes {
893 +       my $option = '';
894 +       while ($option = shift @ARGV) {
895 +               if ($option =~ /^-+/) {
896 +                       unshift(@ARGV, $option);
897 +                       return;
898 +               } else {
899 +                       if ($option =~ /,/) {
900 +                $build_modes{$`}++;
901 +                           unshift(@ARGV, $') if ($');
902 +                       } else {$build_modes{$option}++;};
903 +               };
904 +       };
905 +       $build_modes{$option}++;
906 +};
907 +
908  sub get_incomp_projects {
909         my $option = '';
910         while ($option = shift @ARGV) {
911                 if ($option =~ /^-+/) {
912                         unshift(@ARGV, $option);
913 -                       last;
914 +                       return;
915                 } else {
916                         if ($option =~ /(:)/) {
917                                 $option = $`;
918                                 &print_error("-from switch collision") if ($build_from_opt);    
919                                 $build_from_opt = $';
920                         };
921 -                       $incompartibles{$option}++;
922 +               $incompartibles{$option}++;
923                 };
924         };
925  };
926 @@ -1493,9 +1556,11 @@
927      }
928      foreach (@platforms_conf) {
929          s/\s//g;
930 +        next if ($only_platform && ($only_platform ne $_));
931          my $s_path = $solver . '/' .  $_;
932          $platforms{$_}++ if (-e $s_path);
933 -    }
934 +    };
935 +    &print_error("There is no platform found!!") if (!scalar keys %platforms);
936         return %platforms;
937  };
938  
939 @@ -1641,13 +1706,13 @@
940  
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");
947         my @tag = <CVSTAG>;
948         close CVSTAG;
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);
952  };
953  
954  sub get_deliver_commando {
955 @@ -1656,3 +1721,37 @@
956         return $deliver_commando . ' -force'; 
957  };
958  
959 +#
960 +# Store all available build modi in %build_modes
961 +#
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)
968 +        } else {
969 +            $build_modes{$ENV{BUILD_TYPE}}++;
970 +        };
971 +        return;
972 +    };
973 +    $build_modes{'OOo'}++;
974 +};
975 +
976 +#
977 +# pick only the modules, that should be built for 
978 +# build types from %build_modes
979 +#
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});
987 +            next;
988 +        };
989 +        $new_modules .= $_ . ' '
990 +    };
991 +    return $new_modules;
992 +};
This page took 0.139953 seconds and 3 git commands to generate.