-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsigRun.pl
More file actions
executable file
·142 lines (98 loc) · 4.42 KB
/
sigRun.pl
File metadata and controls
executable file
·142 lines (98 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env perl
# This is based on work that is in the public domain
# and modified by Marc Boudreau
use strict;
use warnings;
use File::Temp qw/ tempfile /;
use File::Basename;
use Getopt::Long ();
use Pod::Usage;
my $perlFilename;
my $help;
my $runDebugger;
my $useDDS;
my $useDDD;
my $showCode;
my $makeCode;
my $noSolutions;
my $noVariables;
my $outputFileHandle;
my $outputFileName;
my ($cmd, $path, $suf) = fileparse($0,".pl");
pod2usage(-verbose => 2, -noperldoc => 1) if (
! Getopt::Long::GetOptions(
"f|file=s" => \$perlFilename, # The file containing the code to run (required)
"d|debug" => \$runDebugger, # Run code in the debugger (default: no)
"ddd" => \$useDDD, # Use the ddd debugger
"dds" => \$useDDS, # Use the Signiant dds_perl
"ns|noscript" => \$noSolutions, # Don't insert the xml containing the Signiant solutions scripts
"nv|novariables" => \$noVariables, # Don't insert the xml containing the variable substitutions. Not substituted if not provided
"show" => \$showCode, # Output code to STDOUT - don't run (default: no)
"code" => \$makeCode, # Output code to File - don't run (default: no)
"h|help|?" => \$help ) or
(!defined $perlFilename) or
defined $help);
my ($codeFile,$codePath,$codeSuf) = fileparse($perlFilename,".pl");
if ((defined $noSolutions) or
(defined $noVariables)) {
$showCode = 1; # Makes sure the we display the code
}
elsif (!defined $showCode) {
($outputFileHandle,$outputFileName) = tempfile( "tmpXXXX" , SUFFIX => '.pl');
}
# Build the command line
my $solutionsCmdLine = "\"$path"."insertSolutions.pl\" -i=\"$perlFilename\"";
$solutionsCmdLine .= " -s=\"$path"."SolutionsScripts.xml\"" if (!defined $noSolutions);
$solutionsCmdLine .= " -v=\"$codePath"."$codeFile".".in\"" if (!defined $noVariables);
$solutionsCmdLine .= " -o=\"$outputFileName\"" if (defined $outputFileName);
system($solutionsCmdLine) == 0 or die "ERROR: Unable to perform variable substitution\n";
# empty outputFileName should show the code on the screen
print "Output File: [$outputFileName]" if ($makeCode);
if ( (!defined $makeCode) and (!defined $showCode) and (defined $outputFileName)) {
# Means we want to run/debug the code
my $options;
$options = 'export PERL5LIB=~/signiant/dds/bin;'; # make sure the perl code in the ddsbin directory can be found
$options = '~/signiant/dds/bin/perl/bin/perl' if (defined $useDDS);
$options = 'perl' if (!defined $useDDS);
$options .= ' -d' if (defined $runDebugger);
$options = 'ddd' if (defined $useDDD);
system("$options $outputFileName");
unlink($outputFileName);
}
__END__
=head1 NAME
sigRun.pl - Run a Signiant perl file
=head1 SYNOPSIS
sigRun.pl [options]
Options:
-f -file Perl input file
-d -debug run in debugger
-ddd debug using ddd
-dds use dds_perl
-ns -noscript skip insertion of Solution Scripts
-nv -novariables skip insertion of the variables
-show output code to STDOUT
-help brief help message
=head1 OPTIONS
=over 8
=item B<-file> (required)
The file containing the Perl script to run.
=item B<-debug>
Perform all the specified substitutions and start the program in the perl debugger.
=item B<-dds>
Run/debug the script with dds_perl (as opposed to the default Perl on the system).
=item B<-noscript>
Perform all other specified substitutions except the insertion of the code in SolutionsScripts.xml.
=item B<-novariable>
Perform all other specified substitutions except the insertion of the variables specified in the corresponding variables file.
=item B<-show>
Perform the specified substitutions and output the resulting script to STDOUT instead of running it.
=item B<-code>
Perform the specified substitutions and output the resulting script to a temporary file instead of running it.
=item B<-help>
Prints this page and exits.
=back
=head1 DESCRIPTION
B<This program> will read the given specified perl script and merge the required elements from the SolutionsScript.xml and the corresponding variable file.
The resultant file will be run using the system default Perl.
=cut