2
|
1 |
::
|
|
2 |
:: Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
:: All rights reserved.
|
|
4 |
:: This component and the accompanying materials are made available
|
|
5 |
:: under the terms of "Eclipse Public License v1.0"
|
|
6 |
:: which accompanies this distribution, and is available
|
|
7 |
:: at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
::
|
|
9 |
:: Initial Contributors:
|
|
10 |
:: Nokia Corporation - initial contribution.
|
|
11 |
::
|
|
12 |
:: Contributors:
|
|
13 |
::
|
|
14 |
:: Description: This file contains capsmodifier implementation.
|
|
15 |
::
|
|
16 |
|
|
17 |
@perl -x CreateKernelTestClass.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
18 |
@goto end
|
|
19 |
|
|
20 |
#!perl
|
|
21 |
use strict;
|
|
22 |
use File::Find;
|
|
23 |
use File::Path;
|
|
24 |
# Verify command line parameters
|
|
25 |
if ($#ARGV == -1 || $#ARGV > 1 )
|
|
26 |
{
|
|
27 |
PrintHelp();
|
|
28 |
}
|
|
29 |
|
|
30 |
# Take module name
|
|
31 |
my $moduleName = $ARGV[0];
|
|
32 |
my $MODULENAME = $moduleName;
|
|
33 |
$MODULENAME =~ tr/[a-z]/[A-Z]/;
|
|
34 |
|
|
35 |
# Take target path or use default
|
|
36 |
my $targetPath="\\";
|
|
37 |
if ( $#ARGV == 1 )
|
|
38 |
{
|
|
39 |
$targetPath = $ARGV[1];
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
# Create directory
|
|
44 |
my $targetDir = $targetPath.$moduleName."\\";
|
|
45 |
|
|
46 |
print "Starting module creation to $targetDir\n";
|
|
47 |
mkpath($targetDir, 1, 0777) || die ("Can't create directory $targetDir");
|
|
48 |
|
|
49 |
# Loop through the file structure
|
|
50 |
find(\&renamerename, '.');
|
|
51 |
|
|
52 |
unlink $targetDir."CreateKernelTestClass.bat";
|
|
53 |
print "Module created to $targetDir\n";
|
|
54 |
|
|
55 |
# This function will be called for each file or directory
|
|
56 |
sub renamerename
|
|
57 |
{
|
|
58 |
my $oldName = $_;
|
|
59 |
print "Processing $oldName\n";
|
|
60 |
|
|
61 |
# Construct new filename if that needed
|
|
62 |
s/TemplateKernelScriptXXX/$moduleName/i;
|
|
63 |
my $newName = $targetDir.$File::Find::dir."/".$_;
|
|
64 |
|
|
65 |
# Process directories
|
|
66 |
if (opendir(DIR, $oldName))
|
|
67 |
{
|
|
68 |
closedir (DIR);
|
|
69 |
mkdir $newName, 0777 || die ("Can't create directory $newName");
|
|
70 |
return;
|
|
71 |
}
|
|
72 |
|
|
73 |
# Open input file
|
|
74 |
open (INFILE, $oldName ) || die ("Can not find $oldName");
|
|
75 |
|
|
76 |
#Open output file
|
|
77 |
my $newOutput = $newName."new";
|
|
78 |
open (OUTFILE, ">".$newOutput ) || die ("Can not open $newOutput");
|
|
79 |
|
|
80 |
# Replace text in files
|
|
81 |
while (<INFILE>)
|
|
82 |
{
|
|
83 |
s/TemplateKernelScriptXXX/$moduleName/g;
|
|
84 |
s/TEMPLATEKERNELSCRIPTXXX/$MODULENAME/g;
|
|
85 |
s/XXX/$moduleName/g;
|
|
86 |
s/TemplateKernelScriptTargetDirYYY/$targetDir/g;
|
|
87 |
print OUTFILE $_;
|
|
88 |
}
|
|
89 |
|
|
90 |
# Close filehandles
|
|
91 |
close (INFILE);
|
|
92 |
close (OUTFILE);
|
|
93 |
|
|
94 |
# Rename result file
|
|
95 |
rename $newOutput,$newName;
|
|
96 |
}
|
|
97 |
|
|
98 |
sub PrintHelp()
|
|
99 |
{
|
|
100 |
print "CreateScriptModule ScriptModuleName [path]\n";
|
|
101 |
print "\n";
|
|
102 |
print "Creates a new test module\n";
|
|
103 |
print "If [path] is not given, module is created to root of current drive.\n";
|
|
104 |
print "If [path] is given, it must contain the final \'\\\' in path name.\n";
|
|
105 |
print "Command must be executed in directory where the template exist.\n";
|
|
106 |
exit;
|
|
107 |
}
|
|
108 |
|
|
109 |
|
|
110 |
__END__
|
|
111 |
:end
|