1 # |
1 # |
2 # Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 # All rights reserved. |
3 # All rights reserved. |
4 # This component and the accompanying materials are made available |
4 # This component and the accompanying materials are made available |
5 # under the terms of "Eclipse Public License v1.0" |
5 # under the terms of "Eclipse Public License v1.0" |
6 # which accompanies this distribution, and is available |
6 # which accompanies this distribution, and is available |
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 # |
8 # |
9 # Initial Contributors: |
9 # Initial Contributors: |
10 # Nokia Corporation - initial contribution. |
10 # Nokia Corporation - initial contribution. |
11 # |
11 # |
12 # Contributors: |
12 # Contributors: |
13 # |
13 # |
14 # Description: |
14 # Description: |
15 # Environment Patcher - Patches older S60 SDKs for supporting |
15 # Environment Patcher - Patches older S60 SDKs for supporting |
16 # tricks in newer platforms |
16 # tricks in newer platforms |
17 # |
17 # |
18 |
18 |
19 |
19 |
47 my $pathutlpmpath = $e32toolsdir."/pathutl.pm"; |
47 my $pathutlpmpath = $e32toolsdir."/pathutl.pm"; |
48 my $prepfilepmpath = $e32toolsdir."/prepfile.pm"; |
48 my $prepfilepmpath = $e32toolsdir."/prepfile.pm"; |
49 |
49 |
50 # variables for hacked content |
50 # variables for hacked content |
51 my $dependshack = "\t\t\tif (/^DEPENDS\$/o) {\r\n\t\t\t\tnext LINE; # Ignore DEPENDS keyword, not needed by ABLD\r\n\t\t\t}\r\n"; |
51 my $dependshack = "\t\t\tif (/^DEPENDS\$/o) {\r\n\t\t\t\tnext LINE; # Ignore DEPENDS keyword, not needed by ABLD\r\n\t\t\t}\r\n"; |
|
52 my $smpsafehack = "\t\tif (/^SMPSAFE\$/o) {\r\n\t\t\tnext LINE; # Ignore SMPSAFE keyword, not needed by older environments\r\n\t\t}\r\n"; |
52 my $forwardslashhack = "\t\t# EnvPatcher forwardslash hack begins\r\n\t\t\$_=~s{/}{\\\\}g; # convert all forward slashes to backslashes\r\n\t\t# EnvPatcher forwardslash hack ends\r\n\r\n"; |
53 my $forwardslashhack = "\t\t# EnvPatcher forwardslash hack begins\r\n\t\t\$_=~s{/}{\\\\}g; # convert all forward slashes to backslashes\r\n\t\t# EnvPatcher forwardslash hack ends\r\n\r\n"; |
53 my $coreibyexportsupport = "\r\n// Following definition is used for exporting tools and stubs IBY files to\r\n// Core image.\r\n#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported\r\n"; |
54 my $coreibyexportsupport = "\r\n// Following definition is used for exporting tools and stubs IBY files to\r\n// Core image.\r\n#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported\r\n"; |
54 |
55 |
55 |
56 |
56 # check epoc32\tools exists |
57 # check epoc32\tools exists |
146 if (-e $mmppmpath) |
147 if (-e $mmppmpath) |
147 { |
148 { |
148 # check if DEPENDS keyword already exists in the file |
149 # check if DEPENDS keyword already exists in the file |
149 if (string_exists_in_file($mmppmpath, "DEPENDS")) |
150 if (string_exists_in_file($mmppmpath, "DEPENDS")) |
150 { |
151 { |
151 print "The SDK has already been patched with DEPENDS keyword hack.\n"; |
152 print "The SDK can already handle DEPENDS keyword in a MMP file.\n"; |
152 } |
153 } |
153 else |
154 else |
154 { |
155 { |
155 # read content of the mmp.pm file |
156 # read content of the mmp.pm file |
156 my @filecontent = read_file_to_array($mmppmpath); |
157 my @filecontent = read_file_to_array($mmppmpath); |
179 |
180 |
180 # write the modified array to the file |
181 # write the modified array to the file |
181 write_file_from_array($mmppmpath, @filecontent); |
182 write_file_from_array($mmppmpath, @filecontent); |
182 |
183 |
183 print "Mmp.pm patched with DEPENDS keyword hack.\n"; |
184 print "Mmp.pm patched with DEPENDS keyword hack.\n"; |
|
185 } |
|
186 else |
|
187 { |
|
188 print "ERROR: Unable to find correct place from $mmppmpath for patching!\n"; |
|
189 print "Your SDK environment probably is not supported by this script!\n"; |
|
190 exit(2); |
|
191 } |
|
192 } |
|
193 |
|
194 # check if SMPSAFE keyword already exists in the file |
|
195 if (string_exists_in_file($mmppmpath, "SMPSAFE")) |
|
196 { |
|
197 print "The SDK can already handle SMPSAFE keyword in a MMP file.\n"; |
|
198 } |
|
199 else |
|
200 { |
|
201 # read content of the mmp.pm file |
|
202 my @filecontent = read_file_to_array($mmppmpath); |
|
203 |
|
204 my $match_found = 0; |
|
205 my $i = 0; |
|
206 my $match_found_pos = 0; |
|
207 |
|
208 # loop through the array to find the correct place |
|
209 foreach (@filecontent) |
|
210 { |
|
211 if ($_ =~ /Unrecognised Keyword/) |
|
212 { |
|
213 $match_found = 1; |
|
214 $match_found_pos = $i; |
|
215 last; |
|
216 } |
|
217 |
|
218 $i++; |
|
219 } |
|
220 |
|
221 if ($match_found) |
|
222 { |
|
223 # insert the patched content to the file |
|
224 splice(@filecontent, $match_found_pos, 0, $smpsafehack); |
|
225 |
|
226 # write the modified array to the file |
|
227 write_file_from_array($mmppmpath, @filecontent); |
|
228 |
|
229 print "Mmp.pm patched with SMPSAFE keyword hack.\n"; |
184 } |
230 } |
185 else |
231 else |
186 { |
232 { |
187 print "ERROR: Unable to find correct place from $mmppmpath for patching!\n"; |
233 print "ERROR: Unable to find correct place from $mmppmpath for patching!\n"; |
188 print "Your SDK environment probably is not supported by this script!\n"; |
234 print "Your SDK environment probably is not supported by this script!\n"; |