|
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 CreateCapsModifier.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 |
|
18 @goto end |
|
19 |
|
20 #!perl |
|
21 use strict; |
|
22 use File::Find; |
|
23 |
|
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."_exe"."\\"; |
|
45 |
|
46 print "Starting module creation to $targetDir\n"; |
|
47 mkdir $targetDir, 0777 || die ("Can't create directory $targetDir"); |
|
48 |
|
49 # Loop through the file structure |
|
50 find(\&renamerename, '.'); |
|
51 |
|
52 unlink $targetDir."CreateCapsModifier.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/CapsModifierXXX/$moduleName/i; |
|
63 my $newName = $targetDir.$File::Find::dir."/".$_; |
|
64 |
|
65 # Process directories |
|
66 if (opendir(DIR, $oldName)) |
|
67 { |
|
68 closedir (DIR); |
|
69 |
|
70 mkdir $newName, 0777 || die ("Can't create directory $newName"); |
|
71 return; |
|
72 } |
|
73 |
|
74 # Open input file |
|
75 open (INFILE, $oldName ) || die ("Can not find $oldName"); |
|
76 |
|
77 #Open output file |
|
78 my $newOutput = $newName."new"; |
|
79 open (OUTFILE, ">".$newOutput ) || die ("Can not open $newOutput"); |
|
80 |
|
81 # Replace text in files |
|
82 while (<INFILE>) |
|
83 { |
|
84 s/CapsModifierXXX/$moduleName/g; |
|
85 print OUTFILE $_; |
|
86 } |
|
87 |
|
88 # Close filehandles |
|
89 close (INFILE); |
|
90 close (OUTFILE); |
|
91 |
|
92 # Rename result file |
|
93 rename $newOutput,$newName; |
|
94 } |
|
95 |
|
96 sub PrintHelp() |
|
97 { |
|
98 print "CreateModule ModuleName [path]\n"; |
|
99 print "\n"; |
|
100 print "Creates a new capsmodifier module\n"; |
|
101 print "If [path] is not given, module is created to root of current drive.\n"; |
|
102 print "If [path] is given, it must contain the final \'\\\' in path name.\n"; |
|
103 print "Command must be executed in directory where the template exist.\n"; |
|
104 exit; |
|
105 } |
|
106 |
|
107 |
|
108 __END__ |
|
109 :end |