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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
#!/usr/bin/perl
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/usr/initservice/build/scanistepnames.pl $
#
# IBM CONFIDENTIAL
#
# COPYRIGHT International Business Machines Corp. 2011
#
# p1
#
# Object Code Only (OCO) source materials
# Licensed Internal Code Source Materials
# IBM HostBoot Licensed Internal Code
#
# The source code for this program is not published or other-
# wise divested of its trade secrets, irrespective of what has
# been deposited with the U.S. Copyright Office.
#
# Origin: 30
#
# IBM_PROLOG_END
#
# scan files in the src/include/usr/isteps dir for ISTEPSNAME macro. This
# calls out ISTeps that are executed by the IStep Dispatcher.
# This perl script will create an img/istepnames.csv file that contains a
# list of Comma-Separated-Values of the istep, substep, and istep names
# that the user console should support. For example:
# 4,0,init_target_states
# 4,1,init_fsi
# 4,2,apply_fsi_info
# 4,3,apply_dd_presence
# 4,4,apply_pr_keyword_data
# 4,5,apply_partial_bad
# 4,6,apply_gard
# 4,7,testHWP
use strict;
use File::Find ();
use Time::localtime;
use File::Path;
# Variables
my $DEBUG = 0;
my $sandBase = $ENV{HOSTBOOTROOT};
my $arg;
my $argOutput = "";
my $output = "";
# Arrays
my @fileList;
while( $ARGV = shift )
{
if( $ARGV =~ m/-b/ )
{
# set base input dir
$sandBase = shift;
}
elsif( $ARGV =~ m/-o/i )
{
# set output filename
$argOutput = shift;
}
elsif( $ARGV =~ m/-h/i )
{
# help
usage();
}
elsif( $ARGV =~ m/-d/i )
{
# debug flag
$DEBUG = 1;
}
else
{
usage();
}
}
# Variables depending on input parameters
if( $argOutput eq "" )
{
$output = "$sandBase/img/istepnames.csv";
}
else
{
$output = $argOutput;
}
print "base input dir: $sandBase\n";
print "output file name: $argOutput\n";
print "debug flag: $DEBUG\n";
#debugMsg( "Source Base Path: $sourcebasePath" );
#debugMsg( "Sandbox Base Dir: $sandBase" );
#debugMsg( "Output Dir: $output" );
@fileList = getFiles( $sandBase );
open( OUTFILE, "> $argOutput" ) or die( "Cannot open: $argOutput: $!" );
my $infile;
my $csv;
my $junk;
my $junk2;
foreach $infile ( @fileList )
{
print "Scanning file $sandBase/$infile...\n";
open(INFILE, "< $sandBase/$infile") or die("Cannot open: $infile: $!");
while( <INFILE> )
{
if ( m/^ *ISTEPNAME/ )
{
( $junk, $csv, $junk2 ) = split /[\(\)]/ ;
$csv =~ s/[" ]//g;
print $csv, "\n";
print OUTFILE $csv, "\n";
}
}
}
close (INFILE);
close (OUTFILE);
## Subroutines ################################################################
##
## Print the Usage message
##
sub usage
{
print "Usage: $0 < -b base > <-d> < -o output file >\"\n";
print "\n";
print "-b: base directory ( default is pwd )\n";
print "-o: Output file path for csv file\n";
print "-d Enable Debug messages.\n";
print "-h Display usage message.\n";
print "\n\n";
exit 1;
}
#
# Print debug messages if $DEBUG is enabled.
#
sub debugMsg
{
my ($msg) = @_;
if( $DEBUG )
{
print "DEBUG: $msg\n";
}
}
#
# getFiles - find *.H or *.C files
# This recursively searches the input directory passed in for all C/H files.
#
sub getFiles
{
my ($l_input_dir) = @_;
my @dir_entry;
my $basefilename;
local *DH;
debugMsg( "Getting Files for dir: $l_input_dir" );
# Open the directory and read all entry names.
opendir(DH, $l_input_dir) or die("Cannot open $l_input_dir: $!");
# skip the dots
## @dir_entry = grep { !/^\./ } readdir(DH);
@dir_entry = grep { /^*.[CH]/ } readdir(DH);
closedir(DH);
return( @dir_entry );
}
|