Subversion Repositories DevTools

Rev

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

########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : jats.sh
# Module type   : Makefile system
# Compiler(s)   : n/a
# Environment(s): jats
#
# Description   : JATS Make Time Support. Command File Generation
#                 This package contains useful functions for the generation of
#                 runtime command files. It extends the binary executable "cmdfile"
#                 but it is intended to:
#                       Be better documented
#                       Have better argument parsing
#                       Not require compilation
#
#                 The functions are designed to be invoked as:
#                   $(GBE_PERL) -Mjats_cmdfile -- <args>+
#
#  Notes        :   Keep this package simple
#                   Don't use all the JATS infrastructure.
#
#......................................................................#

require 5.006_001;
use strict;
use warnings;

package jats_cmdfile;
use Getopt::Long qw(:config bundling require_order);     # Stop on non-option


################################################################################
#   Globals
#   Parsed Options
#
my $opt_help = 0;
my $opt_verbose = 0;
my $opt_debug = 0;
my $opt_trimws = 0;
my $opt_dos = 0;
my $opt_whitespace = 0;
my $opt_output = '';
my @opt_libs;

#-------------------------------------------------------------------------------
#   Parse the user options
#   GetOptions has been configured so that it will stop parsing on the first
#   non-options. This allows the command syntax to the script to have options
#   that are directed to this script before the command keyword, and command
#   options to the subcommand to be after the keyword.
#
my $result = GetOptions (
            "help+"             => \$opt_help,
            "manual"            => sub{ $opt_help = 3},
            "verbose|v+"        => \$opt_verbose,
            "debug+"            => \$opt_debug,
            "w"                 => \$opt_trimws,
            "k"                 => \$opt_dos,
            "W=i"                => \$opt_whitespace,
            "o=s"               => \$opt_output,
            "lib=s"             => \@opt_libs,
            );

die "Bad GetOptions\n" unless ( $result );

print "opt_help: $opt_help\n";
print "opt_trimsw: $opt_trimws\n";
print "opt_dos: $opt_dos\n";
print "opt_whitespace: $opt_whitespace\n";
print "opt_output: $opt_output\n";
print "opt_libs: @opt_libs\n";

print "@ARGV\n";
print "-------------------------\n";

#
#   process the remaininf command line arguments
#   Supported commands are:
#       @(vlib2,System.dll,LIB)"
#
#
foreach my $arg ( @ARGV )
{
        while ( $arg =~ m/@\((.+),(.+),(.+)\)/ )
        {
            my $mb = $-[0];                     # Match begin offset
            my $me = $+[0];                     # Match end
            my $cmd = $1;
            my $name = $2;
            my $envvar = $3;
            my $fn = 'zzzz';

            #
            #   Locate a library file in a specified path
            #
            if ( $cmd eq 'vlib2' )
            {
                print "Name: $name\n";
                print "Var: $envvar\n";

            }

            #
            #   Replace the text in the argument string
            #
            $arg = substr( $arg, 0, $mb ) . $fn . substr( $arg, $me );
        }
        $arg =~ s~\\n\s+~\n~g;
        print "$arg\n";
}

1;