2 eval 'exec perl -wS $0 ${1+"$@"}'
5 #*************************************************************************
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 # Copyright 2008 by Sun Microsystems, Inc.
11 # OpenOffice.org - a multi-platform office productivity suite
13 # $RCSfile: XMLBuildListParser.pm,v $
17 # This file is part of OpenOffice.org.
19 # OpenOffice.org is free software: you can redistribute it and/or modify
20 # it under the terms of the GNU Lesser General Public License version 3
21 # only, as published by the Free Software Foundation.
23 # OpenOffice.org is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU Lesser General Public License version 3 for more details
27 # (a copy is included in the LICENSE file that accompanied this code).
29 # You should have received a copy of the GNU Lesser General Public License
30 # version 3 along with OpenOffice.org. If not, see
31 # <http://www.openoffice.org/license.html>
32 # for a copy of the LGPLv3 License.
34 #*************************************************************************
37 #************************************************************
38 # Data structure and XML parser/creator for the changeover *
39 # of the current build.lst to build.xlist files *
40 # programmer: Pascal Junck, Sun Microsystems GmbH *
41 #************************************************************
43 # The current XMLBuildListParser is the second step for the changeover to XML.
44 # It was written to create a complex structure with more possibilities to store informations
45 # of the 'build.lst' files in the new XML files. The important informations were parsed by the
46 # 'buildlst_parser.pl' from the old files and then are (temporary) stored by the set and add
47 # methods in the module 'XMLBuildListParser' and 'XML::Parser'. By the API of this module it's
48 # possible to create the new XML 'build.xlist' files.
50 # If the '$Product' or the '$JobPlatform' (as also '$BuildReqPlatform') have no value,
51 # their value are automatically 'all'.
52 # It doesn't matter whether it's the set/add or the get method, that receives or sends
53 # these optional parameters.
54 # In the created XML file the default values aren't set, because of the constraints of the
55 # 'Document Type Definition'(DTD).
56 # If there is no product/platform attribute in the 'build.xlist' it means a default of 'all'!
58 # The important parameters are:
60 # $ModuleName = it's the name of the current module
62 # $DependencyType = here are the three possible scalar dependency values
63 # for all other depending modules(of the current module):
64 # 'md-simple', 'md-always' and 'md-force'
66 # $Products = which products can be used for the module dependencies
67 # and might have more different whitespace separated values
68 # e.g.'so oo' (scalar type)
70 # $Dir = it means a string(scalar) with the current working directory,
71 # with a '/'(current directory) at the beginning of the string
73 # $JobType = it means a job e.g. 'make'
75 # $Platforms = in this scalar parameter might be more than one different value,
76 # like: 'wnt unx mac' and 'all'('all' includes the three values)
77 # it must be whitespace separated
79 # @DependingDirs = a list(array) of all inner depending directories
80 # of the current working directory
82 # %BuildReq = means a hash with build requirement pairs:
83 # 'BuildReqName'(key) => 'BuildReqPlatform'(value)
87 ############################## begin of main ########################################
93 package XMLBuildListParser
;
95 # global variable for printing out all results at parsing
96 # if the debug variable is set to '1' it prints the results to STDOUT
100 ############################# begin of subroutines ###################################
104 my $invocant = shift;
105 my $class = ref($invocant) || $invocant;
109 # no real instance data yet, might change if package is extended
110 bless($self, $class);
111 $$self{'error_string'} = '';
112 $self->beginXMLStructure();
117 # VG: procedure for a better error handling
121 return $$self{'error_string'};
124 ########################################################################################
129 # description: get the 'path' of the 'build.xlist'(s), load it in the 'xml parser tree'
130 # and fill it in the own data_structure to make it available for the API
131 ########################################################################################
139 my $TreeParse = new XML
::Parser
(Style
=> 'Tree');
145 $File_ref = $TreeParse->parsefile($File);
151 print"ERROR: $@" if ($Debug);
152 $$self{'error_string'} = 'ERROR: ' . $@
. ". Error occured while trying to parse $File";
158 filterXMLFile
($File_ref);
160 $$self{"ModuleData"} = $File_ref;
167 $$self{'error_string'} = "ERROR: cannot find file $File";
172 ########################################################################################
174 # gets: $ArrayContent_ref
177 # description: filters all '0' and whitespace based pairs of the XML file
178 # -> all spaces, tabs and new lines
179 ########################################################################################
182 my $ArrayContent_ref = shift;
184 # get the number of elements of the array_ref
185 my $Count = getContentCount
($ArrayContent_ref);
187 for (my $i = 0; $i < $Count;)
189 # get each content pair
190 my $Content_ref = getContent
($ArrayContent_ref, $i);
192 # in each content pair the first element is either
193 # a tag name or the value '0'
194 my $FirstContent = getTagName
($Content_ref);
196 # we need the second part of the content pair to check
197 # which value is inside
198 my $SecondContent = getSecondContent
($Content_ref);
200 my $tempArray_ref = "";
201 if (($FirstContent eq "task") or ($FirstContent eq "depend"))
203 my $dir = $Content_ref->[1]->[0]->{dir
};
205 $Content_ref->[1]->[0]->{dir
} = $dir;
207 filterXMLFile
($Content_ref);
209 elsif ($FirstContent eq "0")
211 # only if there is in the first part a '0' and in the
212 # second part are whitespaces...
213 if ($SecondContent =~ /\s+/)
215 # ...make a ref at this position
216 $tempArray_ref = @
$ArrayContent_ref[1];
218 # and delete this element pair
219 removeContent
($tempArray_ref, $i);
221 # now we have one element pair fewer
226 # is there a '0' but in the second part not a whitespace,
233 # if it's a tag name, increase 'i' by one and call recursive
234 # the 'filterXMLFile' with the 'content ref'
237 # look further after the '0' and whitespace content
238 filterXMLFile
($Content_ref);
243 ########################################################################################
245 # gets: $File_ref, $Count
248 # description: removes the '0' and the whitespace based pairs of the XML structure
249 # whitespace could be: tabs, new lines and whitespace itself
250 ########################################################################################
253 my $tempArray_ref = shift;
256 my $Start = (2*$i) + 1;
258 splice(@
$tempArray_ref, $Start, 2);
261 ########################################################################################
262 # sub: beginXMLStructure
263 # gets: $ModuleData_ref
266 # description: create a new beginning of the XML file structure
267 ########################################################################################
268 sub beginXMLStructure
272 # global variable for the complete filled data structure
273 my $ModuleData_ref = createTag
("build-list", {});
275 $$self{"ModuleData"} = $ModuleData_ref;
278 ########################################################################################
280 # gets: $HigherLevelTag_ref, $currentTag_ref, $Pos
283 # description: insert a content at the right (alphabetical sorted) position
284 ########################################################################################
287 my $HigherLevelTag_ref = shift;
288 my $currentTag_ref = shift;
291 my $Array_ref = $HigherLevelTag_ref->[1];
295 splice(@
$Array_ref, $Pos, 0, @
$currentTag_ref);
298 ########################################################################################
303 # description: creates a XML file of the whole data structure
304 ########################################################################################
310 my $ModuleData_ref = $$self{"ModuleData"};
312 # open the filehandle 'CREATE_XML' for creating the XML files
313 open (SAVE_XML
, ">".$Path)
314 or die "Error. Open the file <build.xlist> wasn't successful!\n\n";
318 print"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
319 print"<!DOCTYPE build-list SYSTEM \"build_xlist.dtd\">\n";
321 ."***************************************************************************\n"
323 ."* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. \n"
325 ."* Copyright 2008 by Sun Microsystems, Inc. \n"
327 ."* OpenOffice.org - a multi-platform office productivity suite \n"
329 ."* \$RCSfile: XMLBuildListParser.pm,v $ \n"
331 ."* \$Revision: 1.3 $ \n"
333 ."* This file is part of OpenOffice.org. \n"
335 ."* OpenOffice.org is free software: you can redistribute it and/or modify \n"
336 ."* it under the terms of the GNU Lesser General Public License version 3 \n"
337 ."* only, as published by the Free Software Foundation. \n"
339 ."* OpenOffice.org is distributed in the hope that it will be useful, \n"
340 ."* but WITHOUT ANY WARRANTY; without even the implied warranty of \n"
341 ."* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n"
342 ."* GNU Lesser General Public License version 3 for more details \n"
343 ."* (a copy is included in the LICENSE file that accompanied this code). \n"
345 ."* You should have received a copy of the GNU Lesser General Public License \n"
346 ."* version 3 along with OpenOffice.org. If not, see \n"
347 ."* <http://www.openoffice.org/license.html> \n"
348 ."* for a copy of the LGPLv3 License. \n"
350 ."***************************************************************************\n"
353 printTag
($ModuleData_ref);
356 # it's the same like the both lines below here, but we make it manually without module 'IO'
358 # SAVE_XML -> autoflush(1);
367 ########################################################################################
372 # description: prints out each tag of the existing data structure (XML tree)
373 ########################################################################################
378 # the first time we call this function the 'pos counter' has the default value of '0',
379 # because it is for the begin tag -> it shouldn't have a distance to the left side
380 my $PosCounter = shift || 0;
382 # makes it possible that each tag has a specified distance from the left sided margin
383 my $Distance = " " x
$PosCounter;
385 # it's possible that the content is a text(case 1) between a begin and end tag
386 # or a tag name(case 2)
387 # case 1: ( 0 , "Text between the begin and end tag" )
388 my $TagName = getTagName
($Tag_ref);
392 print"$Tag_ref->[1]";
394 # case 2: ( "TagName" , (...) )
398 # only a new line if it is not the first tag
399 print"\n" if ($PosCounter != 0);
400 print $Distance."<".$TagName;
402 my $Attributes_ref = getAttributesRef
($Tag_ref);
404 # print all sorted attributes of this tag
405 foreach my $Attribute (sort keys %$Attributes_ref)
407 my $value = $$Attributes_ref{$Attribute};
408 print" $Attribute=\"$value\"";
411 # get the number of elements of the array
412 my $ContentCount = getContentCount
($Tag_ref);
415 # if it is an empty tag create a '/' before we close it with '>'
416 print"/" if ($ContentCount == 0);
419 # get and print all tags recursive
420 for (my $i = 0; $i < $ContentCount; $i++)
422 # here we get the content of the current tag,
423 # we rise the 'pos counter' that each level of tags
424 # has a specified distance from the left side
425 printTag
(getContent
($Tag_ref, $i), $PosCounter + 2);
428 # check that the tag has a text between the begin and end tag
429 # first: had the tag further inner tags?
430 if ($ContentCount > 0)
432 my $Content_ref = getContent
($Tag_ref, 0);
433 my $TagName = getTagName
($Tag_ref);
434 my $TagContent = getTagName
($Content_ref);
436 # if a tag has a begin tag and a following text, create the end tag behind the text
437 print"</$TagName>" if ($TagContent eq "0");
439 print"\n".$Distance."</$TagName>" if ($TagContent ne "0");
444 ########################################################################################
449 # description: gets a reference of an array and returns the tag name at position '0'
450 ########################################################################################
453 my $Content_ref = shift;
455 my $TagName = $$Content_ref[0];
460 ########################################################################################
461 # sub: getSecondContent
464 # returns: $SecondContent
465 # description: gets a reference of an array and returns the second value(index '1')
466 ########################################################################################
469 my $Content_ref = shift;
471 my $SecondContent = $$Content_ref[1];
473 return $SecondContent;
476 ########################################################################################
478 # gets: $DependencyType, $DepModuleName
481 # description: creates a key with a number(depending of the dependency type)
482 # and a string and returns it
483 ########################################################################################
486 my $DependencyType = shift;
487 my $DepModuleName = shift;
489 my $DepTypeAsValue = 0;
491 if ($DependencyType eq "md-simple")
495 elsif ($DependencyType eq "md-always")
499 elsif ($DependencyType eq "md-force")
504 my $SortKey = $DepTypeAsValue.$DepModuleName;
509 ########################################################################################
511 # gets: $TagName, $Tag_ref
513 # returns: $TagValues_ref
514 # description: gets a reference and goes in the lower level tag,
515 # looks after the specified tag name and returns the reference
516 # of itself and the neighbour element
517 ########################################################################################
523 my $TagSerie_ref = $Tag_ref->[1];
525 # (all elements of the array) - 1 => highest index of the array
526 my $IndexEnd = scalar(@
$TagSerie_ref)-1;
528 my $TagValues_ref = undef;
530 for (my $i = 1; $i <= $IndexEnd; $i += 2)
532 if ($TagSerie_ref->[$i] eq $TagName)
534 @
$TagValues_ref = @
$TagSerie_ref[$i..$i+1];
540 return $TagValues_ref;
543 ########################################################################################
545 # gets: $TagName, $Attribute_ref
548 # description: creates an anonymous array with a tag name and the reference of its
549 # attributes; then returns the reference of this array
550 ########################################################################################
554 my $Attribute_ref = shift;
556 my $Tag_ref = [$TagName, [$Attribute_ref]];
561 ########################################################################################
565 # returns: $TagText_ref
566 # description: creates an anonymous array(which contains a '0' and a string)
567 # for the data structure and returns a reference of it
568 ########################################################################################
573 my $TagText_ref = [0, $Text];
578 ########################################################################################
580 # gets: $Tag_ref, $NextInfos_ref
583 # description: creates and adds a tag with its following content
584 ########################################################################################
587 # '$NextInfos_ref' has two infos:
588 # either: '0' and a string -> [Tag, [{}, 0 , string ]]
589 # or: 'tag' and a ref of a anonymous array -> [Tag, [{}, newTag, [.....] ]]
591 my $NextInfos_ref = shift;
593 my $SecondPart_ref = $Tag_ref->[1];
595 # '$Tag_ref' gets now the right structure:
596 # e.g. ['tag1', [{}, 0, "text of tag1" ...]...]
597 # or ['tag1', [{}, 'tag2', [...] ...]...]
598 push(@
$SecondPart_ref, @
$NextInfos_ref);
601 ########################################################################################
605 # returns: \@Content (ref of array 'content')
606 # description: creates and returns a reference of an array with two elements,
607 # which are a part of the array of the current tag
608 ########################################################################################
615 # [ "tag 1", [ {} , 0 , "string", "tag 2", [{}..], "tag 3", [{}..], ..] ..]
616 # $Tag_ref [ [0] [1] ..]
617 # $Content_ref [ [0] [1] [2] [3] [4] [5] [6] ..]
619 my $Content_ref = $$Tag_ref[1];
621 # '$start' contains: elements with the index 1, 3, 5 ...(and so on)
622 # '$end' contains: elements with the index 2, 4, 6 ...(and so on)
623 my $start = (2 * $i) + 1;
624 my $end = $start + 1;
626 my @Content = @
$Content_ref[$start..$end];
631 ########################################################################################
633 # gets: $Tag_ref, $AttributeName
635 # returns: $Attribute
636 # description: finds and returns an attribute as a string
637 ########################################################################################
641 my $AttributeName = shift;
643 # [ "tag1", [ { attribute1 = "..", attribute2 = ".." } , "tag2"... ] ]
644 # Tag_ref [ [0] [1] ] ]
645 # [ [0]->'attribute1' , [0]->'attribute2' , [1] ... ] ]
647 # get the scalar of the value of the 'AttributeName' in the anonymous hash
648 my $Attribute = $Tag_ref->[1]->[0]->{$AttributeName};
653 ########################################################################################
654 # sub: getAttributeRef
657 # returns: $Attribute_ref
658 # description: finds and returns the reference of the hash which contains the attributes
659 ########################################################################################
664 # [ "tag1", [ { attribute1 = "..", attribute2 = ".." } , "tag2"... ] ]
665 # Tag_ref [ [0] [1] ] ]
668 # get the reference of the anonymous hash
669 my $Attribute_ref = $Tag_ref->[1]->[0];
671 return $Attribute_ref;
674 ########################################################################################
675 # sub: getContentCount
678 # returns: $IndexValue
679 # description: returns the sum of elements pairs of the array (less the anonymous hash)
680 ########################################################################################
685 # get the content array (address of the inner array)
686 my $Content_ref = $$Tag_ref[1];
688 # get the number of the element pairs of the array (without the anonymous hash)
689 my $IndexValue = scalar(@
$Content_ref);
690 $IndexValue = ($IndexValue-1)/2;
695 ########################################################################################
696 # sub: getIterationData
699 # returns: $IndexValue, $TagDepend_ref
700 # description: gets a tag name and returns the sum of elements pairs of the array
701 # (less the anonymous hash) and the reference of the anonymous array
702 ########################################################################################
708 my $ModuleData_ref = $$self{"ModuleData"};
710 my $TagDepend_ref = searchTag
($TagName, $ModuleData_ref);
711 my $IndexValue = getContentCount
($TagDepend_ref);
713 return ($IndexValue, $TagDepend_ref);
716 ########################################################################################
717 # sub: printErrorMessage
718 # gets: $BuildReqPlatforms or $Platforms or $Products
721 # description: it's an error, if a platform or a product content (e.g.'so oo')
722 # has at least one valid value and also the value 'all',
723 # because 'all' includes all other possible values
724 ########################################################################################
725 sub printErrorMessage
730 my $ModuleData_ref = $$self{"ModuleData"};
732 my $Module_ref = searchTag
("module-name", $ModuleData_ref);
733 my $ModuleContent_ref = getContent
($Module_ref, 0);
734 my $Module = @
$ModuleContent_ref[1];
736 print"Error in module <$Module> in Content <$Content>!\n";
737 print"The value 'all' includes all currently existing valid values.\n\n";
740 ########################################################################################
741 # sub: adjustRedundancy
742 # gets: $Task_ref, $JobPlatform, $BuildReq_ref
745 # description: the tag <task> (it means 'job') should be created with no redundant infos,
746 # like: <task dir="/uno" platform="unx"> ...
747 # <task dir="/uno" platform="wnt"> ...
748 # <build-requirement name="test10" platform="wnt">
750 # it should be: <task dir="/uno" platform="unx wnt">
751 # <build-requirement name="test10" platform="wnt">
752 ########################################################################################
755 my $Task_ref = shift;
756 my $JobPlatform = shift;
757 my $BuildReq_ref = shift;
759 my %sortedJobPlatforms = ();
760 my @JobPlatforms = ();
761 my $PlatformContent = "";
763 # get the 'task platforms' in one content
764 my $Attributes_ref = getAttributesRef
($Task_ref);
766 # get the existing 'task platform'
767 my $existingPlatform = getAttribute
($Task_ref, "platform");
768 $existingPlatform = "all" if (!($existingPlatform));
770 if ( ($existingPlatform ne "all") && ($JobPlatform ne "all") )
772 # get the sorted platform content
773 $sortedJobPlatforms{$JobPlatform} = "";
774 $sortedJobPlatforms{$existingPlatform} = "";
776 @JobPlatforms = sort keys %sortedJobPlatforms;
778 $PlatformContent = join " ", @JobPlatforms;
780 $$Attributes_ref{"platform"} = $PlatformContent;
782 elsif ( ($existingPlatform ne "all") && ($JobPlatform eq "all") )
784 delete $$Attributes_ref{"platform"};
789 my $JobType_ref = getContent
($Task_ref, 0);
791 # if it exists add the 'build requirements' at the
792 # previous(with the same directory as the current) <task> tag
793 addBuildReq
($JobType_ref, $BuildReq_ref);
797 ########################################################################################
799 # gets: $JobTypeInfos_ref, $BuildReq_ref
802 # description: add the 'build requirements' to the existing data structure
803 # case 1: if the 'job directory' is not redundant
804 # case 2: if it is redundant create it to the first existing 'job'
805 ########################################################################################
808 my $JobTypeInfos_ref = shift;
809 my $BuildReq_ref = shift;
811 my @sortedBuildReqPlatforms = ();
813 foreach my $BuildReqName (sort keys %$BuildReq_ref)
815 my $BuildReqPlatforms = $$BuildReq_ref{$BuildReqName};
817 $BuildReqPlatforms = "all" if (!($BuildReqPlatforms));
819 my $Attributes_ref = {"name" => "$BuildReqName"};
821 # it's wrong, if in a platform content(e.g. "unx wnt") are at least
822 # one or more platform(s) and within a 'all' term,
823 # because 'all' is default and means it includes all other possible values!
824 if ( ($BuildReqPlatforms ne "all") && ($BuildReqPlatforms =~ /\ball\b/) )
826 printErrorMessage
($BuildReqPlatforms);
828 elsif (!($BuildReqPlatforms =~ /\ball\b/))
830 @sortedBuildReqPlatforms = sort(split(/\s+/, $BuildReqPlatforms));
831 $BuildReqPlatforms = join " ", @sortedBuildReqPlatforms;
833 $$Attributes_ref{"platform"} = "$BuildReqPlatforms";
836 # create the tag <build-requirement>
837 my $BuildReqInfos_ref = createTag
("build-requirement", $Attributes_ref);
839 # append the <build-requirement> tag to the <'$JobType'> tag
840 addContent
($JobTypeInfos_ref, $BuildReqInfos_ref);
844 ########################################################################################
845 # sub: checkJobRedundancy
846 # gets: $Task_ref, $JobType, $DependingDirs_ref, $JobPlatform, $BuildReq_ref
848 # returns: $LineIsRedundant
849 # description: checks whether the values of the 'job' line are redundant, like:
850 # 'job dir', 'job'(e.g.: make) and 'depending dirs'
851 ########################################################################################
852 sub checkJobRedundancy
854 my $Task_ref = shift;
856 my $DependingDirs_ref = shift;
857 my $JobPlatform = shift;
858 my $BuildReq_ref = shift;
860 my $LineIsRedundant = 0;
863 # get the ref of the existing 'depending directories'
864 # if they also equal with the current 'depending directories',
865 # make one tag instead of two, which differences only in the platform
866 # (and the 'build requirement', if it exists)
867 my $JobType_ref = getContent
($Task_ref, 0);
868 my $JobName = getTagName
($JobType_ref);
870 # get the existing 'task platform'
871 my $existingPlatform = getAttribute
($Task_ref, "platform");
873 # are the jobs equal?
874 if ($JobType eq $JobName)
876 my @existingDepDirs = ();
878 my $IndexEnd = getContentCount
($JobType_ref);
880 # get all existing 'depending dirs' of this redundant 'job'
881 for (my $j = 0; $j < $IndexEnd; $j++)
883 my $Content_ref = getContent
($JobType_ref, $j);
885 my $TagName = getTagName
($Content_ref);
887 # create an array of the 'depending directories'
888 if ($TagName eq "depend")
890 my $DepDir = getAttribute
($Content_ref, "depend");
892 push(@existingDepDirs, $DepDir);
896 # if now the current 'depending dirs' equal with the existing,
897 # we know that is redundant and have to create only one instead
899 # before: <task dir="/uno" platform="unx">...
900 # <task dir="/uno" platform="wnt"> ...
901 # <build-requirement name="test10" platform="wnt">
903 # it should be: <task dir="/uno" platform="unx wnt">
904 # <build-requirement name="test10" platform="wnt">
905 if (@
$DependingDirs_ref eq @existingDepDirs)
907 $LineIsRedundant = 1;
909 # check redundant directories and create no redundant 'task dirs'
910 adjustRedundancy
($Task_ref, $JobPlatform, $BuildReq_ref);
914 return $LineIsRedundant;
917 ########################################################################################
921 # returns: $TagExists_ref
922 # description: checks whether that a tag exists and returns the ref of the content
923 ########################################################################################
929 my $TagExists_ref = undef;
931 my $ModuleData_ref = $$self{"ModuleData"};
933 # check whether that the <module-depend> tag exists
934 $TagExists_ref = searchTag
($TagName, $ModuleData_ref);
936 return $TagExists_ref;
939 ########################################################################################
940 # API - (internal) 'set/add' methods #
941 ########################################################################################
943 ########################################################################################
948 # description: gets the name of the current module and set it at the right position
949 # in the data structure
950 ########################################################################################
954 my $ModuleName = shift;
956 my $ModuleData_ref = $$self{"ModuleData"};
958 my $Tag_ref = createTag
("module-name", {});
959 my $TagText_ref = createText
($ModuleName);
961 addContent
($Tag_ref, $TagText_ref);
963 addContent
($ModuleData_ref, $Tag_ref);
966 ########################################################################################
967 # sub: addModuleDependencies
968 # gets: $ModuleName, $DependencyType, $Products
969 # optional: $Products(default: 'all' -> includes currently 'so' and 'oo')
970 # but the default should not set in the data structure,
971 # it's only a 'Document Type Definition' based term
973 # description: add the module dependencies and their attributes into the data structure
974 ########################################################################################
975 sub addModuleDependencies
978 my $ModuleName = shift;
979 my $DependencyType = shift;
980 my $Products = shift || "all";
982 my $ModuleData_ref = $$self{"ModuleData"};
984 my @sortedProducts = ();
986 # change all possible upper cases to lower cases
987 $Products =~ s/($Products)/\L$Products/;
989 # before we add the module dependencies, we have to prove that the <module-depend> tag was set
990 # because this tag must be set once before the module dependency tags begin
991 my $ModuleDepend_ref = searchTag
("module-depend", $ModuleData_ref);
993 # if it doesn't exist, create this tag '<module-depend>'
994 if (!($ModuleDepend_ref))
996 $ModuleDepend_ref = createTag
("module-depend", {});
998 # add it to the global data structure
999 addContent
($ModuleData_ref, $ModuleDepend_ref);
1002 my $Attributes_ref = {"module" => "$ModuleName"};
1004 # it's wrong, if in a product content(e.g. "so") are at least
1005 # one or more product(s) and within a 'all' term,
1006 # because 'all' is default and means it includes all other possible values!
1007 if ( ($Products ne "all") && ($Products =~ /\ball\b/) )
1009 printErrorMessage
($Products);
1011 elsif (!($Products =~ /\ball\b/))
1013 @sortedProducts = sort(split(/\s+/ ,$Products));
1014 $Products = join " ", @sortedProducts;
1016 $$Attributes_ref{"product"} = "$Products";
1019 my $ModuleDependenciesInfos_ref = createTag
("$DependencyType", $Attributes_ref);
1021 my $currentKey = createSortKey
($DependencyType, $ModuleName);
1023 # search and get the position in which we have to insert the current 'module depend name'
1024 # at first get the current 'module depend name'
1025 my $currentName = getAttribute
($ModuleDependenciesInfos_ref, "module");
1027 # get the information about the number of 'Contents'(= elements) of the array
1028 my $ContentCount = getContentCount
($ModuleDepend_ref);
1030 # we have to sort the serie of the 'name' contents,
1031 # therefore we need a 'Pos'(position) of the array in which we want to sort in the 'name' content
1034 # and we need a control variable 'isInsert'
1035 # that we won't add the 'name' and the content more than one time
1038 for (my $i = 0; $i < $ContentCount; $i++)
1040 # get each 'Content' of the array = ('task', ARRAY(...))
1041 my $Content_ref = getContent
($ModuleDepend_ref, $i);
1042 my $TagName = getTagName
($Content_ref);
1044 # get the existing 'task dir' to compare it with the current 'task dir'
1045 my $existingName = getAttribute
($Content_ref, "module");
1047 my $existingKey = createSortKey
(getTagName
($Content_ref), $existingName);
1049 # compare both dirs...
1050 # only if the 'current dir' is lower than a 'existing dir'
1051 # insert it in the data structure
1052 if ($currentKey lt $existingKey)
1056 insertContent
($ModuleDepend_ref, $ModuleDependenciesInfos_ref, $Pos);
1063 # only if the 'current name' is greater (or equal) than the other 'existing names'
1064 # insert it at the end of the data structure
1065 addContent
($ModuleDepend_ref, $ModuleDependenciesInfos_ref) if ($isInsert == 0);
1068 ########################################################################################
1070 # gets: $Dir, $JobType, $JobPlatform, $DependingDirs_ref, $BuildReq_ref,
1071 # $JobPlatform, $DependingDirs_ref, $BuildReq_ref
1072 # optional: $JobPlatform(default: 'all' -> includes all other possible values),
1073 # $DependingDirs_ref, $BuildReq_ref
1075 # description: add the infos about a job from the old build lists(by ascii parser) and
1076 # sort it in the data structure
1077 ########################################################################################
1082 my $JobType = shift;
1083 my $JobPlatform = shift || "all";
1084 my $DependingDirs_ref = shift;
1085 my $BuildReq_ref = shift;
1087 my $ModuleData_ref = $$self{"ModuleData"};
1089 # before we add the "build" tag, we have to prove that the <build> tag was set
1090 # because this tag must be set once before the job tag(s) follows
1091 my $buildTag_ref = searchTag
("build", $ModuleData_ref);
1093 # if it doesn't exist, create the tag '<build>'
1094 if (!($buildTag_ref))
1096 # If the tag wasn't found, create it
1097 $buildTag_ref = createTag
("build", {});
1099 # add it to the global data structure
1100 addContent
($ModuleData_ref, $buildTag_ref);
1103 my $Attributes_ref = {"dir" => "$Dir"};
1105 # it's wrong, if a 'job platform' content(e.g. "unx wnt") has at least
1106 # one or more 'job platform(s)' and an 'all' term,
1107 # because 'all' is default and means it includes all other possible values
1108 if ( ($JobPlatform ne "all") && ($JobPlatform =~ /\ball\b/) )
1110 printErrorMessage
($JobPlatform);
1112 elsif (!($JobPlatform =~ /\ball\b/))
1114 my @sortedPlatforms = sort(split /\s+/, $JobPlatform);
1115 $JobPlatform = join " ", @sortedPlatforms;
1117 $$Attributes_ref{"platform"} = "$JobPlatform";
1120 # create the tags: <task>, <make> and (if it exists)...
1121 # <depend> and/or <build-requirement>
1122 my $taskInfos_ref = createTag
("task", $Attributes_ref);
1124 # search and get the position in which we have to insert the current task
1125 # at first get the current 'task directory'
1126 my $currentDir = getAttribute
($taskInfos_ref, "dir");
1128 # get the information about the number of 'Contents'(= elements) of the array
1129 my $IndexValue = getContentCount
($buildTag_ref);
1131 # we have to sort the serie of the 'task contents',
1132 # therefore we need a '$pos'(position) of the array in which we want to sort in the 'task content'
1135 # and we need a control variable 'isInsert'
1136 # that we won't add the 'task content' more than one time
1139 # control variable for the redundancy check
1140 my $LineIsRedundant = 0;
1142 # go in the array of the corresponding <build> tag element
1143 for (my $i = 0; $i < $IndexValue; $i++)
1145 # get each content of the <build> tag => ('task1', ARRAY1(...), task2...)
1146 my $Task_ref = getContent
($buildTag_ref, $i);
1148 # get the existing 'task dir' to compare it with the current 'task dir'
1149 my $existingDir = getAttribute
($Task_ref, "dir");
1151 # is the 'job dir' redundant?
1152 if ($currentDir eq $existingDir)
1154 $LineIsRedundant = checkJobRedundancy
($Task_ref, $JobType, $DependingDirs_ref, $JobPlatform, $BuildReq_ref);
1157 # if it's not a redundant line, compare both dirs:
1158 # only if the 'current dir' is lower than an 'existing dir'
1159 # insert it in the data structure
1160 if ( ($LineIsRedundant == 0) && ($currentDir lt $existingDir) )
1164 insertContent
($buildTag_ref, $taskInfos_ref, $Pos);
1172 # only if the 'current dir' is greater (or equal) than the other 'existing dirs'
1173 # and it is not redundant insert it at the end of the data structure
1174 if ( ($isInsert == 0) && ($LineIsRedundant == 0) )
1176 addContent
($buildTag_ref, $taskInfos_ref);
1179 if ($LineIsRedundant == 0)
1181 # create the <'$JobType'> tag
1182 my $JobTypeInfos_ref = createTag
($JobType, {});
1184 # append the <'$JobType'> tag to the <task> tag
1185 addContent
($taskInfos_ref, $JobTypeInfos_ref);
1187 # before we add the "depend" infos
1188 # we have to get the alphabetical sorted 'Depending Directories'
1189 @
$DependingDirs_ref = sort(@
$DependingDirs_ref) if ($DependingDirs_ref);
1191 foreach my $DependDir (@
$DependingDirs_ref)
1193 my $DependInfos_ref = createTag
("depend", {"dir" => "$DependDir"});
1195 # append the <depend> tag to the <'$JobType'> tag
1196 addContent
($JobTypeInfos_ref, $DependInfos_ref);
1199 # if a 'build requirement' exists, create the tag <build-requirement>
1202 addBuildReq
($JobTypeInfos_ref, $BuildReq_ref);
1207 ########################################################################################
1208 # end of (internal) 'set/add' methods #
1209 ########################################################################################
1212 ########################################################################################
1213 # API - (external) 'get' methods #
1214 ########################################################################################
1216 ########################################################################################
1217 # sub: getModuleDependencies
1218 # gets: $Product, $DependencyType
1219 # optional: $Product(default: 'all', means all currently used valid values),
1220 # $DependencyType(default: 'md-simple', 'md-always' and 'md-force')
1221 # returns: @ModuleDependencies
1222 # description: gets a ref of an array (with the products) and creates and
1223 # returns an array with the sorted depending modules
1224 ########################################################################################
1227 if ($self->existsTag("module-name")) {
1228 my ($IndexValue, $ModuleDepend_ref) = $self->getIterationData("module-name");
1229 return $$ModuleDepend_ref[1][2];
1234 sub getModuleDependencies
1237 my $Products_ref = shift;
1238 my $DependencyType = shift || "all";
1240 push(@
$Products_ref, "all") if (!scalar @
$Products_ref);
1243 my %tempModuleDeps = ();
1244 my @ModuleDependencies = ();
1246 my $ModuleData_ref = $$self{"ModuleData"};
1248 # check whether that the <module-depend> tag exists
1249 if ($self->existsTag("module-depend"))
1251 # change all possible upper cases to lower cases
1252 $DependencyType =~ s/($DependencyType)/\L$DependencyType/ if ($DependencyType ne "all");
1254 foreach $Product (@
$Products_ref)
1256 # change all possible upper cases to lower cases
1257 $Product =~ s/($Product)/\L$Product/;
1259 my $ProductContent = undef;
1260 my $ModuleDependencyName = "";
1262 # get the number of elements and the ref of the <module-depend> tag
1263 my ($IndexValue, $ModuleDepend_ref) = $self->getIterationData("module-depend");
1265 for (my $i = 0; $i < $IndexValue; $i++)
1267 my $Content_ref = getContent
($ModuleDepend_ref, $i);
1269 my $ModuleDependencyName = getAttribute
($Content_ref, "module");
1271 # get the name of each existing tag
1272 my $TagName = getTagName
($Content_ref);
1274 $ProductContent = getAttribute
($Content_ref, "product");
1276 # if the attribute 'product' wasn't set in the internal data structure,
1277 # it means the default of 'all' is valid and includes all other possible values
1278 $ProductContent = "all" if (!($ProductContent));
1280 if ($Product ne "all")
1282 if ($DependencyType ne "all")
1284 # if the caller wants all (e.g.)'so' product based dependency types,
1285 # we must get the 'so' and the 'all' matching products
1286 # because 'all' matches also the product 'so'
1287 if ( ($DependencyType eq $TagName) &&
1288 ((($ProductContent eq "all") || $ProductContent =~ /\b($Product)\b/)) )
1290 $tempModuleDeps{$ModuleDependencyName} = "";
1292 print"ModuleDeps (Product != 'all' && DepType != 'all') = <$ModuleDependencyName>\n" if ($Debug);
1295 # we get from the caller only the 'product' parameter,
1296 # 'dependency type' is now 'all'(default) and includes all possible values
1297 elsif ( ($ProductContent =~ /\b($Product)\b/) || ($ProductContent eq "all") )
1299 $tempModuleDeps{$ModuleDependencyName} = "";
1301 print"ModuleDeps (Product != 'all' && DepType = 'all') = <$ModuleDependencyName>\n" if ($Debug);
1304 # now the product is 'all' and we only need to check the 'dependency type'
1305 elsif ($DependencyType ne "all")
1307 if ($DependencyType eq $TagName)
1309 $tempModuleDeps{$ModuleDependencyName} = "";
1311 print"ModuleDeps (Product = 'all' && DepType != 'all') = <$ModuleDependencyName>\n" if ($Debug);
1316 $tempModuleDeps{$ModuleDependencyName} = "";
1318 print"ModuleDeps (Product = 'all' && DepType = 'all') = <$ModuleDependencyName>\n" if ($Debug);
1323 @ModuleDependencies = sort keys %tempModuleDeps;
1326 print"ModuleDependencies = <@ModuleDependencies>\n" if ($Debug);
1328 return @ModuleDependencies;
1331 ########################################################################################
1332 # sub: getModuleDepType
1333 # gets: $DepModuleName
1335 # returns: $DependencyType
1336 # description: gets a module name and returns the dependency type of it
1337 ########################################################################################
1338 sub getModuleDepType
1341 my $DepModuleName = shift;
1343 my $DependencyType = "";
1345 my $ModuleData_ref = $$self{"ModuleData"};
1347 # check whether that the <module-depend> tag exists
1348 if ($self->existsTag("module-depend"))
1350 # change all possible upper cases to lower cases
1351 $DepModuleName =~ s/($DepModuleName)/\L$DepModuleName/;
1353 my ($IndexValue, $ModuleDepend_ref) = $self->getIterationData("module-depend");
1355 for (my $i = 0; $i < $IndexValue; $i++)
1357 my $Content_ref = getContent
($ModuleDepend_ref, $i);
1358 my $existingModuleName = getAttribute
($Content_ref, "module");
1360 if ($DepModuleName eq $existingModuleName)
1362 $DependencyType = getTagName
($Content_ref);
1368 print"DependencyType = <$DependencyType>\n" if ($Debug);
1370 return $DependencyType;
1373 ########################################################################################
1374 # sub: getModuleProducts
1375 # gets: $DepModuleName
1377 # returns: @ModuleProducts
1378 # description: gets a module name and returns the associated products
1379 ########################################################################################
1380 sub getModuleProducts
1383 my $DepModuleName = shift;
1385 my @ModuleProducts = ();
1387 my $ModuleData_ref = $$self{"ModuleData"};
1389 # check whether that the <module-depend> tag exists
1390 if ($self->existsTag("module-depend"))
1392 # change all possible upper cases to lower cases
1393 $DepModuleName =~ s/($DepModuleName)/\L$DepModuleName/;
1395 my $ProductContent = undef;
1397 my ($IndexValue, $ModuleDepend_ref) = $self->getIterationData("module-depend");
1399 for (my $i = 0; $i < $IndexValue; $i++)
1401 my $Content_ref = getContent
($ModuleDepend_ref, $i);
1403 my $existingModuleName = getAttribute
($Content_ref, "module");
1405 # if the attribute 'product' wasn't set in the internal data structure,
1406 # it means the default of 'all' is valid and includes all other possible values
1407 $ProductContent = getAttribute
($Content_ref, "product");
1409 if ($DepModuleName eq $existingModuleName)
1411 $ProductContent = "all" if (!($ProductContent));
1413 @ModuleProducts = split /\s+/, $ProductContent;
1420 print"Products = <@ModuleProducts>\n" if ($Debug);
1422 return @ModuleProducts;
1425 ########################################################################################
1429 # returns: @ModuleProducts
1430 # description: returns the products of the whole depending modules
1431 # each found product name may occurs only once in the module products array
1432 ########################################################################################
1436 my $ProductContent = undef;
1437 my @tempProducts = ();
1438 my @ModuleProducts = ();
1441 my $ModuleData_ref = $$self{"ModuleData"};
1443 # check whether that the <module-depend> tag exists
1444 if ($self->existsTag("module-depend"))
1446 my ($IndexValue, $ModuleDepend_ref) = $self->getIterationData("module-depend");
1448 for (my $i = 0; $i < $IndexValue; $i++)
1450 my $Content_ref = getContent
($ModuleDepend_ref, $i);
1452 $ProductContent = getAttribute
($Content_ref, "product");
1454 # if the attribute 'product' wasn't set in the internal data structure,
1455 # it means the default of 'all' is valid and includes all other possible values
1456 # but here we need only all 'not-all' values!
1457 if (!($ProductContent))
1463 # here are the products of the current depending module
1464 @tempProducts = split /\s+/, $ProductContent;
1466 foreach my $Product (@tempProducts)
1468 $Products{$Product} = "";
1473 # fill the sorted 'module products' in the array
1474 @ModuleProducts = sort keys %Products;
1477 print"All ModuleProducts = <@ModuleProducts>\n" if ($Debug);
1479 return @ModuleProducts;
1482 ########################################################################################
1483 # sub: getJobDirectories
1484 # gets: $JobType, $JobPlatform
1485 # optional: $JobType, $JobPlatform(default: 'all' -> includes all possible values)
1486 # returns: @JobDirectories
1487 # description: creates and returns an array with the sorted directories, which
1488 # fulfil the expected values of the job type and the job platform
1489 ########################################################################################
1490 sub getJobDirectories
1493 my $JobType = shift;
1494 my $JobPlatform = shift || "all";
1496 my @JobDirectories = ();
1498 my $ModuleData_ref = $$self{"ModuleData"};
1500 # check whether that the <build> tag exists
1501 if ($self->existsTag("build"))
1503 # change all possible upper cases to lower cases
1504 $JobType =~ s/($JobType)/\L$JobType/ if ($JobType);
1505 $JobPlatform =~ s/($JobPlatform)/\L$JobPlatform/ if ($JobPlatform ne "all");
1507 my $PlatformContent = undef;
1508 my %tempJobDirectories = ();
1510 # get the ref of the <build> tag
1511 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1513 for (my $i = 0; $i < $IndexValue; $i++)
1515 my $Content_ref = getContent
($Build_ref, $i);
1517 my $PlatformContent = getAttribute
($Content_ref, "platform");
1518 my $existingDir = getAttribute
($Content_ref, "dir");
1520 # three cases are possible...
1523 my $JobType_ref = getContent
($Content_ref, 0);
1524 my $existingJobType = getTagName
($JobType_ref);
1526 # if the attribute 'job platform' wasn't set in the internal data structure,
1527 # it means the default of 'all' is valid and includes all other possible values
1528 $PlatformContent = "all" if (!($PlatformContent));
1530 # first case: we get from the caller the parameters 'job type' and 'job platform'
1531 if ($JobPlatform ne "all")
1533 # if the caller wants all e.g.'wnt' job platform based directories,
1534 # we have to get the 'wnt' or the 'all' matching platform
1535 # because 'all' includes also 'wnt'
1536 if ( ($JobType eq $existingJobType) &&
1537 (($PlatformContent =~ /\b($JobPlatform)\b/) || ($PlatformContent eq "all")) )
1539 $tempJobDirectories{$existingDir} = "";
1542 # second case: we get from the caller only the 'job type' parameter
1543 # 'job platform' is now 'all'(default) and includes all possible values
1544 elsif ($JobType eq $existingJobType)
1546 $tempJobDirectories{$existingDir} = "";
1549 # third case: we get from the caller no parameter; now we take each existing 'job directory',
1550 # no matter which 'job type' and 'job platform' it has
1553 $tempJobDirectories{$existingDir} = "";
1557 # sort each unique 'job directory' alphabetical
1558 @JobDirectories = sort keys %tempJobDirectories;
1560 print"JobDirectories = <@JobDirectories>\n" if ($Debug);
1562 return @JobDirectories;
1565 ########################################################################################
1566 # sub: getDirDependencies
1567 # gets: $Dir, $JobType, $JobPlatform
1568 # optional: $JobPlatform(default: 'all' -> includes all possible values)
1569 # returns: @JobDependencies
1570 # description: creates and returns an array with the sorted depending directories
1571 ########################################################################################
1572 sub getDirDependencies
1576 my $JobType = shift;
1577 my $JobPlatform = shift || "all";
1579 my @JobDependencies = ();
1581 my $ModuleData_ref = $$self{"ModuleData"};
1583 # check whether that the <build> tag exists
1584 if ($self->existsTag("build"))
1586 # change all possible upper cases to lower cases
1587 $JobType =~ s/($JobType)/\L$JobType/;
1588 $JobPlatform =~ s/($JobPlatform)/\L$JobPlatform/ if ($JobPlatform ne "all");
1590 my $PlatformContent = undef;
1591 my %tempJobDependencies = ();
1593 # first we need a reference of the higher level tag <build>
1594 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1596 # get all 'job directories' with the matching values of the 'job type' and the 'job platform'
1597 my @tempDepDirs = ();
1598 @tempDepDirs = $self->getJobDirectories($JobType, $JobPlatform);
1600 # get each content of the <build> tag
1601 for (my $i = 0; $i < $IndexValue; $i++)
1603 # get the ref of the content of the <build> tag
1604 my $Task_ref = getContent
($Build_ref, $i);
1606 # get both attributes: 'job dir' and 'job platform'
1607 my $existingDir = getAttribute
($Task_ref, "dir");
1608 my $PlatformContent = getAttribute
($Task_ref, "platform");
1610 # if the attribute 'job platform' wasn't set in the internal data structure,
1611 # it means the default of 'all' is valid and includes all other possible values
1612 $PlatformContent = "all" if (!($PlatformContent));
1614 # get the 'job type' ref which is inside the <task> tag on position '0'
1615 my $JobType_ref = getContent
($Task_ref, 0);
1617 my $existingJobType = getTagName
($JobType_ref);
1619 if ( ($Dir eq $existingDir) && ($JobType eq $existingJobType) )
1621 # each 'job type' can have several 'depends' and 'build requirements'
1622 # here we get the number of the including elements
1623 my $IndexEnd = getContentCount
($JobType_ref);
1625 for (my $j = 0; $j < $IndexEnd; $j++)
1627 # create a ref of the existing content
1628 my $Content_ref = getContent
($JobType_ref, $j);
1630 # the content_ref can be 'depend' or 'build requirement'
1631 # but we only need the 'depend' informations
1632 next if (getTagName
($Content_ref) ne "depend");
1634 # get the 'depend dir'
1635 my $DependDir = getAttribute
($Content_ref, "dir");
1637 # look in the list of all existing 'job directories'
1638 foreach my $DepDir (@tempDepDirs)
1640 # get it, if one of these 'job dirs' is equal with one of the 'depending dirs'
1641 if ($DepDir eq $DependDir)
1643 # get all unique values only once
1644 $tempJobDependencies{$DepDir} = "";
1651 # get the unique sorted values in the array
1652 @JobDependencies = sort keys %tempJobDependencies;
1655 print"Depending Dirs = <@JobDependencies>\n" if ($Debug);
1657 return @JobDependencies;
1660 ########################################################################################
1664 # returns: @JobTypes
1665 # description: creates and returns an array with the sorted 'job types'
1666 ########################################################################################
1674 my $ModuleData_ref = $$self{"ModuleData"};
1676 # check whether that the <build> tag exists
1677 if ($self->existsTag("build"))
1679 # it's for creating unique 'job types' which exists only once in the (later) array
1680 my %tempJobTypes = ();
1682 # first we need a reference of the higher level tag <build>
1683 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1685 for (my $i = 0; $i < $IndexValue; $i++)
1687 # get the ref of the <build> tag
1688 my $Task_ref = getContent
($Build_ref, $i);
1689 my $existingDir = getAttribute
($Task_ref, "dir");
1691 # we only need the 'task(s)' with the matching dir
1692 next if ($Dir ne $existingDir);
1694 # get the ref of the <task> tag at the position '0'
1695 my $JobType_ref = getContent
($Task_ref, 0);
1696 my $JobType = getTagName
($JobType_ref);
1698 # get the 'job type' as a key in the hash
1699 # so we can guarantee that each 'job type' stays unique!
1700 $tempJobTypes{$JobType} = "";
1703 # fill the unique sorted 'job types' in the array
1704 @JobTypes = sort keys %tempJobTypes;
1707 print"JobTypes = <@JobTypes>\n" if ($Debug);
1712 ########################################################################################
1713 # sub: getJobBuildReqs
1714 # gets: $Dir, $BuildReqPlatform
1715 # optional: $BuildReqPlatform(default: 'all' -> includes all possible values)
1716 # returns: @JobBuildRequirements
1717 # description: creates and returns an array with the sorted 'job build requirements'
1718 ########################################################################################
1723 my $BuildReqPlatform = shift || "all";
1725 my @JobBuildRequirements = ();
1727 my $ModuleData_ref = $$self{"ModuleData"};
1729 # check whether that the <build> tag exists
1730 if ($self->existsTag("build"))
1732 # change all possible upper cases to lower cases
1733 $BuildReqPlatform =~ s/($BuildReqPlatform)/\L$BuildReqPlatform/ if ($BuildReqPlatform ne "all");
1735 my $BuildReqPlatformContent = undef;
1736 my %tempJobBuildRequirements = ();
1738 # first we need a reference of the higher level tag <build>
1739 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1741 for (my $i = 0; $i < $IndexValue; $i++)
1743 # get the ref to the content of the array of the <build> tag
1744 my $Task_ref = getContent
($Build_ref, $i);
1746 # get the attribute 'task dir'
1747 my $existingDir = getAttribute
($Task_ref, "dir");
1749 # get the 'job type' ref which is inside the <task> tag
1750 my $JobType_ref = getContent
($Task_ref, 0);
1752 # each 'job type' can have several 'depends' and 'build requirements'
1753 # here we get the number of the included elements
1754 my $IndexEnd = getContentCount
($JobType_ref);
1756 for (my $j = 0; $j < $IndexEnd; $j++)
1758 # create a ref of the existing content
1759 my $Content_ref = getContent
($JobType_ref, $j);
1761 # the content_ref can be 'build requirement' or 'depend'
1762 # but we need only the 'build requirement' informations
1763 next if (getTagName
($Content_ref) ne "build-requirement");
1765 my $BuildReqName = getAttribute
($Content_ref, "name");
1766 $BuildReqPlatformContent = getAttribute
($Content_ref, "platform");
1768 $BuildReqPlatformContent = "all" if (!($BuildReqPlatformContent));
1770 if ($BuildReqPlatform ne "all")
1772 # compare the parameters: 'dir' and 'platform'
1773 # other values('wnt', 'unx' and 'mac') for 'platform'
1774 # including the value 'all' in the existing 'platform' list
1775 # get each 'build requirement name' only once (unique)
1776 if ( ($Dir eq $existingDir) &&
1777 (($BuildReqPlatformContent =~ /\b($BuildReqPlatform)\b/) || ($BuildReqPlatformContent =~ /\ball\b/)) )
1779 $tempJobBuildRequirements{$BuildReqName} = "";
1781 print"JobBuildRequirements (if) = <$BuildReqName>\n" if ($Debug);
1784 # if the 'build requirement platform' was not allocated, it is "all" (default)
1785 # now we only need to compare the directories
1786 elsif ($Dir eq $existingDir)
1788 $tempJobBuildRequirements{$BuildReqName} = "";
1790 print"JobBuildRequirements (elsif) = <$BuildReqName>\n" if ($Debug);
1795 # fill the unique sorted 'build requirement names' in the array
1796 @JobBuildRequirements = sort keys %tempJobBuildRequirements;
1799 print"JobBuildRequirements = <@JobBuildRequirements>\n" if ($Debug);
1801 return @JobBuildRequirements;
1804 ########################################################################################
1805 # sub: getJobBuildReqPlatforms
1806 # gets: $Dir, $BuildReqName
1808 # returns: @JobBuildReqPlatforms
1809 # description: creates and returns an array with
1810 # the sorted 'job build requirement platforms'
1811 ########################################################################################
1812 sub getJobBuildReqPlatforms
1816 my $JobBuildReqName = shift;
1818 my @JobBuildReqPlatforms = ();
1820 my $ModuleData_ref = $$self{"ModuleData"};
1822 # check whether that the <build> tag exists
1823 if ($self->existsTag("build"))
1825 # change all possible upper cases to lower cases
1826 $JobBuildReqName =~ s/($JobBuildReqName)/\L$JobBuildReqName/;
1828 my $BuildReqPlatformContent = undef;
1829 my @tempPlatforms = ();
1830 my %tempJobBuildReqPlatforms = ();
1832 # first we need a reference of the higher level tag <build>
1833 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1835 for (my $i = 0; $i < $IndexValue; $i++)
1837 # get the ref to the content of the array of the <build> tag
1838 my $Task_ref = getContent
($Build_ref, $i);
1840 # get the attribute 'task dir'
1841 my $existingDir = getAttribute
($Task_ref, "dir");
1843 # get the 'job type' ref which is inside the <task> tag
1844 my $JobType_ref = getContent
($Task_ref, 0);
1846 # each 'job type' can have several 'depends' and 'build requirements'
1847 # here we get the number of the included elements
1848 my $IndexEnd = getContentCount
($JobType_ref);
1850 for (my $j = 0; $j < $IndexEnd; $j++)
1852 # create a ref of the existing content
1853 my $Content_ref = getContent
($JobType_ref, $j);
1855 # the content_ref can be 'build requirement' or 'depend'
1856 # but we need only the 'build requirement' informations
1857 next if (getTagName
($Content_ref) ne "build-requirement");
1859 my $existingJobBuildReqName = getAttribute
($Content_ref, "name");
1860 $BuildReqPlatformContent = getAttribute
($Content_ref, "platform");
1862 $BuildReqPlatformContent = "all" if (!($BuildReqPlatformContent));
1864 if ( ($Dir eq $existingDir) && ($JobBuildReqName eq $existingJobBuildReqName) )
1866 # here are the platforms of the current 'build requirement'
1867 @tempPlatforms = split /\s+/, $BuildReqPlatformContent;
1869 foreach my $BuildReqPlatform (@tempPlatforms)
1871 $tempJobBuildReqPlatforms{$BuildReqPlatform} = "";
1877 # fill the unique sorted 'build requirement platforms' in the array
1878 @JobBuildReqPlatforms = sort keys %tempJobBuildReqPlatforms;
1881 print"JobBuildReqPlatforms = <@JobBuildReqPlatforms>\n" if ($Debug);
1883 return @JobBuildReqPlatforms;
1886 ########################################################################################
1887 # sub: getJobPlatforms
1890 # returns: @JobPlatforms
1891 # description: creates and returns an array with the sorted depending 'job platforms'
1892 ########################################################################################
1898 my @JobPlatforms = ();
1900 my $ModuleData_ref = $$self{"ModuleData"};
1902 # check whether that the <build> tag exists
1903 if ($self->existsTag("build"))
1905 my $PlatformContent = undef;
1906 my %tempJobPlatforms = ();
1908 # control variable: if a value 'all' exists in the platform content
1909 # it doesn't matter which platforms are also existing,
1910 # because 'all' includes all possible values!
1913 # first we need a reference of the higher level tag <build>
1914 my ($IndexValue, $Build_ref) = $self->getIterationData("build");
1916 for (my $i = 0; $i < $IndexValue; $i++)
1918 my $Task_ref = getContent
($Build_ref, $i);
1920 # get the attributes of the <task> tag
1921 my $existingTaskDir = getAttribute
($Task_ref, "dir");
1922 $PlatformContent = getAttribute
($Task_ref, "platform");
1924 # if it is not set in the data structure,
1925 # it has automatically the default value 'all'
1926 $PlatformContent = "all" if (!($PlatformContent));
1928 if ($Dir eq $existingTaskDir)
1930 # if a platform value 'all' exists, we remember it
1931 # and don't look further after other platforms
1932 if ($PlatformContent =~ /\ball\b/)
1936 @JobPlatforms = "all";
1941 my @tempPlatforms = ();
1943 push(@tempPlatforms, split(/\s+/, $PlatformContent));
1945 foreach my $Platform (@tempPlatforms)
1947 $tempJobPlatforms{$Platform} = "";
1952 # fill the unique sorted 'job platforms' in the array,
1953 # but only if the content "all" is not present in the platform content
1954 @JobPlatforms = sort keys %tempJobPlatforms if ($allExists == 0);
1957 print"JobPlatforms = <@JobPlatforms>\n" if ($Debug);
1959 return @JobPlatforms;
1962 ########################################################################################
1963 # end of 'get' methods #
1964 ########################################################################################