Subversion Repositories DevTools

Rev

Rev 281 | Rev 331 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 281 Rev 323
Line 38... Line 38...
38
my $opt_xml;
38
my $opt_xml;
39
my $opt_oldproject;
39
my $opt_oldproject;
40
my $opt_newproject;
40
my $opt_newproject;
41
my $opt_noconfig;
41
my $opt_noconfig;
42
my $opt_validate;
42
my $opt_validate;
-
 
43
my $opt_mode = 0;
-
 
44
my $opt_work_file = 'auto.new';
43
 
45
 
44
#
46
#
45
#   Globals
47
#   Globals
46
#
48
#
47
my %component =  ();
49
my %component =  ();
Line 73... Line 75...
73
                "errors"        => \$opt_errors,        # flag
75
                "errors"        => \$opt_errors,        # flag
74
                "xml!"          => \$opt_xml,           # flag
76
                "xml!"          => \$opt_xml,           # flag
75
                "oldproject=s"  => \$opt_oldproject,    # string
77
                "oldproject=s"  => \$opt_oldproject,    # string
76
                "newproject=s"  => \$opt_newproject,    # string
78
                "newproject=s"  => \$opt_newproject,    # string
77
                "validate"      => \$opt_validate,      # flag
79
                "validate"      => \$opt_validate,      # flag
-
 
80
                "mode=s"        => \$opt_mode,          # Flag
78
                );
81
                );
79
 
82
 
80
#
83
#
81
#   Process help and manual options
84
#   Process help and manual options
82
#
85
#
Line 97... Line 100...
97
    if ( $opt_datafile && $opt_noconfig );
100
    if ( $opt_datafile && $opt_noconfig );
98
 
101
 
99
Error ("No configuration file specified")
102
Error ("No configuration file specified")
100
    unless ( $opt_datafile || $opt_newproject || $opt_noconfig );
103
    unless ( $opt_datafile || $opt_newproject || $opt_noconfig );
101
 
104
 
102
Error ("Input and output file are the same" )
105
Warning ("Input and output file are the same" )
103
    if ( $opt_infile eq $opt_ofile );
106
    if ( ! $opt_mode && $opt_infile eq $opt_ofile );
104
 
107
 
105
#
108
#
106
#   Auto detect XML files
109
#   Auto detect XML files
107
#
110
#
108
$opt_xml = 1
111
$opt_xml = 1
109
    if ( $opt_infile =~ m~\.xml$~i );
112
    if ( $opt_infile =~ m~\.xml$~i );
110
 
113
 
111
#
114
#
-
 
115
#   When opt_mode is invoked, allow reuse auto.xxx files
-
 
116
#   if they are present. The user may be changing the file
-
 
117
#
-
 
118
if ( $opt_mode )
-
 
119
{
-
 
120
    #
-
 
121
    #   Use later of build.pl or auto.pl
-
 
122
    #
-
 
123
    my $bstamp = -M "build.pl";
-
 
124
    my $astamp = -M "auto.pl";
-
 
125
    $opt_infile = 'auto.pl'
-
 
126
        if ( $astamp && $astamp < $bstamp );
-
 
127
 
-
 
128
    $opt_infile = 'auto.xml' if ( -f 'auto.xml' );
-
 
129
    Message ("Using: $opt_infile");
-
 
130
}
-
 
131
 
-
 
132
#
112
#   Process config and input files
133
#   Process config and input files
113
#
134
#
114
read_config_file()          if $opt_datafile;
135
read_config_file()          if $opt_datafile;
115
process_build_file()        unless( $opt_xml);
136
process_build_file()        unless( $opt_xml);
116
process_xml_build_file()    if ( $opt_xml);
137
process_xml_build_file()    if ( $opt_xml);
Line 119... Line 140...
119
    if ( $ opt_newproject );
140
    if ( $ opt_newproject );
120
 
141
 
121
Warning("No project extensions changed")
142
Warning("No project extensions changed")
122
    if ( !$suffix_count && $opt_newproject);
143
    if ( !$suffix_count && $opt_newproject);
123
 
144
 
-
 
145
#
-
 
146
#   Report errors or warnings for packages that are not in the configuration
-
 
147
#   File. These will not have been updated inthe output file.
-
 
148
#
124
if ( @pkg_errors || @pkg_errors_val)
149
if ( @pkg_errors || @pkg_errors_val)
125
{
150
{
-
 
151
    my $report = $opt_mode ? \&Warning : \&ReportError;
126
    ReportError ("Errors encountered in the following packages:");
152
    $report->("Errors encountered in the following packages:");
127
    ReportError ( @pkg_errors );
153
    $report->( @pkg_errors );
128
    ReportError ( @pkg_errors_val );
154
    $report->( @pkg_errors_val );
129
    ReportError ( "Package Names and Versions in build files may not match Release Manager");
155
    $report->( "Package Names and Versions in build files may not match Release Manager");
130
}
156
}
131
 
157
 
132
ReportError("Unused packages found: $not_use_count")
158
ReportError("Unused packages found: $not_use_count")
133
    if ( $opt_errors && $not_use_count && $opt_datafile);
159
    if ( $opt_errors && $not_use_count && $opt_datafile);
134
 
160
 
Line 189... Line 215...
189
            my $ver = $2;
215
            my $ver = $2;
190
 
216
 
191
#print "Got Archive stuff: $_ : $comp, $ver\n";
217
#print "Got Archive stuff: $_ : $comp, $ver\n";
192
 
218
 
193
            Error "Version not specified for: $comp" unless ( $ver );
219
            Error "Version not specified for: $comp" unless ( $ver );
194
            Warning "Suspect version format for: $comp ($ver)" unless ( $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
220
            Warning "Suspect version format for: $comp ($ver)" unless ( $opt_mode || $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
195
 
221
 
196
            save_package( $comp, $ver );
222
            save_package( $comp, $ver );
197
            next;
223
            next;
198
        }
224
        }
199
        
225
        
Line 203... Line 229...
203
        #   Process line as
229
        #   Process line as
204
        #       component version
230
        #       component version
205
        #
231
        #
206
        my ( $comp, $ver, $opt ) = split( /[\s,]+/, $_, 3);
232
        my ( $comp, $ver, $opt ) = split( /[\s,]+/, $_, 3);
207
        Error "Version not specified for: $comp" unless ( $ver );
233
        Error "Version not specified for: $comp" unless ( $ver );
208
        Warning "Suspect version format for: $comp ($ver)" unless ( $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
234
        Warning "Suspect version format for: $comp ($ver)" unless ( $opt_mode || $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
209
        save_package( $comp, $ver );
235
        save_package( $comp, $ver );
210
    }
236
    }
211
    close FILE;
237
    close FILE;
212
 
238
 
213
#    DebugDumpData ("component", \%component );
239
#    DebugDumpData ("component", \%component );
Line 233... Line 259...
233
 
259
 
234
    #
260
    #
235
    #   Always display diffs
261
    #   Always display diffs
236
    #   Display all if verbose
262
    #   Display all if verbose
237
    #
263
    #
238
    if ( $diff || $opt_verbose  )
264
    if ( $diff || $opt_verbose || $opt_mode  )
239
    {
265
    {
240
        $title = 'Package' unless ( $title );
266
        $title = 'Package' unless ( $title );
241
        Message( sprintf("%-8s: %-${max_pkglen}s, Version: %-15s %1.1s-> %-15s\n", $title, $name ,$version, $diff, $new_version));
267
        Message( sprintf("%-8s: %-${max_pkglen}s, Version: %-15s %1.1s-> %-15s\n", $title, $name ,$version, $diff, $new_version));
242
    }
268
    }
243
}
269
}
244
 
270
 
245
#-------------------------------------------------------------------------------
271
#-------------------------------------------------------------------------------
246
# Function        : process_build_file
272
# Function        : process_build_file
247
#
273
#
248
# Description     : Rewrite one file
274
# Description     : Rewrite one file
249
#                   build.pl -> build-new.pl
275
#                   build.pl -> auto.pl
250
#
276
#
251
# Inputs          :
277
# Inputs          :
252
#
278
#
253
# Returns         :
279
# Returns         :
254
#
280
#
Line 257... Line 283...
257
    Verbose ("Processing build file: $opt_infile");
283
    Verbose ("Processing build file: $opt_infile");
258
 
284
 
259
    #
285
    #
260
    #   Unlink any OLD output file
286
    #   Unlink any OLD output file
261
    #
287
    #
262
    unlink $opt_ofile;
288
    unlink $opt_work_file;
263
 
289
 
264
    #
290
    #
265
    #   Open the input and output files
291
    #   Open the input and output files
266
    #
292
    #
267
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot open $opt_infile" );
293
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot read from $opt_infile", $! );
268
    open ( OUTFILE, ">$opt_ofile" ) || Error( "Cannot create $opt_ofile" );
294
    open ( OUTFILE, ">$opt_work_file" ) || Error( "Cannot create $opt_work_file", $! );
269
 
295
 
270
    my $build_info;
296
    my $build_info;
271
 
297
 
272
    my $release_name;
298
    my $release_name;
273
    my $release_version;
299
    my $release_version;
Line 277... Line 303...
277
        next if ( $opt_noconfig );       # Nothing to do
303
        next if ( $opt_noconfig );       # Nothing to do
278
        next if ( m~^\s*#~ );            # Skip comments
304
        next if ( m~^\s*#~ );            # Skip comments
279
        #
305
        #
280
        #   Process BuildName
306
        #   Process BuildName
281
        #
307
        #
282
        if ( m~\s*BuildName[\s\(]~ )
308
        if ( m~\s*BuildName[\s\(]~  )
283
        {
309
        {
284
            #   Build names come in many flavours
310
            #   Build names come in many flavours
285
            #   Must support a number of different formats
311
            #   Must support a number of different formats
286
            #       "name nn.nn.nn prj"
312
            #       "name nn.nn.nn prj"
287
            #       "name nn.nn.nn.prj"
313
            #       "name nn.nn.nn.prj"
Line 292... Line 318...
292
            #       "name", "nn.nn.nn.prj"
318
            #       "name", "nn.nn.nn.prj"
293
            #
319
            #
294
            m~\(\s*(.*?)\s*\)~;
320
            m~\(\s*(.*?)\s*\)~;
295
            my @args = split /\s*,\s*/, $1;
321
            my @args = split /\s*,\s*/, $1;
296
            $build_info = parseBuildName( @args );
322
            $build_info = parseBuildName( @args );
-
 
323
            my $new_ver;
297
 
324
 
-
 
325
            #
-
 
326
            #   In Special Mode, don't change the version of this package
-
 
327
            #   Assume that the user has fiddled with it.
-
 
328
            #
-
 
329
            if ( $opt_mode ) {
-
 
330
                $new_ver = $build_info->{BUILDVERSION};
-
 
331
            } else {
298
            my $new_ver = get_package ( $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION} );
332
                $new_ver = get_package ( $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION} );
-
 
333
            }
299
            my $build_args = genBuildName( $build_info, $new_ver );
334
            my $build_args = genBuildName( $build_info, $new_ver );
300
 
335
 
301
            #
336
            #
302
            #   Rewrite the body of the directive
337
            #   Rewrite the body of the directive
303
            #
338
            #
304
            s~\(\s*(.*?)\s*\)~( $build_args )~;
339
            s~\(\s*(.*?)\s*\)~( $build_args )~;
305
            print_update( '', $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION}, $new_ver );
340
            print_update( 'Name', $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION}, $new_ver );
306
 
341
 
307
        }
342
        }
308
 
343
 
309
        #
344
        #
310
        #   Process BuildPreviousVersion
345
        #   Process BuildPreviousVersion
311
        #   Save the current version information in this directive
346
        #   Save the current version information in this directive
312
        #
347
        #
313
        if ( m/^\s*BuildPreviousVersion/ )
348
        if ( m/^\s*BuildPreviousVersion/ && ! $opt_mode )
314
        {
349
        {
315
            Error ("BuildPreviousVersion directive before BuildName") unless ( $build_info );
350
            Error ("BuildPreviousVersion directive before BuildName") unless ( $build_info );
316
            m/['"](.*?)['"]/;
351
            m/['"](.*?)['"]/;
317
            my $prev = $1;
352
            my $prev = $1;
318
            my $new_ver = $opt_validate ? $prev : $build_info->{BUILDVERSION};
353
            my $new_ver = $opt_validate ? $prev : $build_info->{BUILDVERSION};
Line 346... Line 381...
346
    #
381
    #
347
    #   Cleanup
382
    #   Cleanup
348
    #
383
    #
349
    close INFILE;
384
    close INFILE;
350
    close OUTFILE;
385
    close OUTFILE;
-
 
386
    unlink $opt_ofile;
-
 
387
    rename $opt_work_file ,$opt_ofile;
351
    display_unused();
388
    display_unused();
352
}
389
}
353
 
390
 
354
#-------------------------------------------------------------------------------
391
#-------------------------------------------------------------------------------
355
# Function        : process_xml_build_file
392
# Function        : process_xml_build_file
Line 382... Line 419...
382
    Verbose ("$opt_infile");
419
    Verbose ("$opt_infile");
383
 
420
 
384
    #
421
    #
385
    #   Unlink any OLD output file
422
    #   Unlink any OLD output file
386
    #
423
    #
387
    unlink $opt_ofile;
424
    unlink $opt_work_file;
388
 
425
 
389
    #
426
    #
390
    #   Open the input and output files
427
    #   Open the input and output files
391
    #
428
    #
392
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot open $opt_infile" );
429
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot read from $opt_infile", $! );
393
    open ( OUTFILE, ">$opt_ofile" ) || Error( "Cannot create $opt_ofile" );
430
    open ( OUTFILE, ">$opt_work_file" ) || Error( "Cannot create $opt_work_file", $! );
394
 
431
 
395
    my $release_name;
432
    my $release_name;
396
    my $release_version;
433
    my $release_version;
397
 
434
 
398
    while ( <INFILE> )
435
    while ( <INFILE> )
Line 444... Line 481...
444
                Error ("Value attribute not found in $name 'property'");
481
                Error ("Value attribute not found in $name 'property'");
445
            }
482
            }
446
            Verbose2 ("Property: $name, Value: $value");
483
            Verbose2 ("Property: $name, Value: $value");
447
            
484
            
448
            #
485
            #
449
            #   Examine th property name
486
            #   Examine the property name
450
            #   Some of the them are special, others will be package names
487
            #   Some of the them are special, others will be package names
451
            #
488
            #
452
            if ( $name eq 'packagename' )
489
            if ( $name eq 'packagename' )
453
            {
490
            {
454
                $release_name = $value;
491
                $release_name = $value;
Line 463... Line 500...
463
                #
500
                #
464
                Error ("packageversion before packagename") unless ( $release_name );
501
                Error ("packageversion before packagename") unless ( $release_name );
465
 
502
 
466
                my $new_ver = get_package ( $release_name, $release_version );
503
                my $new_ver = get_package ( $release_name, $release_version );
467
                s~(.*)value="([^"]*)"~$1value=\"$new_ver\"~;
504
                s~(.*)value="([^"]*)"~$1value=\"$new_ver\"~;
468
                print_update( '', $release_name ,$release_version, $new_ver );
505
                print_update( 'Name', $release_name ,$release_version, $new_ver );
469
            }
506
            }
470
            elsif ( defined $fields{$name} )
507
            elsif ( defined $fields{$name} )
471
            {
508
            {
472
                #
509
                #
473
                #   Use tagged values in preference to packages
510
                #   Use tagged values in preference to packages
Line 557... Line 594...
557
    #
594
    #
558
    #   Cleanup
595
    #   Cleanup
559
    #
596
    #
560
    close INFILE;
597
    close INFILE;
561
    close OUTFILE;
598
    close OUTFILE;
-
 
599
    unlink $opt_ofile;
-
 
600
    rename $opt_work_file ,$opt_ofile;
562
    display_unused();
601
    display_unused();
563
}
602
}
564
 
603
 
565
#-------------------------------------------------------------------------------
604
#-------------------------------------------------------------------------------
566
# Function        : display_unused
605
# Function        : display_unused
Line 571... Line 610...
571
#
610
#
572
# Returns         :
611
# Returns         :
573
#
612
#
574
sub display_unused
613
sub display_unused
575
{
614
{
-
 
615
    return
-
 
616
        if ( $opt_mode );
-
 
617
 
576
    foreach my $comp ( sort keys %component_use )
618
    foreach my $comp ( sort keys %component_use )
577
    {
619
    {
578
        foreach my $suf ( keys %{$component_use{$comp}} )
620
        foreach my $suf ( keys %{$component_use{$comp}} )
579
        {
621
        {
580
            my $ver = get_version( $comp, $suf );
622
            my $ver = get_version( $comp, $suf );
Line 856... Line 898...
856
    -infile xxx         - Input file (build.pl)
898
    -infile xxx         - Input file (build.pl)
857
    -outfile xxx        - Output file (auto.pl)
899
    -outfile xxx        - Output file (auto.pl)
858
    -errors             - Generate errors for unused config items
900
    -errors             - Generate errors for unused config items
859
    -xml                - Process a build.xml file
901
    -xml                - Process a build.xml file
860
    -validate           - Validate dependencies only
902
    -validate           - Validate dependencies only
-
 
903
    -mode=nn            - Special operational modes
861
 
904
 
862
=head1 OPTIONS
905
=head1 OPTIONS
863
 
906
 
864
=over 8
907
=over 8
865
 
908
 
Line 928... Line 971...
928
=item B<-validate>
971
=item B<-validate>
929
 
972
 
930
This option will validate the build files against the configuration file. This
973
This option will validate the build files against the configuration file. This
931
option is used by build tools to validate dependency information.
974
option is used by build tools to validate dependency information.
932
 
975
 
-
 
976
=item B<-mode=n>
-
 
977
 
-
 
978
This option is used internally, by JATS, to indicate that the utility is being
-
 
979
used to perform controlled rewrite operations. Currently only a value of 1 is
-
 
980
supported. This will:
-
 
981
 
-
 
982
=over 8
-
 
983
 
-
 
984
* Suppress warnings about unused packages. The config file may is expected to contain
-
 
985
  many more packages than required by the rewrite.
-
 
986
 
-
 
987
* Suppress warnings about badly formatted config entries.
-
 
988
 
-
 
989
* Will reuse an auto.pl or auto.xml file if its present. Allows user changes
-
 
990
to be made to made to working copies of the build files.
-
 
991
 
-
 
992
* Will use build.pl as a template if it is newer than auto.pl. Allows user
-
 
993
changes to be made to build.pl.
-
 
994
 
-
 
995
* Will not modify the packages own version number, or the previous version number.
-
 
996
Only the package dependencies will be modified.
-
 
997
 
-
 
998
* Package-Version that are not in the Release will not be treated as an error.
-
 
999
 
-
 
1000
=back
-
 
1001
 
933
=back
1002
=back
934
 
1003
 
935
=head1 DESCRIPTION
1004
=head1 DESCRIPTION
936
 
1005
 
937
This utility is used within the automated build system to rewrite build files
1006
This utility is used within the automated build system to rewrite build files