1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#**************************************************************
6#
7#  Licensed to the Apache Software Foundation (ASF) under one
8#  or more contributor license agreements.  See the NOTICE file
9#  distributed with this work for additional information
10#  regarding copyright ownership.  The ASF licenses this file
11#  to you under the Apache License, Version 2.0 (the
12#  "License"); you may not use this file except in compliance
13#  with the License.  You may obtain a copy of the License at
14#
15#    http://www.apache.org/licenses/LICENSE-2.0
16#
17#  Unless required by applicable law or agreed to in writing,
18#  software distributed under the License is distributed on an
19#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20#  KIND, either express or implied.  See the License for the
21#  specific language governing permissions and limitations
22#  under the License.
23#
24#**************************************************************
25
26
27
28
29#*****************************************************************************************
30# ASCII parser for the changeover of the current build.lst files to XML files            *
31# programmer: Pascal Junck, Sun Microsystems GmbH                                        *
32#*****************************************************************************************
33
34# this is the first step for the changeover of the current 'build.lst' files to the new
35# 'build.xlist'(XML) files
36# before we create the new ones we have to parse all important informations from the old files
37# important parameters are:
38# 1. 'module name'
39# 2. 'module dependency names'
40# 3. 'dependency type'
41# 4. 'job dir'
42# 5. 'depending directories'
43# 6. 'job platform'(only: 'w', 'u', 'm' and 'all')
44# 7. 'job'(only: 'nmake' means 'make')
45# 8. 'build requirements'(here called: 'restrictions')
46
47
48#################################  begin of main   #######################################
49
50use strict;
51use lib ("/home/vg119683/work/modules");
52
53use XMLBuildListParser;
54
55# get and work with each argument(build.lst files) of the commando line
56# e.g. if the user wants to parse the build.lst file(s):
57#   user input (on unix) for all modules    : 'perl -w ascii_parser.pl /so/ws/SRC680/src.m42/*/prj/build.lst'
58#   user input (on windows) for one module  : 'perl -w ascii_parser.pl O:/SRC680/src.m42/[module]/prj/build.lst'
59# get all arguments (build.lst files) of the commando line in this global variable '@buildlist_files'
60my @buildlist_files = @ARGV;
61# global variable for each file name that we want to parse in ASCII
62my $parse_file = "";
63# set the global variable '$debug' (= 1) to see all results on the terminal,
64# else (= 0) it shows nothing of the working output!
65my $debug = 0;
66
67# open the filehandle 'ERROR_LOG' for all errors
68open (ERROR_LOG, ">>ascii_parse.log")
69  or die "Error. Open the file <ascii_parse.log> wasn't successful!\n\n";
70
71# reference of the instance of a new object
72my $XMLTree;
73
74foreach (@buildlist_files)
75{
76   # get each element (= module) in '$parse_file'
77   $parse_file = $_;
78
79   # open the filehandle 'PARSE_ASCII' for each module/file that we want to parse
80   open (PARSE_ASCII, $parse_file)
81     or die "Error. Open the module <$parse_file> wasn't successful!\n\n";
82
83   # create a new object
84   $XMLTree = XMLBuildListParser->new();
85
86   # invoking of the main subroutine
87   reading_file();
88
89   # is the file name 'build.lst' in the path on the command line?
90   # if not, we can not parse and create the new 'build.xlist' file
91   if ($parse_file =~ /build(\w+)?\.lst\S*$/)
92   {
93      my $path = $parse_file;
94
95      $path =~ s/build(\w+)?\.lst\S*$/build\.xlist/;
96
97      $XMLTree->saveXMLFile($path);
98   }
99   else
100   {
101      add_errorlog_no_buildlst_file_found_statement($parse_file);
102   }
103
104   # close the current $parse_file
105   close(PARSE_ASCII);
106
107}
108# after all files were read close the errorlog file
109close(ERROR_LOG);
110
111
112###########################  begin of subroutines  #####################################
113#
114#                       global used variable: $parse_file
115#
116########################################################################################
117
118
119########################################################################################
120#       sub: reading_file
121#      gets: $_ (current file)
122#   returns: -
123########################################################################################
124sub reading_file
125{
126   # variable for the name of the current module
127   my $module_name = "";
128
129   # hashes for the infos beginning at the second line of the build.lst files
130   my %dir_of_job_platform = ();
131   my %dir_of_alias = ();
132
133   # control variable for the module dependency line of the file
134   #   like line 1 of module 'sal' (dependencies means the colon(s)) (SRC680/src.m42)
135   #   "sa      sal     :       xml2cmp NULL"
136   my $module_dependency_line_exists = 0;
137   my $module_dependency_line_was_read = 0;
138
139   # this line variables are for checking that all lines will be read
140   # counts each line
141   my $line_number = 0;
142   # for the sum of the informative lines (='module dependency line' and 'nmake' lines of the file)
143   my $info_line_sum = 0;
144   # for the sum of the no-info lines, like:
145   # job lines: 'usr1', 'get', ... and comment lines: '# ...' or empty lines
146   my $no_info_line_sum = 0;
147
148   # read all lines of the file to resolve the first alias
149   # with the matching dir to know all aliases and directories
150   # at the later second file reading
151   while (<PARSE_ASCII>)
152   {
153      # the variable for each line of a file
154      my $line = $_;
155
156      # count each line for more exact error descriptions in the log file
157      $line_number += 1;
158
159      # remember it, if this line exists
160      if ( (is_module_dependency_line($line)) && ($module_dependency_line_exists == 0) )
161      {
162         $module_dependency_line_exists = 1;
163
164         # get the name of the current module
165         $module_name = get_module_name($line);
166      }
167
168      # skip all lines, that hasn't the job 'nmake'
169      next if (!(is_nmake_line($line)));
170
171      # check that the infos (job directory, job platform and alias) exist
172      if (my ($job_dir, $job_platform, $alias) = get_alias_resolving_infos($line))
173      {
174         # prove that it's a valid job_platform
175         # and that each first alias and matching job platform exists only once
176         check_alias_and_job_platform($job_dir, $job_platform, $alias, \%dir_of_job_platform,
177                                      \%dir_of_alias, $module_name, $line_number);
178      }
179      else
180      {
181         chomp;
182         add_errorlog_unknown_format_statement($line, $module_name, $line_number);
183         next;
184      }
185   }
186   # reset the $line_number, because we count it again
187   $line_number = 0;
188
189   # read the same file again
190   seek (PARSE_ASCII,0,0);
191
192   # read each line of the file for all other informations
193   # e.g. line 8 of module 'sal'
194   # "sa  sal\systools\win32\guistdio  nmake  -     n          sa_guistdio     sa_uwinapi.n          NULL"
195   #             $job_dir              $job     $job_platform   1.$alias   2.$alias + alias platform
196   while (<PARSE_ASCII>)
197   {
198      # the variable for each line of a file
199      my $line = $_;
200
201      # count each line to check at the end of the file that all lines were read
202      # and for more exact error descriptions in the log file
203      $line_number += 1;
204
205      # is it a 'nmake' or a 'module dependency' line?
206      # if not: print this line to STDOUT,
207      #         count one to the no-info lines,
208      #         try to get the information about the module name from this line
209      #         and skip the line
210      if ( (!(is_nmake_line($line))) && (!(is_module_dependency_line($line))) )
211      {
212         my $no_info_line = show_no_info_line($line, $line_number);
213
214         $no_info_line_sum += $no_info_line;
215
216         # if no module dependency line exists get the name of the current module from another line
217         $module_name = get_module_name($line) if (!($module_name));
218
219         # skip the no-info line
220         next;
221      }
222
223      # only if the module dependency line exists and it wasn't read get the infos about it
224      if ( ($module_dependency_line_exists) && (!($module_dependency_line_was_read)) )
225      {
226         ($module_dependency_line_was_read, $info_line_sum) = get_module_dependency_line_infos
227                                                              ($line, $module_name, $line_number);
228      }
229
230      # get all 'nmake' line infos
231      my $info_line = get_nmake_line_infos($line, \%dir_of_alias, \%dir_of_job_platform,
232                                           $module_name, $line_number);
233
234      # count the info lines;
235      $info_line_sum += $info_line;
236   }
237
238   if ($debug == 1)
239   {
240      # show the sums of the info and no-info lines
241      lines_sums_output($module_name, $line_number, $info_line_sum, $no_info_line_sum);
242   }
243}
244
245########################################################################################
246#       sub: is_module_dependency_line
247#      gets: $line
248#   returns: 1 (true) or 0 (false)
249########################################################################################
250sub is_module_dependency_line
251{
252   my $line = shift;
253
254   # if the module dpendency line exists return 1, otherwise 0
255   ($line =~ /^\w+\s+\S+\s+:+\s+/)
256   ? return 1
257   : return 0;
258}
259
260########################################################################################
261#       sub: is_nmake_line
262#      gets: $line
263#   returns: '1' (true) or '0' (false)
264########################################################################################
265sub is_nmake_line
266{
267   my $line = shift;
268
269   # these lines are NO nmake lines:
270   # 1. a empty line
271   # 2. a comment line (perhaps with the job 'nmake')
272   #    like line 20 of module 'bridges' (SRC680/src.m42)
273   #    "#br  bridges\source\cli_uno  nmake  -  w,vc7  br_cli_uno br_unotypes NULL========= "
274   # 3. the module dependency line
275   #    like line 1 of module 'sal' (dependencies means the colon(s)) (SRC680/src.m42)
276   #    "sa      sal     :       xml2cmp N                                    ULL"
277   # 4. a 'p' job platform line (for OS2)
278   # 5. a line with a job, which is not 'nmake'
279   ($line =~ (/^[^\s+\#]/) && (!(/\s+:+\s+/)) && (!(/\s+p\s+/)) && (/\bnmake\b/) )
280   ? return 1
281   : return 0;
282}
283
284########################################################################################
285#       sub: get_alias_resolving_infos
286#      gets: $line
287#   returns: $job_dir, $job_platform, $alias
288########################################################################################
289sub get_alias_resolving_infos
290{
291   my $line = shift;
292
293   if ($line =~ /^\w+\s+(\S+)\s+\w+\s+\-\s+(\w+)\,?(\w+)?\s+(\S+)\s+/)
294   {
295      # get the current work directory
296      my $temp_job_dir = $1;
297
298      my $job_dir = change_job_directory($temp_job_dir);
299
300      # get the job platform of the current job
301      # if it is a 'n' job platform transform it to 'w'
302      # because 'n' can be used now as 'w' (both means windows)
303      my $job_platform = $2;
304      $job_platform = "w" if($job_platform eq "n");
305
306      # get the first alias in each line
307      my $alias = $4;
308
309      return ($job_dir, $job_platform, $alias);
310   }
311   return (undef, undef, undef);
312}
313
314########################################################################################
315#       sub: change_job_directory
316#      gets: $job_dir
317#   returns: $changed_job_dir
318########################################################################################
319# we don't need the module name and the first '\' in the current directory
320sub change_job_directory
321{
322   my $changed_job_dir = shift;
323
324   # ignore the module name
325   $changed_job_dir =~ s/^\w+//;
326   # change all other '\' against the '/' of the current dir
327   $changed_job_dir =~ s/\\/\//g;
328
329   # get only a "/" if we are in the root directory
330   $changed_job_dir = "/" if ($changed_job_dir eq "");
331
332   return $changed_job_dir;
333}
334
335########################################################################################
336#       sub: check_alias_and_job_platform
337#      gets: $job_dir, $job_platform, $alias, $dir_of_job_platform_ref,
338#            $dir_of_alias_ref, $module_name, $line_number
339#   returns: -
340########################################################################################
341# get it in the hash only if it is a valid job platform,
342# like 'w', 'u', 'm' and 'n'
343# 'all' is also valid but it doesn't exist in an alias platform(!)
344sub check_alias_and_job_platform
345{
346   my ($job_dir, $job_platform, $alias, $dir_of_job_platform_ref,
347       $dir_of_alias_ref, $module_name, $line_number) = @_;
348
349   # is it a valid job_platform?
350   if ($job_platform =~ /(w|u|m|n|all)/)
351   {
352      # get only the 'w', 'u', 'm' and 'n' based job platforms
353      if ($job_platform =~ /[wumn]/)
354      {
355         # doesn't the key already exist?
356         (!(exists $$dir_of_job_platform_ref{$job_platform.$alias}))
357           # get the first alias with the matching job platform in the hash
358         ? get_alias_and_job_platform($job_platform, $alias, $dir_of_job_platform_ref)
359           # this is a line with a redundant alias and job platform
360         : add_errorlog_alias_redundancy_statement($module_name, $alias, $job_platform, $line_number);
361      }
362      if (!(exists $$dir_of_alias_ref{$alias}))
363      {
364         # get each first alias with the matching job platform
365         get_alias_and_matching_directory($dir_of_alias_ref, $alias, $job_dir);
366      }
367   }
368   # it's not a valid job platform
369   else
370   {
371      add_errorlog_invalid_platform_statement($module_name, $job_platform, $line_number);
372   }
373}
374
375########################################################################################
376#       sub: get_alias_and_job_platform
377#      gets: $job_platform, $alias, $dir_of_job_platform_ref
378#   returns: -
379########################################################################################
380# get the the job platform and the first alias as a unique key
381# and the job platform as value of the hash
382# it's for checking later that the alias platform is equal to the job platform
383#   e.g.: line 6 + 7 of the module 'gtk' (SRC680/src.m42)
384#   "gt  gtk\pkgconfig  nmake  -  u   gt_pkg   NULL"
385#   "gt  gtk\glib       nmake  -  u   gt_glib gt_pkg.u NULL"
386#   the alias 'gt_pkg' has the directory 'gtk\pkgconfig' (we need only 'pkgconfig')
387#   and it has the job platform 'u' - compare it with the alias platform 'gt_pkg.u'
388sub get_alias_and_job_platform
389{
390   my ($job_platform, $alias, $dir_of_job_platform_ref) = @_;
391
392   # key = 'job platform' and 'first alias'   =>   value = 'job platform'
393   $$dir_of_job_platform_ref{$job_platform.$alias} = $job_platform;
394}
395
396########################################################################################
397#       sub: get_alias_and_matching_directory
398#      gets: $dir_of_alias_ref, $alias, $job_dir
399#   returns: -
400########################################################################################
401# fill the hash with the first alias and the matching directory
402#   e.g. line 14 of module 'setup2' (SRC680/src.m42)
403#   "se  setup2\win\source\unloader   nmake   -   w   se_wulo se_unotypes NULL"
404#   key = 'se_wulo'     =>    value = 'win/source/unloader'
405sub get_alias_and_matching_directory
406{
407   my ($dir_of_alias_ref, $alias, $job_dir) = @_;
408
409   #     key = 'first alias'  => value = 'job directory'
410   $$dir_of_alias_ref{$alias} = $job_dir;
411}
412
413########################################################################################
414#       sub: show_no_info_line
415#      gets: $line, $line_number
416#   returns: $no_info_line
417########################################################################################
418sub show_no_info_line
419{
420   my ($line, $line_number) = @_;
421   my $no_info_line += 1;
422
423   chomp($line);
424
425   print"Ignore line <$line_number>:\n\"$line\"\n\n" if ($debug);
426
427   return $no_info_line;
428}
429
430########################################################################################
431#       sub: get_module_name
432#      gets: $line
433#   returns: $module_name
434########################################################################################
435sub get_module_name
436{
437   my $line = shift;
438   my $module_name = "";
439
440   if ($line =~ /^\w+\s+([\w\.\-]+)\\?/)
441   {
442      $module_name = $1;
443   }
444
445   # set the 'module name' in the data structure tree
446   $XMLTree->setModuleName($module_name);
447
448   return $module_name;
449}
450
451########################################################################################
452#       sub: get_module_dependency_line_infos
453#      gets: $line, $module_name, $line_number
454#   returns: $module_dependency_line_was_read, $info_line_sum
455########################################################################################
456# get the informations about the module dependency line
457# like line 1 of module 'sal' (SRC680/src.m42)
458#    "sa     sal              :                       xml2cmp             NULL"
459#        $module_name   $module_dependency    @module_dependency_names
460sub get_module_dependency_line_infos
461{
462   my ($line, $module_name, $line_number) = @_;
463   my $module_dependency = "";
464   my @module_dependency_names = ();
465   my %dep_modules_and_products = ();
466   my $product = "";
467
468   my $module_dependency_line_was_read = 1;
469   my $info_line_sum = 1;
470
471   if ($debug)
472   {
473      print"\nline number               : <$line_number>\n";
474      print"module-name               : <$module_name>\n";
475   }
476
477   # get the dependencies
478   if ($line =~ /\s+(:+)\s+/)
479   {
480      $module_dependency = $1;
481      print"module-dependency         : <$module_dependency>\n" if ($debug);
482
483      # transform the dependency type to the corresponding tag name
484      if ($module_dependency eq ":")
485      {
486         $module_dependency = "md-simple";
487      }
488      elsif ($module_dependency eq "::")
489      {
490         $module_dependency = "md-always";
491      }
492      elsif ($module_dependency eq ":::")
493      {
494         $module_dependency = "md-force";
495      }
496   }
497
498   # get a list of all depending module names
499   if ($line =~ /:+\s+([\S\s]+)\s+NULL/)
500   {
501      @module_dependency_names = split(/\s+/, $1);
502
503      foreach my $module (@module_dependency_names)
504      {
505         # check whether that there is another product (as "all") of a module
506         if ($module =~ /(\S+):+(\S+)/)
507         {
508            $dep_modules_and_products{$2} = $1;
509         }
510         else
511         {
512            $dep_modules_and_products{$module} = "all";
513         }
514      }
515   }
516
517   # add the dependency module names, the module dependency type and the product to the data structure
518   foreach my $module (sort keys %dep_modules_and_products)
519   {
520      print"module-dependency-name(s) : key <$module>  value <".$dep_modules_and_products{$module}.">\n" if ($debug);
521
522      $XMLTree->addModuleDependencies($module, $module_dependency, $dep_modules_and_products{$module});
523   }
524
525   return ($module_dependency_line_was_read, $info_line_sum);
526}
527
528########################################################################################
529#       sub: get_nmake_line_infos
530#      gets: $line, \%dir_of_alias, \%dir_of_job_platform, $module_name, $line_number
531#   returns: $info_line
532########################################################################################
533# get all infos about the 'nmake' lines
534# e.g. line 8 of module 'sal'
535# "sa  sal\systools\win32\guistdio  nmake  -     n         sa_guistdio     sa_uwinapi.n          NULL"
536#             $job_dir              $job     $job_platform  1.$alias   2.$alias + alias platform
537sub get_nmake_line_infos
538{
539   my ($line, $dir_of_alias_ref, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
540   my $directories_ref = "";
541   my $info_line = 0;
542
543   # get the infos about the 'nmake' lines
544   if ($line =~ /^\w+\s+(\S+)\s+(\w+)\s+\-\s+(\w+)\,?(\S+)?/)
545   {
546      # get the current working directory
547      my $temp_job_dir = $1;
548      my $job_dir = change_job_directory($temp_job_dir);
549
550      # get the job
551      my $job = $2;
552      $job = "make" if ($job eq "nmake");
553
554      # get the job platform of the current job
555      # if it is a 'n' job platform transform it to 'wnt'
556      # available values are: 'wnt', 'unx', 'mac' or 'all'
557      my $job_platform = $3;
558      $job_platform = change_job_platform_name($job_platform);
559
560      # get the first alias in each line
561      my $restriction = $4;
562      my %build_req = ( "$restriction" => "$job_platform") if ($restriction && $job_platform);
563
564
565      # get all aliases (but not the first) in an array
566      my $aliases_ref = get_aliases($line);
567
568      # filter the list of aliases, which has a 'p' job platform
569      # and transform a 'n' ending alias platform to a 'w' ending alias platform
570      filter_aliases($aliases_ref);
571
572      # resolve all aliases (alias[.job platform] => matching directory)
573      $directories_ref = resolve_aliases($aliases_ref, $dir_of_alias_ref,
574                                         $dir_of_job_platform_ref, $module_name, $line_number);
575
576      # count the informative lines
577      $info_line = 1;
578
579      $XMLTree->addJob($job_dir, $job, $job_platform, $directories_ref, \%build_req);
580
581      # show the infos, that we know about each line
582      if ($debug == 1)
583      {
584         show_line_infos($line_number, $job_dir, $job, $job_platform, $restriction, $aliases_ref, $directories_ref);
585      }
586   }
587   return $info_line;
588}
589
590########################################################################################
591#       sub: change_job_platform_name
592#      gets: $job_platform
593#   returns: $job_platform
594########################################################################################
595sub change_job_platform_name
596{
597   my $job_platform = shift;
598
599   $job_platform = "wnt" if($job_platform eq "n" || $job_platform eq "w");
600   $job_platform = "unx" if($job_platform eq "u");
601   $job_platform = "mac" if($job_platform eq "m");
602
603   return $job_platform;
604}
605
606########################################################################################
607#       sub: get_aliases
608#      gets: $_ (current line)
609#   returns: \@aliases
610########################################################################################
611# get all aliases of the line in an array
612sub get_aliases
613{
614   my $line = shift;
615   my @aliases = ();
616
617   # get all aliases in an array (but cut out the first alias)
618   if ($line =~ /\-\s+[\w+\,]+\s+([\S\s]+)\s+NULL$/)
619   {
620      print"\nall job aliases           : <$1>\n" if ($debug);
621
622      @aliases = split /\s+/, $1;
623
624      # we don't need the first alias (it stands for the current job directory)
625      shift @aliases;
626   }
627   return \@aliases;
628}
629
630########################################################################################
631#       sub: filter_aliases
632#      gets: $aliases_ref
633#   returns: -
634########################################################################################
635# filter all aliases, because we only need the 'w', 'u' and 'm' job platform based aliases
636sub filter_aliases
637{
638   my $aliases_ref = shift;
639
640   # get the highest index of the array (number of elements of the array - 1)
641   # also works: my $index = scalar(@$aliases_ref)-1;
642   my $index = $#{@{$aliases_ref}};
643
644   for (; $index >= 0; $index--)
645   {
646      # filter the 'p' job platform based aliases from '@aliases'
647      splice(@$aliases_ref, $index, 1) if ($$aliases_ref[$index] =~ /\.p$/);
648
649      # transform a '.n' ending alias platform to '.w' ending alias platform
650      if ($$aliases_ref[$index] =~ /\.n$/)
651      {
652         $$aliases_ref[$index] =~ s/\.n$/\.w/;
653         splice(@$aliases_ref, $index, 1, $$aliases_ref[$index]);
654      }
655   }
656}
657
658########################################################################################
659#       sub: resolve_aliases
660#      gets: $aliases_ref, $dir_of_alias_ref, $dir_of_job_platform_ref,
661#            $module_name, $line_number
662#   returns: \@directories
663########################################################################################
664# here we get each alias with the matching job directory
665sub resolve_aliases
666{
667   my ($aliases_ref, $dir_of_alias_ref, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
668
669   my @directories = ();
670   my ($alias_platform, $alias, $temp_alias) = "";
671
672   # resolving all directory aliases
673   foreach $temp_alias (@$aliases_ref)
674   {
675      ($alias, $alias_platform) = compare_job_platform_with_alias_platform
676                                  ($temp_alias, $dir_of_job_platform_ref, $module_name, $line_number);
677
678      # does the alias exist?
679      if (exists $$dir_of_alias_ref{$alias})
680      {
681         # then get the matching directory in the array
682         push (@directories, $$dir_of_alias_ref{$alias});
683      }
684      else
685      {
686         add_errorlog_no_directory_of_alias_statement($module_name, $alias, $line_number);
687      }
688   }
689   return \@directories;
690}
691
692########################################################################################
693#       sub: compare_job_platform_with_alias_platform
694#      gets: $alias, $dir_of_job_platform_ref, $module_name, $line_number
695#   returns: $alias
696########################################################################################
697sub compare_job_platform_with_alias_platform
698{
699   my ($alias, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
700
701   my $alias_platform = "";
702
703   # compare the alias platform (with a dot and an ending letter, like "al_alib.u")
704   # with the job platform of the line in which this alias was resolved
705   if ($alias =~ /\.([wum])$/)
706   {
707      $alias_platform = $1;
708
709      # don't memorize the ending dot and letter
710      $alias =~ s/\.\w$//;
711
712      # if the value(= job platform) of the hash or the alias platform has no value
713      # set it to "no valid value"
714      if (!(exists $$dir_of_job_platform_ref{$alias_platform.$alias}))
715      {
716         $$dir_of_job_platform_ref{$alias_platform.$alias} = "no valid value";
717      }
718      $alias_platform = "no valid value" if (!($alias_platform));
719
720      # are the job platform and the alias platform equal?
721      if ($$dir_of_job_platform_ref{$alias_platform.$alias} ne $alias_platform)
722      {
723         add_errorlog_not_equal_platforms_statement
724         ($module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number);
725      }
726   }
727   return ($alias, $alias_platform);
728}
729
730########################################################################################
731#       sub: show_line_infos
732#      gets: $line_number, $job_dir, $job, $job_platform, $restriction,
733#            $aliases_ref, $directories_ref
734#   returns: -
735########################################################################################
736# print the infos about each line
737sub show_line_infos
738{
739   my ($line_number, $job_dir, $job, $job_platform, $restriction, $aliases_ref, $directories_ref) = @_;
740
741   print"line number               : <$line_number>\n";
742   print"job directory             : <$job_dir>\n";
743   print"job                       : <$job>\n";
744   print"job platform              : <$job_platform>\n" if ($job_platform =~ /(w|u|m|all)/);
745   print"restriction               : <$restriction>\n" if ($restriction);
746   print"alias dependencies        : <@$aliases_ref>\n";
747   print"directory dependencies    : <@$directories_ref>\n\n";
748}
749
750########################################################################################
751#       sub: lines_sums_output
752#      gets: $module_name, $line_number, $info_line_sum, $no_info_line_sum
753#   returns: -
754########################################################################################
755sub lines_sums_output
756{
757   # this line variables are for checking that all lines will be read:
758   my ($module_name, $line_number, $info_line_sum, $no_info_line_sum) = @_;
759   my $lines_sum = 0;
760
761   add_errorlog_no_module_name_statement() if (!($module_name));
762
763   # were all lines read? and is the checksum okay?
764   $lines_sum = $info_line_sum + $no_info_line_sum;
765   if ($lines_sum == $line_number)
766   {
767      print"All $line_number line(s) of module <$module_name> were read and checked!\n\n";
768   }
769   else
770   {
771      add_errorlog_different_lines_sums_statement($module_name);
772   }
773
774   print"module: <$module_name>\n".
775        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".
776        "   info line(s) sum    =  $info_line_sum\n".
777        "no-info line(s) sum    =  $no_info_line_sum\n".
778        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".
779        "  total line(s) sum    =  $line_number\n\n\n";
780}
781
782
783############################ ERROR_LOG subroutines #####################################
784
785
786########################################################################################
787#       sub: add_errorlog_invalid_job_platform_statement
788#      gets: $module_name, $platform, $line_number
789#   returns: -
790########################################################################################
791sub add_errorlog_invalid_job_platform_statement
792{
793   my ($module_name, $job_platform, $line_number) = @_;
794
795   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
796                   "The job platform <$job_platform> is not valid.\n\n";
797}
798
799########################################################################################
800#       sub: add_errorlog_not_equal_platforms_statement
801#      gets: $module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number
802#   returns: -
803########################################################################################
804sub add_errorlog_not_equal_platforms_statement
805{
806   my ($module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number) = @_;
807
808   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
809                   "The alias platform <$alias.$alias_platform> is not equal ".
810                   "with the job platform <$$dir_of_job_platform_ref{$alias_platform.$alias}>.\n\n";
811}
812
813########################################################################################
814#       sub: add_errorlog_no_directory_of_alias_statement
815#      gets: $module_name, $alias, $line_number
816#   returns: -
817########################################################################################
818sub add_errorlog_no_directory_of_alias_statement
819{
820   my ($module_name, $alias, $line_number) = @_;
821
822   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
823                   "The directory of the alias <$alias> doesn't exist!\n\n";
824}
825
826########################################################################################
827#       sub: add_errorlog_no_module_name_statement
828#      gets: -
829#   returns: -
830########################################################################################
831sub add_errorlog_no_module_name_statement
832{
833   print ERROR_LOG "Error. No module name found in dir/file <$parse_file>.\n\n";
834}
835
836########################################################################################
837#       sub: add_errorlog_alias_redundancy_statement
838#      gets: $module_name, $alias, $job_platform, $line_number
839#   returns: -
840########################################################################################
841sub add_errorlog_alias_redundancy_statement
842{
843   my ($module_name, $alias, $job_platform, $line_number)= @_;
844
845   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
846                   "The alias <$alias> with the job platform <$job_platform> is redundant.\n\n";
847}
848
849########################################################################################
850#       sub: add_errorlog_unknown_format_statement
851#      gets: $module_name, $line_number
852#   returns: -
853########################################################################################
854sub add_errorlog_unknown_format_statement
855{
856   my ($line, $module_name, $line_number) = @_;
857
858   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.".
859                   "\nUnknown format:\n\"$line\"\n\n";
860}
861
862########################################################################################
863#       sub: add_errorlog_different_lines_sums_statement
864#      gets: $module_name
865#   returns: -
866########################################################################################
867sub add_errorlog_different_lines_sums_statement
868{
869   my $module_name = shift;
870
871   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file>.\n".
872                   "The sums of all info and no-info lines are not correct!\n\n";
873}
874
875########################################################################################
876#       sub: add_errorlog_no_buildlst_file_found_statement
877#      gets: $parse_file
878#   returns: -
879########################################################################################
880sub add_errorlog_no_buildlst_file_found_statement
881{
882   my $parse_file = shift;
883
884   print ERROR_LOG "Error in command line argument <$parse_file>.\n".
885                   "File 'build.lst' not found!\n";
886}
887
888############################# end of the subroutines ###################################
889