Subversion Repositories DevTools

Rev

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

Rev 255 Rev 263
Line 1... Line -...
1
#! perl
-
 
2
########################################################################
1
########################################################################
3
# Copyright ( C ) 2004 ERG Limited, All rights reserved
2
# Copyright ( C ) 2008 ERG Limited, All rights reserved
4
#
3
#
5
# Module name   : jats.sh
4
# Module name   : jats_rewrite.pl
6
# Module type   : Makefile system
5
# Module type   : JATS Utility
7
# Compiler(s)   : n/a
6
# Compiler(s)   : Perl
8
# Environment(s): jats
7
# Environment(s): jats
9
#
8
#
10
# Description   : Rewrite a build.pl file
9
# Description   : Rewrite a build.pl file
11
#                 Use an external configuration file to provide a common
10
#                 Use an external configuration file to provide a common
12
#                 source of configuration information
11
#                 source of configuration information
13
#
12
#
14
# Usage:
13
# Usage         : See POD
15
#
14
#
16
#......................................................................#
15
#......................................................................#
17
 
16
 
18
require 5.006_001;
17
require 5.006_001;
19
use strict;
18
use strict;
Line 27... Line 26...
27
 
26
 
28
################################################################################
27
################################################################################
29
#   Option variables
28
#   Option variables
30
#
29
#
31
 
30
 
32
my $VERSION = "1.2.4";                      # Update this
31
my $VERSION = "1.3.0";                      # Update this
33
my $opt_verbose = 0;
32
my $opt_verbose = 0;
34
my $opt_datafile = "";
33
my $opt_datafile = "";
35
my $opt_ofile  = "auto.pl";
34
my $opt_ofile  = "auto.pl";
36
my $opt_infile = "build.pl";
35
my $opt_infile = "build.pl";
37
my $opt_help = 0;
36
my $opt_help = 0;
38
my $opt_manual;
-
 
39
my $opt_errors = 0;
37
my $opt_errors = 0;
40
my $opt_xml;
38
my $opt_xml;
41
my $opt_oldproject;
39
my $opt_oldproject;
42
my $opt_newproject;
40
my $opt_newproject;
-
 
41
my $opt_noconfig;
43
 
42
 
44
#
43
#
45
#   Globals
44
#   Globals
46
#
45
#
47
my %component =  ();
46
my %component =  ();
Line 58... Line 57...
58
    'releasemanager.releasename' => undef,
57
    'releasemanager.releasename' => undef,
59
    'releasemanager.projectname' => undef,
58
    'releasemanager.projectname' => undef,
60
);
59
);
61
 
60
 
62
my $result = GetOptions (
61
my $result = GetOptions (
63
                "help+"     => \$opt_help,          # flag, multiple use allowed
62
                "help:+"    => \$opt_help,          # flag, multiple use allowed
64
                "manual"    => \$opt_manual,        # flag
63
                "manual:3"  => \$opt_help,          # flag
65
                "verbose+"  => \$opt_verbose,       # flag
64
                "verbose:+"  => \$opt_verbose,      # flag
66
                "config=s"  => \$opt_datafile,      # string
65
                "config=s"  => \$opt_datafile,      # string
-
 
66
                "noconfig"  => \$opt_noconfig,      # flag
67
                "outfile=s" => \$opt_ofile,         # string
67
                "outfile=s" => \$opt_ofile,         # string
68
                "infile=s"  => \$opt_infile,        # string
68
                "infile=s"  => \$opt_infile,        # string
69
                "errors"    => \$opt_errors,        # flag
69
                "errors"    => \$opt_errors,        # flag
70
                "xml!"       => \$opt_xml,          # flag
70
                "xml!"       => \$opt_xml,          # flag
71
                "oldproject=s"  => \$opt_oldproject,
71
                "oldproject=s"  => \$opt_oldproject,
Line 75... Line 75...
75
#
75
#
76
#   Process help and manual options
76
#   Process help and manual options
77
#
77
#
78
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
78
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
79
pod2usage(-verbose => 1)  if ($opt_help == 2 );
79
pod2usage(-verbose => 1)  if ($opt_help == 2 );
80
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
80
pod2usage(-verbose => 2)  if ($opt_help > 2);
81
 
81
 
82
#
82
#
83
#   Configure the error reporting process now that we have the user options
83
#   Configure the error reporting process now that we have the user options
84
#
84
#
85
ErrorConfig( 'name'    =>'REWRITE',
85
ErrorConfig( 'name'    =>'REWRITE',
86
             'verbose' => $opt_verbose );
86
             'verbose' => $opt_verbose );
87
 
87
 
88
Error ("Must specify both Old and New project tags")
88
Error ("Must specify both Old and New project tags")
89
    if ( $opt_newproject xor $opt_oldproject );
89
    if ( $opt_newproject xor $opt_oldproject );
90
 
90
 
-
 
91
Error ("Conflicting options -config=file and -noconfig")
-
 
92
    if ( $opt_datafile && $opt_noconfig );
-
 
93
 
91
Error ("No configuration file specified")
94
Error ("No configuration file specified")
92
    unless ( $opt_datafile || $opt_newproject  );
95
    unless ( $opt_datafile || $opt_newproject || $opt_noconfig );
93
 
96
 
94
Error ("Input and output file are the same" )
97
Error ("Input and output file are the same" )
95
    if ( $opt_infile eq $opt_ofile );
98
    if ( $opt_infile eq $opt_ofile );
96
 
99
 
97
#
100
#
Line 255... Line 258...
255
    my $release_name;
258
    my $release_name;
256
    my $release_version;
259
    my $release_version;
257
 
260
 
258
    while ( <INFILE> )
261
    while ( <INFILE> )
259
    {
262
    {
-
 
263
        next if ( $opt_noconfig );       # Nothing to do
260
        next if ( m~^\s*#~ );            # Skip comments
264
        next if ( m~^\s*#~ );            # Skip comments
261
        #
265
        #
262
        #   Process BuildName
266
        #   Process BuildName
263
        #
267
        #
264
        if ( m~\s*BuildName[\s\(]~ )
268
        if ( m~\s*BuildName[\s\(]~ )
Line 376... Line 380...
376
    my $release_name;
380
    my $release_name;
377
    my $release_version;
381
    my $release_version;
378
 
382
 
379
    while ( <INFILE> )
383
    while ( <INFILE> )
380
    {
384
    {
-
 
385
        next if ( $opt_noconfig );       # Nothing to do
381
        #
386
        #
382
        #   Process "project" statement
387
        #   Process "project" statement
383
        #
388
        #
384
        if ( m~<project~ )
389
        if ( m~<project~ )
385
        {
390
        {
Line 766... Line 771...
766
        #
771
        #
767
        #   Generate two field version as some of the deployment scripts
772
        #   Generate two field version as some of the deployment scripts
768
        #   need this format.
773
        #   need this format.
769
        #
774
        #
770
        push @args, "$build_info->{BUILDNAME_PACKAGE} $new_ver $prj";
775
        push @args, "$build_info->{BUILDNAME_PACKAGE} $new_ver $prj";
771
        push @args, "$new_ver";
-
 
772
    }
776
    }
773
 
777
 
774
    #
778
    #
775
    #   Common arguments
779
    #   Common arguments
776
    #
780
    #
Line 804... Line 808...
804
    -help               - brief help message
808
    -help               - brief help message
805
    -help -help         - Detailed help message
809
    -help -help         - Detailed help message
806
    -man                - Full documentation
810
    -man                - Full documentation
807
    -verbose            - Verbose operation
811
    -verbose            - Verbose operation
808
    -config xxx         - Configuration file. Full file name
812
    -config xxx         - Configuration file. Full file name
-
 
813
    -noconfig           - No configuration file
809
    -oldproject         - Old project extension (optional)
814
    -oldproject         - Old project extension (optional)
810
    -newproject         - New project extension (optional)
815
    -newproject         - New project extension (optional)
811
    -infile xxx         - Input file (build.pl)
816
    -infile xxx         - Input file (build.pl)
812
    -outfile xxx        - Output file (auto.pl)
817
    -outfile xxx        - Output file (auto.pl)
813
    -errors             - Generate errors for unused config items
818
    -errors             - Generate errors for unused config items
Line 839... Line 844...
839
transformation between of version numbers. The format of the config file is
844
transformation between of version numbers. The format of the config file is
840
described later.
845
described later.
841
 
846
 
842
The option is not required if -newproject and -oldproject are specified
847
The option is not required if -newproject and -oldproject are specified
843
 
848
 
-
 
849
=item B<-noconfig>
-
 
850
 
-
 
851
This option indiocates that no config file is present and that the output file
-
 
852
is to be created without reference to the configuration.
-
 
853
 
844
=item B<-oldproject=xxx>
854
=item B<-oldproject=xxx>
845
 
855
 
846
This option, in conjunction with B<-oldproject=xxx> allows the project
856
This option, in conjunction with B<-oldproject=xxx> allows the project
847
extensions to be modified. ie: .syd projects can be converted into .bej
857
extensions to be modified. ie: .syd projects can be converted into .bej
848
projects.
858
projects.