| 392 |
dpurdie |
1 |
########################################################################
|
| 5709 |
dpurdie |
2 |
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
|
| 392 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : jats.sh
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : n/a
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : JATS Make Time Support. Command File Generation
|
|
|
10 |
# This package contains useful functions for the generation of
|
|
|
11 |
# runtime command files. It extends the binary executable "cmdfile"
|
|
|
12 |
# but it is intended to:
|
|
|
13 |
# Be better documented
|
|
|
14 |
# Have better argument parsing
|
|
|
15 |
# Not require compilation
|
|
|
16 |
#
|
|
|
17 |
# The functions are designed to be invoked as:
|
|
|
18 |
# $(GBE_PERL) -Mjats_cmdfile -- <args>+
|
|
|
19 |
#
|
|
|
20 |
# Notes : Keep this package simple
|
|
|
21 |
# Don't use all the JATS infrastructure.
|
|
|
22 |
#
|
|
|
23 |
#......................................................................#
|
|
|
24 |
|
|
|
25 |
require 5.006_001;
|
|
|
26 |
use strict;
|
|
|
27 |
use warnings;
|
|
|
28 |
|
|
|
29 |
package jats_cmdfile;
|
|
|
30 |
use Getopt::Long qw(:config bundling require_order); # Stop on non-option
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
################################################################################
|
|
|
34 |
# Globals
|
|
|
35 |
# Parsed Options
|
|
|
36 |
#
|
|
|
37 |
my $opt_help = 0;
|
|
|
38 |
my $opt_verbose = 0;
|
|
|
39 |
my $opt_debug = 0;
|
|
|
40 |
my $opt_trimws = 0;
|
|
|
41 |
my $opt_dos = 0;
|
|
|
42 |
my $opt_whitespace = 0;
|
|
|
43 |
my $opt_output = '';
|
|
|
44 |
my @opt_libs;
|
|
|
45 |
|
|
|
46 |
#-------------------------------------------------------------------------------
|
|
|
47 |
# Parse the user options
|
|
|
48 |
# GetOptions has been configured so that it will stop parsing on the first
|
|
|
49 |
# non-options. This allows the command syntax to the script to have options
|
|
|
50 |
# that are directed to this script before the command keyword, and command
|
|
|
51 |
# options to the subcommand to be after the keyword.
|
|
|
52 |
#
|
|
|
53 |
my $result = GetOptions (
|
|
|
54 |
"help+" => \$opt_help,
|
|
|
55 |
"manual" => sub{ $opt_help = 3},
|
|
|
56 |
"verbose|v+" => \$opt_verbose,
|
|
|
57 |
"debug+" => \$opt_debug,
|
|
|
58 |
"w" => \$opt_trimws,
|
|
|
59 |
"k" => \$opt_dos,
|
|
|
60 |
"W=i" => \$opt_whitespace,
|
|
|
61 |
"o=s" => \$opt_output,
|
|
|
62 |
"lib=s" => \@opt_libs,
|
|
|
63 |
);
|
|
|
64 |
|
|
|
65 |
die "Bad GetOptions\n" unless ( $result );
|
|
|
66 |
|
|
|
67 |
print "opt_help: $opt_help\n";
|
|
|
68 |
print "opt_trimsw: $opt_trimws\n";
|
|
|
69 |
print "opt_dos: $opt_dos\n";
|
|
|
70 |
print "opt_whitespace: $opt_whitespace\n";
|
|
|
71 |
print "opt_output: $opt_output\n";
|
|
|
72 |
print "opt_libs: @opt_libs\n";
|
|
|
73 |
|
|
|
74 |
print "@ARGV\n";
|
|
|
75 |
print "-------------------------\n";
|
|
|
76 |
|
|
|
77 |
#
|
|
|
78 |
# process the remaininf command line arguments
|
|
|
79 |
# Supported commands are:
|
|
|
80 |
# @(vlib2,System.dll,LIB)"
|
|
|
81 |
#
|
|
|
82 |
#
|
|
|
83 |
foreach my $arg ( @ARGV )
|
|
|
84 |
{
|
|
|
85 |
while ( $arg =~ m/@\((.+),(.+),(.+)\)/ )
|
|
|
86 |
{
|
|
|
87 |
my $mb = $-[0]; # Match begin offset
|
|
|
88 |
my $me = $+[0]; # Match end
|
|
|
89 |
my $cmd = $1;
|
|
|
90 |
my $name = $2;
|
|
|
91 |
my $envvar = $3;
|
|
|
92 |
my $fn = 'zzzz';
|
|
|
93 |
|
|
|
94 |
#
|
|
|
95 |
# Locate a library file in a specified path
|
|
|
96 |
#
|
|
|
97 |
if ( $cmd eq 'vlib2' )
|
|
|
98 |
{
|
|
|
99 |
print "Name: $name\n";
|
|
|
100 |
print "Var: $envvar\n";
|
|
|
101 |
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
#
|
|
|
105 |
# Replace the text in the argument string
|
|
|
106 |
#
|
|
|
107 |
$arg = substr( $arg, 0, $mb ) . $fn . substr( $arg, $me );
|
|
|
108 |
}
|
|
|
109 |
$arg =~ s~\\n\s+~\n~g;
|
|
|
110 |
print "$arg\n";
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
1;
|