Subversion Repositories DevTools

Rev

Rev 7296 | Blame | Compare with Previous | Last modification | View Log | RSS feed

########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : antBuildInfo.pl
# Module type   : JATS Utility
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description   : This utity is used by the buld system
#                 Its fuction is to mirror the 'jats build buildinfo' operation
#                 for the (old) ANT based build system.
#
# Usage         : See POD at the end of this file
#
#......................................................................#

require 5.008_002;
use strict;
use warnings;

use Pod::Usage;
use Getopt::Long;

use JatsError;
use JatsEnv;
use ConfigurationFile;

my $VERSION = '1.0';
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
my $opt_help = 0;
my $opt_manual = 0;
my $opt_buildInfoFile = 'BuildInfo.properties';
my $opt_java = '1.4';



#-------------------------------------------------------------------------------
# Function        : Mainline Entry Point
#
# Description     :
#
# Inputs          :
#
my $result = GetOptions (
                "help+"         => \$opt_help,              # flag, multiple use allowed
                "manual|man"    => \$opt_manual,            # flag
                "verbose:+"     => \$opt_verbose,           # flag, multiple use allowed
                "java=s"        => \$opt_java,
                "buildinfo:s"   => \$opt_buildInfoFile,
                );

                #
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
                #

#
#   Process help and manual options
#
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
pod2usage(-verbose => 1) if ($opt_help == 2 );
pod2usage(-verbose => 2) if ($opt_manual || ($opt_help > 2));
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV >= 0 );

#
#   Configure the error reporting process now that we have the user options
#
ErrorConfig( 'name'    =>'ANTBUILDINFO',
             'verbose' => $opt_verbose,
            );

EnvImportOptional ( 'GBE_BUILDFILTER' );            # optional BUILD filter       
generateBuildInfo();
exit 0;


#-------------------------------------------------------------------------------
# Function        : generateBuildInfo 
#
# Description     : Using in BuildInfo mode to save the required information
#                   See function of the same name in buildlib.pl
#
#                   In BuildInfo mode we have all the data that we need
#                   Save it into a file for the build system and then exit the build process
#                   We do not need to do any further work at this point in time
#
# Inputs          : Globals 
#
# Returns         : This function does not return
#                   It will exit as there is no more work to be done
#                   
#                   Will generate a JAVA properties file with BuildInfo required by the
#                   Build System.
#
sub generateBuildInfo
{
    Message ("Generate BuildInfo Data: ". $opt_buildInfoFile);
    my @propLines = ();

    my $fh = ConfigurationFile::New( $opt_buildInfoFile, '--Type=Properties' );
    $fh->HeaderSimple( "antBuildinfo (Version $VERSION)", "BuildInfo properties" );

    # Build style
    push @propLines, "buildstyle = ANTS";

    # Current Build Filter
    push @propLines, "buildfilter = " . join(',', sort split(' ', $::GBE_BUILDFILTER));

    # All platforms that the package can be built for.
    #   Limited to JAVA
    push @propLines, "platforms = " . 'JAVA';

    # All platforms that the package will be built for with the current build filter
    #   Will be set to JAVA.
    #   The ANT builds will build on a specified machine architecture independently of where
    #   the existence of a JAVA entry in the BUILDFILTER
    push @propLines, "build.platforms = " . 'JAVA';

    # Platforms that have been specifically excluded from the build
    push @propLines, "excluded.platforms = ";

    # Platforms not known to JATS
    # Only works in ABT mode. Errors will be detected before this
    push @propLines, "unknown.platforms = ";
    
    # Toolset build information
    # NONE

    # Indication of production and debug builds
    # JAVA - Assume a production build
    push @propLines, "prod.platforms = " . 'JAVA';
    push @propLines, "debug.platforms = ";

    # JAVA version specified
    push @propLines, "java.version = " . $opt_java;

    $fh->WriteLn(@propLines);
    $fh->Close();

    # Display for user gratification (and build system logging)
    Information($opt_buildInfoFile,@propLines);
    exit 0;
}

#-------------------------------------------------------------------------------
#   Documentation
#

=pod

=for htmltoc    SYSUTIL::

=head1 NAME

antBuildinfo - Generate a BuildInfo file for ant builds

=head1 SYNOPSIS

jats etool antBuildInfo [options]

 Options:
    -help              - brief help message
    -help -help        - Detailed help message
    -man               - Full documentation
    -verbose[=n]       - Verbose operation
    -java=version      - Alters java version used (1.4, 1.5, 1.6)
    -buildinfo=path    - Specify name of the buildinfo file

=head1 OPTIONS

=over 8

=item B<-help>

Print a brief help message and exits.

=item B<-help -help>

Print a detailed help message with an explanation for each option.

=item B<-man>

Prints the manual page and exits.

=item B<-verbose[=n]>

This option will increase the level of verbosity of the command.

If an argument is provided, then it will be used to set the level, otherwise the
existing level will be incremented. This option may be specified multiple times.

=item B<-java=version>

This option will override the default java version used by the ant builds and
passed to the underlying programs.

=item B<-buildinfo>

This option will specify the path of a file to write the build information. 
The dafault value is 'BuildInfo.properties'.

=back

=head1 DESCRIPTION

This program will a BuildInfi.properties file as used by the build system. It is only used when 
building JANTs style builds and should produce a file similar t that created by 
the 'jats build buildinfo' command.

=head1 EXAMPLE

=head2 Generation

 jats etool antBuildInfo.pl -java=1.5

This command will generate a BuildInfo.properties file.

=cut