|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
5 ** |
|
6 ** This file is part of the qmake application of the Qt Toolkit. |
|
7 ** |
|
8 ** $QT_BEGIN_LICENSE:LGPL$ |
|
9 ** No Commercial Usage |
|
10 ** This file contains pre-release code and may not be distributed. |
|
11 ** You may use this file in accordance with the terms and conditions |
|
12 ** contained in the Technology Preview License Agreement accompanying |
|
13 ** this package. |
|
14 ** |
|
15 ** GNU Lesser General Public License Usage |
|
16 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
17 ** General Public License version 2.1 as published by the Free Software |
|
18 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
19 ** packaging of this file. Please review the following information to |
|
20 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
22 ** |
|
23 ** In addition, as a special exception, Nokia gives you certain |
|
24 ** additional rights. These rights are described in the Nokia Qt LGPL |
|
25 ** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this |
|
26 ** package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "symmake.h" |
|
43 #include "initprojectdeploy_symbian.h" |
|
44 |
|
45 #include <qstring.h> |
|
46 #include <qhash.h> |
|
47 #include <qstringlist.h> |
|
48 #include <qdir.h> |
|
49 #include <qdatetime.h> |
|
50 #include <stdlib.h> |
|
51 #include <qdebug.h> |
|
52 |
|
53 #define RESOURCE_DIRECTORY_MMP "/resource/apps" |
|
54 #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\" |
|
55 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps" |
|
56 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def" |
|
57 #define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def" |
|
58 #define BLD_INF_FILENAME_LEN (sizeof(BLD_INF_FILENAME) - 1) |
|
59 |
|
60 #define BLD_INF_RULES_BASE "BLD_INF_RULES." |
|
61 #define BLD_INF_TAG_PLATFORMS "prj_platforms" |
|
62 #define BLD_INF_TAG_MMPFILES "prj_mmpfiles" |
|
63 #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles" |
|
64 #define BLD_INF_TAG_EXTENSIONS "prj_extensions" |
|
65 |
|
66 #define RSS_RULES "RSS_RULES" |
|
67 #define RSS_RULES_BASE "RSS_RULES." |
|
68 #define RSS_TAG_NBROFICONS "number_of_icons" |
|
69 #define RSS_TAG_ICONFILE "icon_file" |
|
70 |
|
71 #define MMP_TARGET "TARGET" |
|
72 #define MMP_TARGETTYPE "TARGETTYPE" |
|
73 #define MMP_SECUREID "SECUREID" |
|
74 |
|
75 #define SIS_TARGET "sis" |
|
76 #define OK_SIS_TARGET "ok_sis" |
|
77 #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg" |
|
78 #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache" |
|
79 #define RESTORE_BUILD_TARGET "restore_build" |
|
80 |
|
81 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename)); |
|
82 |
|
83 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir) |
|
84 { |
|
85 static QString epocRootStr; |
|
86 if (epocRootStr.isEmpty()) { |
|
87 QFileInfo efi(epocRoot()); |
|
88 epocRootStr = efi.canonicalFilePath(); |
|
89 if (epocRootStr.isEmpty()) { |
|
90 fprintf(stderr, "Unable to resolve epocRoot '%s' to real dir on current drive, defaulting to '/' for mmp paths\n", qPrintable(epocRoot())); |
|
91 epocRootStr = "/"; |
|
92 } |
|
93 if (!epocRootStr.endsWith("/")) |
|
94 epocRootStr += "/"; |
|
95 |
|
96 epocRootStr += "epoc32/"; |
|
97 } |
|
98 |
|
99 QString resultPath = origPath; |
|
100 |
|
101 // Make it relative, unless it starts with "%epocroot%/epoc32/" |
|
102 if (resultPath.startsWith(epocRootStr, Qt::CaseInsensitive)) { |
|
103 resultPath.replace(epocRootStr, "/epoc32/", Qt::CaseInsensitive); |
|
104 } else { |
|
105 resultPath = parentDir.relativeFilePath(resultPath); |
|
106 } |
|
107 resultPath = QDir::cleanPath(resultPath); |
|
108 |
|
109 if (resultPath.isEmpty()) |
|
110 resultPath = "."; |
|
111 |
|
112 return resultPath; |
|
113 } |
|
114 |
|
115 QString SymbianMakefileGenerator::canonizePath(const QString& origPath) |
|
116 { |
|
117 // Since current path gets appended almost always anyway, use it as default |
|
118 // for nonexisting paths. |
|
119 static QString defaultPath; |
|
120 if (defaultPath.isEmpty()) { |
|
121 QFileInfo fi("."); |
|
122 defaultPath = fi.canonicalFilePath(); |
|
123 } |
|
124 |
|
125 // Prepend epocroot to any paths beginning with "/epoc32/" |
|
126 QString resultPath = QDir::fromNativeSeparators(origPath); |
|
127 if (resultPath.startsWith("/epoc32/", Qt::CaseInsensitive)) |
|
128 resultPath = QDir::fromNativeSeparators(epocRoot()) + resultPath.mid(1); |
|
129 |
|
130 QFileInfo fi(fileInfo(resultPath)); |
|
131 if (fi.isDir()) { |
|
132 resultPath = fi.canonicalFilePath(); |
|
133 } else { |
|
134 resultPath = fi.canonicalPath(); |
|
135 } |
|
136 |
|
137 resultPath = QDir::cleanPath(resultPath); |
|
138 |
|
139 if (resultPath.isEmpty()) |
|
140 resultPath = defaultPath; |
|
141 |
|
142 return resultPath; |
|
143 } |
|
144 |
|
145 SymbianMakefileGenerator::SymbianMakefileGenerator() : MakefileGenerator() { } |
|
146 SymbianMakefileGenerator::~SymbianMakefileGenerator() { } |
|
147 |
|
148 void SymbianMakefileGenerator::writeHeader(QTextStream &t) |
|
149 { |
|
150 t << "// ============================================================================" << endl; |
|
151 t << "// * Makefile for building: " << escapeFilePath(var("TARGET")) << endl; |
|
152 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
153 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
154 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
155 t << "// * user." << endl; |
|
156 t << "// * Project: " << fileFixify(project->projectFile()) << endl; |
|
157 t << "// * Template: " << var("TEMPLATE") << endl; |
|
158 t << "// ============================================================================" << endl; |
|
159 t << endl; |
|
160 |
|
161 // Defining define for bld.inf |
|
162 |
|
163 QString shortProFilename = project->projectFile(); |
|
164 shortProFilename.replace(0, shortProFilename.lastIndexOf("/") + 1, QString("")); |
|
165 shortProFilename.replace(Option::pro_ext, QString("")); |
|
166 |
|
167 QString bldinfDefine = shortProFilename; |
|
168 bldinfDefine.append("_"); |
|
169 bldinfDefine.append(generate_uid(project->projectFile())); |
|
170 |
|
171 bldinfDefine.prepend("BLD_INF_"); |
|
172 removeSpecialCharacters(bldinfDefine); |
|
173 |
|
174 t << "#define " << bldinfDefine.toUpper() << endl << endl; |
|
175 } |
|
176 |
|
177 bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) |
|
178 { |
|
179 writeHeader(t); |
|
180 |
|
181 QString numberOfIcons; |
|
182 QString iconFile; |
|
183 QStringList userRssRules; |
|
184 readRssRules(numberOfIcons, iconFile, userRssRules); |
|
185 |
|
186 // Get the application translations and convert to symbian OS lang code, i.e. decical number |
|
187 QStringList symbianLangCodes = symbianLangCodesFromTsFiles(); |
|
188 |
|
189 // Generate pkg files if there are any actual files to deploy |
|
190 bool generatePkg = false; |
|
191 if (targetType == TypeExe) { |
|
192 generatePkg = true; |
|
193 } else { |
|
194 foreach(QString item, project->values("DEPLOYMENT")) { |
|
195 if (!project->values(item + ".sources").isEmpty()) { |
|
196 generatePkg = true; |
|
197 break; |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 if (generatePkg) { |
|
203 generatePkgFile(iconFile); |
|
204 } |
|
205 |
|
206 writeBldInfContent(t, generatePkg); |
|
207 |
|
208 // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile, |
|
209 // but all required data is not yet available. |
|
210 bool isPrimaryMakefile = true; |
|
211 QString wrapperFileName("Makefile"); |
|
212 QString outputFileName = fileInfo(Option::output.fileName()).fileName(); |
|
213 if (outputFileName != BLD_INF_FILENAME) { |
|
214 wrapperFileName.append(".").append((outputFileName.size() > BLD_INF_FILENAME_LEN && outputFileName.left(BLD_INF_FILENAME_LEN) == BLD_INF_FILENAME) ? outputFileName.mid(8) : outputFileName); |
|
215 isPrimaryMakefile = false; |
|
216 } |
|
217 |
|
218 QFile wrapperMakefile(wrapperFileName); |
|
219 if (wrapperMakefile.open(QIODevice::WriteOnly)) { |
|
220 generatedFiles << wrapperFileName; |
|
221 } else { |
|
222 PRINT_FILE_CREATE_ERROR(wrapperFileName); |
|
223 return false; |
|
224 } |
|
225 |
|
226 if (targetType == TypeSubdirs) { |
|
227 // If we have something to deploy, generate extension makefile for just that, since |
|
228 // normal extension makefile is not getting generated and we need emulator deployment to be done. |
|
229 if (generatePkg) |
|
230 writeMkFile(wrapperFileName, true); |
|
231 writeWrapperMakefile(wrapperMakefile, isPrimaryMakefile); |
|
232 return true; |
|
233 } |
|
234 |
|
235 writeMkFile(wrapperFileName, false); |
|
236 |
|
237 QString shortProFilename = project->projectFile(); |
|
238 shortProFilename.replace(0, shortProFilename.lastIndexOf("/") + 1, QString("")); |
|
239 shortProFilename.replace(Option::pro_ext, QString("")); |
|
240 |
|
241 QString mmpFilename = shortProFilename; |
|
242 mmpFilename.append("_"); |
|
243 mmpFilename.append(uid3); |
|
244 mmpFilename.append(Option::mmp_ext); |
|
245 writeMmpFile(mmpFilename, symbianLangCodes); |
|
246 |
|
247 if (targetType == TypeExe) { |
|
248 if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) { |
|
249 writeRegRssFile(userRssRules); |
|
250 writeRssFile(numberOfIcons, iconFile); |
|
251 writeLocFile(symbianLangCodes); |
|
252 } |
|
253 } |
|
254 |
|
255 writeCustomDefFile(); |
|
256 writeWrapperMakefile(wrapperMakefile, isPrimaryMakefile); |
|
257 |
|
258 return true; |
|
259 } |
|
260 |
|
261 void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile) |
|
262 { |
|
263 QString pkgFilename = QString("%1_template.%2") |
|
264 .arg(fixedTarget) |
|
265 .arg("pkg"); |
|
266 QFile pkgFile(pkgFilename); |
|
267 if (!pkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { |
|
268 PRINT_FILE_CREATE_ERROR(pkgFilename); |
|
269 return; |
|
270 } |
|
271 |
|
272 generatedFiles << pkgFile.fileName(); |
|
273 |
|
274 // Header info |
|
275 QTextStream t(&pkgFile); |
|
276 t << QString("; %1 generated by qmake at %2").arg(pkgFilename).arg(QDateTime::currentDateTime().toString(Qt::ISODate)) << endl; |
|
277 t << "; This file is generated by qmake and should not be modified by the user" << endl; |
|
278 t << ";" << endl << endl; |
|
279 |
|
280 // Construct QStringList from pkg_prerules since we need search it before printed to file |
|
281 QStringList rawPkgPreRules; |
|
282 foreach(QString deploymentItem, project->values("DEPLOYMENT")) { |
|
283 foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_prerules")) { |
|
284 QStringList pkgrulesValue = project->values(pkgrulesItem); |
|
285 // If there is no stringlist defined for a rule, use rule name directly |
|
286 // This is convenience for defining single line mmp statements |
|
287 if (pkgrulesValue.isEmpty()) { |
|
288 rawPkgPreRules << pkgrulesItem; |
|
289 } else { |
|
290 foreach(QString pkgrule, pkgrulesValue) { |
|
291 rawPkgPreRules << pkgrule; |
|
292 } |
|
293 } |
|
294 } |
|
295 } |
|
296 |
|
297 // Apply some defaults if specific data does not exist in PKG pre-rules |
|
298 |
|
299 if (!containsStartWithItem('&', rawPkgPreRules)) { |
|
300 // language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS) |
|
301 t << "; Language" << endl; |
|
302 t << "&EN" << endl << endl; |
|
303 } else { |
|
304 // In case user defines langs, he must take care also about SIS header |
|
305 if (!containsStartWithItem('#', rawPkgPreRules)) |
|
306 fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n"); |
|
307 } |
|
308 |
|
309 // name of application, UID and version |
|
310 QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ','); |
|
311 |
|
312 if (!containsStartWithItem('#', rawPkgPreRules)) { |
|
313 QString visualTarget = escapeFilePath(fileFixify(project->first("TARGET"))); |
|
314 visualTarget = removePathSeparators(visualTarget); |
|
315 |
|
316 t << "; SIS header: name, uid, version" << endl; |
|
317 t << QString("#{\"%1\"},(%2),%3").arg(visualTarget).arg(uid3).arg(applicationVersion) << endl << endl; |
|
318 } |
|
319 |
|
320 // Localized vendor name |
|
321 if (!containsStartWithItem('%', rawPkgPreRules)) { |
|
322 t << "; Localised Vendor name" << endl; |
|
323 t << "%{\"Vendor\"}" << endl << endl; |
|
324 } |
|
325 |
|
326 // Unique vendor name |
|
327 if (!containsStartWithItem(':', rawPkgPreRules)) { |
|
328 t << "; Unique Vendor name" << endl; |
|
329 t << ":\"Vendor\"" << endl << endl; |
|
330 } |
|
331 |
|
332 // PKG pre-rules - these are added before actual file installations i.e. SIS package body |
|
333 if (rawPkgPreRules.size()) { |
|
334 t << "; Manual PKG pre-rules from PRO files" << endl; |
|
335 foreach(QString item, rawPkgPreRules) { |
|
336 t << item << endl; |
|
337 } |
|
338 t << endl; |
|
339 } |
|
340 |
|
341 // Install paths on the phone *** should be dynamic at some point |
|
342 QString installPathBin = "!:\\sys\\bin"; |
|
343 QString installPathResource = "!:\\resource\\apps"; |
|
344 QString installPathRegResource = "!:\\private\\10003a3f\\import\\apps"; |
|
345 |
|
346 // Find location of builds |
|
347 QString epocReleasePath = QString("%1epoc32/release/$(PLATFORM)/$(TARGET)") |
|
348 .arg(epocRoot()); |
|
349 |
|
350 |
|
351 if (targetType == TypeExe) { |
|
352 // deploy .exe file |
|
353 t << "; Executable and default resource files" << endl; |
|
354 QString exeFile = fixedTarget + ".exe"; |
|
355 t << QString("\"%1/%2\" - \"%3\\%4\"") |
|
356 .arg(epocReleasePath) |
|
357 .arg(exeFile) |
|
358 .arg(installPathBin) |
|
359 .arg(exeFile) << endl; |
|
360 |
|
361 // deploy rsc & reg_rsc file |
|
362 if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) { |
|
363 t << QString("\"%1epoc32/data/z/resource/apps/%2\" - \"%3\\%4\"") |
|
364 .arg(epocRoot()) |
|
365 .arg(fixedTarget + ".rsc") |
|
366 .arg(installPathResource) |
|
367 .arg(fixedTarget + ".rsc") << endl; |
|
368 |
|
369 t << QString("\"%1epoc32/data/z/private/10003a3f/import/apps/%2\" - \"%3\\%4\"") |
|
370 .arg(epocRoot()) |
|
371 .arg(fixedTarget + "_reg.rsc") |
|
372 .arg(installPathRegResource) |
|
373 .arg(fixedTarget + "_reg.rsc") << endl; |
|
374 |
|
375 QString myIconFile = iconFile; |
|
376 myIconFile = myIconFile.replace("\\\\", "\\"); |
|
377 |
|
378 if (!iconFile.isEmpty()) { |
|
379 t << QString("\"%1epoc32/data/z%2\" - \"!:%3\"") |
|
380 .arg(epocRoot()) |
|
381 .arg(QString(myIconFile).replace('\\','/')) |
|
382 .arg(myIconFile) << endl << endl; |
|
383 } |
|
384 } |
|
385 } |
|
386 |
|
387 // deploy any additional DEPLOYMENT files |
|
388 DeploymentList depList; |
|
389 QString remoteTestPath; |
|
390 remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid); |
|
391 |
|
392 initProjectDeploySymbian(project, depList, remoteTestPath, true, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles); |
|
393 if (depList.size()) |
|
394 t << "; DEPLOYMENT" << endl; |
|
395 for (int i = 0; i < depList.size(); ++i) { |
|
396 t << QString("\"%1\" - \"%2\"") |
|
397 .arg(QString(depList.at(i).from).replace('\\','/')) |
|
398 .arg(depList.at(i).to) << endl; |
|
399 } |
|
400 t << endl; |
|
401 |
|
402 // PKG post-rules - these are added after actual file installations i.e. SIS package body |
|
403 t << "; Manual PKG post-rules from PRO files" << endl; |
|
404 foreach(QString deploymentItem, project->values("DEPLOYMENT")) { |
|
405 foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_postrules")) { |
|
406 QStringList pkgrulesValue = project->values(pkgrulesItem); |
|
407 // If there is no stringlist defined for a rule, use rule name directly |
|
408 // This is convenience for defining single line statements |
|
409 if (pkgrulesValue.isEmpty()) { |
|
410 t << pkgrulesItem << endl; |
|
411 } else { |
|
412 foreach(QString pkgrule, pkgrulesValue) { |
|
413 t << pkgrule << endl; |
|
414 } |
|
415 } |
|
416 t << endl; |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 bool SymbianMakefileGenerator::containsStartWithItem(const QChar &c, const QStringList& src) |
|
422 { |
|
423 bool result = false; |
|
424 foreach(QString str, src) { |
|
425 if (str.startsWith(c)) { |
|
426 result = true; |
|
427 break; |
|
428 } |
|
429 } |
|
430 return result; |
|
431 } |
|
432 |
|
433 void SymbianMakefileGenerator::writeCustomDefFile() |
|
434 { |
|
435 if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) { |
|
436 // Create custom def file for plugin |
|
437 QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL)); |
|
438 |
|
439 if (ft.open(QIODevice::WriteOnly)) { |
|
440 generatedFiles << ft.fileName(); |
|
441 QTextStream t(&ft); |
|
442 |
|
443 t << "; ==============================================================================" << endl; |
|
444 t << "; Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
445 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
446 t << "; This file is generated by qmake and should not be modified by the" << endl; |
|
447 t << "; user." << endl; |
|
448 t << "; Name : " PLUGIN_COMMON_DEF_FILE_ACTUAL << endl; |
|
449 t << "; Part of : " << project->values("TARGET").join(" ") << endl; |
|
450 t << "; Description : Fixes common plugin symbols to known ordinals" << endl; |
|
451 t << "; Version : " << endl; |
|
452 t << ";" << endl; |
|
453 t << "; ==============================================================================" << "\n" << endl; |
|
454 |
|
455 t << endl; |
|
456 |
|
457 t << "EXPORTS" << endl; |
|
458 t << "\tqt_plugin_query_verification_data @ 1 NONAME" << endl; |
|
459 t << "\tqt_plugin_instance @ 2 NONAME" << endl; |
|
460 t << endl; |
|
461 } else { |
|
462 PRINT_FILE_CREATE_ERROR(QString(PLUGIN_COMMON_DEF_FILE_ACTUAL)) |
|
463 } |
|
464 } |
|
465 } |
|
466 |
|
467 void SymbianMakefileGenerator::init() |
|
468 { |
|
469 MakefileGenerator::init(); |
|
470 fixedTarget = escapeFilePath(fileFixify(project->first("TARGET"))); |
|
471 fixedTarget = removePathSeparators(fixedTarget); |
|
472 removeSpecialCharacters(fixedTarget); |
|
473 |
|
474 if (0 != project->values("QMAKE_PLATFORM").size()) |
|
475 platform = varGlue("QMAKE_PLATFORM", "", " ", ""); |
|
476 |
|
477 if (0 == project->values("QMAKESPEC").size()) |
|
478 project->values("QMAKESPEC").append(qgetenv("QMAKESPEC")); |
|
479 |
|
480 project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); |
|
481 project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); |
|
482 |
|
483 // bld.inf |
|
484 project->values("MAKEFILE") += BLD_INF_FILENAME; |
|
485 |
|
486 // .mmp |
|
487 initMmpVariables(); |
|
488 |
|
489 // Check TARGET.UID3 presence |
|
490 if (0 != project->values("TARGET.UID3").size()) { |
|
491 uid3 = project->first("TARGET.UID3"); |
|
492 } else { |
|
493 uid3 = generateUID3(); |
|
494 } |
|
495 |
|
496 if ((project->values("TEMPLATE")).contains("app")) |
|
497 targetType = TypeExe; |
|
498 else if ((project->values("TEMPLATE")).contains("lib")) { |
|
499 // Check CONFIG to see if we are to build staticlib or dll |
|
500 if (project->values("CONFIG").contains("staticlib") || project->values("CONFIG").contains("static")) |
|
501 targetType = TypeLib; |
|
502 else if (project->values("CONFIG").contains("plugin")) |
|
503 targetType = TypePlugin; |
|
504 else |
|
505 targetType = TypeDll; |
|
506 } else { |
|
507 targetType = TypeSubdirs; |
|
508 } |
|
509 |
|
510 if (0 != project->values("TARGET.UID2").size()) { |
|
511 uid2 = project->first("TARGET.UID2"); |
|
512 } else if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) { |
|
513 uid2 = "0x20004C45"; |
|
514 } else { |
|
515 if (targetType == TypeExe) { |
|
516 if (project->values("QT").contains("gui", Qt::CaseInsensitive)) { |
|
517 // exe and gui -> uid2 needed |
|
518 uid2 = "0x100039CE"; |
|
519 } else { |
|
520 // exe but not gui: uid2 is ignored anyway -> set it to 0 |
|
521 uid2 = "0"; |
|
522 } |
|
523 } else if (targetType == TypeDll || targetType == TypeLib || targetType == TypePlugin) { |
|
524 uid2 = "0x1000008d"; |
|
525 } |
|
526 } |
|
527 |
|
528 uid2 = uid2.trimmed(); |
|
529 uid3 = uid3.trimmed(); |
|
530 |
|
531 // UID is valid as either hex or decimal, so just convert it to number and back to hex |
|
532 // to get proper string for private dir |
|
533 bool conversionOk = false; |
|
534 uint uidNum = uid3.toUInt(&conversionOk, 0); |
|
535 |
|
536 if (!conversionOk) { |
|
537 fprintf(stderr, "Error: Invalid UID \"%s\".\n", uid3.toUtf8().constData()); |
|
538 } else { |
|
539 privateDirUid.setNum(uidNum, 16); |
|
540 while (privateDirUid.length() < 8) |
|
541 privateDirUid.insert(0, QLatin1Char('0')); |
|
542 } |
|
543 } |
|
544 |
|
545 QString SymbianMakefileGenerator::getTargetExtension() |
|
546 { |
|
547 QString ret; |
|
548 if (targetType == TypeExe) { |
|
549 ret.append("exe"); |
|
550 } else if (targetType == TypeLib) { |
|
551 ret.append("lib"); |
|
552 } else if (targetType == TypeDll || targetType == TypePlugin) { |
|
553 ret.append("dll"); |
|
554 } else if (targetType == TypeSubdirs) { |
|
555 // Not actually usable, so return empty |
|
556 } else { |
|
557 // If nothing else set, default to exe |
|
558 ret.append("exe"); |
|
559 } |
|
560 |
|
561 return ret; |
|
562 } |
|
563 |
|
564 QString SymbianMakefileGenerator::generateUID3() |
|
565 { |
|
566 QString target = project->first("TARGET"); |
|
567 QString currPath = qmake_getpwd(); |
|
568 target.prepend("/").prepend(currPath); |
|
569 return generate_test_uid(target); |
|
570 } |
|
571 |
|
572 void SymbianMakefileGenerator::initMmpVariables() |
|
573 { |
|
574 QStringList sysincspaths; |
|
575 QStringList srcincpaths; |
|
576 QStringList srcpaths; |
|
577 |
|
578 srcpaths << project->values("SOURCES") << project->values("GENERATED_SOURCES"); |
|
579 srcpaths << project->values("UNUSED_SOURCES") << project->values("UI_SOURCES_DIR"); |
|
580 srcpaths << project->values("UI_DIR"); |
|
581 |
|
582 QDir current = QDir::current(); |
|
583 QString canonizedCurrent = canonizePath("."); |
|
584 |
|
585 for (int j = 0; j < srcpaths.size(); ++j) { |
|
586 QFileInfo fi(fileInfo(srcpaths.at(j))); |
|
587 // Sometimes sources have other than *.c* files (e.g. *.moc); prune them. |
|
588 if (fi.suffix().startsWith("c")) { |
|
589 if (fi.filePath().length() > fi.fileName().length()) { |
|
590 appendIfnotExist(srcincpaths, fi.path()); |
|
591 sources[canonizePath(fi.path())] += fi.fileName(); |
|
592 } else { |
|
593 sources[canonizedCurrent] += fi.fileName(); |
|
594 appendIfnotExist(srcincpaths, canonizedCurrent); |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 QStringList incpaths; |
|
600 incpaths << project->values("INCLUDEPATH"); |
|
601 incpaths << QLibraryInfo::location(QLibraryInfo::HeadersPath); |
|
602 incpaths << project->values("HEADERS"); |
|
603 incpaths << srcincpaths; |
|
604 incpaths << project->values("UI_HEADERS_DIR"); |
|
605 incpaths << project->values("UI_DIR"); |
|
606 |
|
607 QString epocPath("epoc32"); |
|
608 for (int j = 0; j < incpaths.size(); ++j) { |
|
609 QString includepath = canonizePath(incpaths.at(j)); |
|
610 appendIfnotExist(sysincspaths, includepath); |
|
611 // As a workaround for Symbian toolchain insistence to treat include |
|
612 // statements as relative to source file rather than the file they appear in, |
|
613 // we generate extra temporary include directories to make |
|
614 // relative include paths used in various headers to work properly. |
|
615 // Note that this is not a fix-all solution; it's just a stop-gap measure |
|
616 // to make Qt itself build until toolchain can support relative includes in |
|
617 // a way that Qt expects. |
|
618 if (!includepath.contains(epocPath)) // No temp dirs for epoc includes |
|
619 appendIfnotExist(sysincspaths, includepath + QString("/" QT_EXTRA_INCLUDE_DIR)); |
|
620 } |
|
621 |
|
622 // Remove duplicate include path entries |
|
623 QStringList temporary; |
|
624 for (int i = 0; i < sysincspaths.size(); ++i) { |
|
625 QString origPath = sysincspaths.at(i); |
|
626 QFileInfo origPathInfo(fileInfo(origPath)); |
|
627 bool bFound = false; |
|
628 |
|
629 for (int j = 0; j < temporary.size(); ++j) { |
|
630 QString tmpPath = temporary.at(j); |
|
631 QFileInfo tmpPathInfo(fileInfo(tmpPath)); |
|
632 |
|
633 if (origPathInfo.absoluteFilePath() == tmpPathInfo.absoluteFilePath()) { |
|
634 bFound = true; |
|
635 if (!tmpPathInfo.isRelative() && origPathInfo.isRelative()) { |
|
636 // We keep the relative notation |
|
637 temporary.removeOne(tmpPath); |
|
638 temporary << origPath; |
|
639 } |
|
640 } |
|
641 } |
|
642 |
|
643 if (!bFound) |
|
644 temporary << origPath; |
|
645 |
|
646 } |
|
647 |
|
648 sysincspaths.clear(); |
|
649 sysincspaths << temporary; |
|
650 |
|
651 systeminclude.insert("SYSTEMINCLUDE", sysincspaths); |
|
652 } |
|
653 |
|
654 bool SymbianMakefileGenerator::removeDuplicatedStrings(QStringList& stringList) |
|
655 { |
|
656 QStringList tmpStringList; |
|
657 |
|
658 for (int i = 0; i < stringList.size(); ++i) { |
|
659 QString string = stringList.at(i); |
|
660 if (tmpStringList.contains(string)) |
|
661 continue; |
|
662 else |
|
663 tmpStringList.append(string); |
|
664 } |
|
665 |
|
666 stringList.clear(); |
|
667 stringList = tmpStringList; |
|
668 return true; |
|
669 } |
|
670 |
|
671 void SymbianMakefileGenerator::writeMmpFileHeader(QTextStream &t) |
|
672 { |
|
673 t << "// ==============================================================================" << endl; |
|
674 t << "// Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
675 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
676 t << "// This file is generated by qmake and should not be modified by the" << endl; |
|
677 t << "// user." << endl; |
|
678 t << "// Name : " << escapeFilePath(fileFixify(project->projectFile().remove(project->projectFile().length() - 4, 4))) << Option::mmp_ext << endl; |
|
679 t << "// ==============================================================================" << endl << endl; |
|
680 } |
|
681 |
|
682 void SymbianMakefileGenerator::writeMmpFile(QString &filename, QStringList &symbianLangCodes) |
|
683 { |
|
684 QFile ft(filename); |
|
685 if (ft.open(QIODevice::WriteOnly)) { |
|
686 generatedFiles << ft.fileName(); |
|
687 |
|
688 QTextStream t(&ft); |
|
689 |
|
690 writeMmpFileHeader(t); |
|
691 |
|
692 writeMmpFileTargetPart(t); |
|
693 |
|
694 writeMmpFileResourcePart(t, symbianLangCodes); |
|
695 |
|
696 writeMmpFileMacrosPart(t); |
|
697 |
|
698 writeMmpFileIncludePart(t); |
|
699 |
|
700 QDir current = QDir::current(); |
|
701 |
|
702 for (QMap<QString, QStringList>::iterator it = sources.begin(); it != sources.end(); ++it) { |
|
703 QStringList values = it.value(); |
|
704 QString currentSourcePath = it.key(); |
|
705 |
|
706 if (values.size()) |
|
707 t << "SOURCEPATH \t" << fixPathForMmp(currentSourcePath, current) << endl; |
|
708 |
|
709 for (int i = 0; i < values.size(); ++i) { |
|
710 QString sourceFileName = values.at(i); |
|
711 t << "SOURCE\t\t" << sourceFileName << endl; |
|
712 } |
|
713 t << endl; |
|
714 } |
|
715 t << endl; |
|
716 |
|
717 if (!project->values("CONFIG").contains("static") && !project->values("CONFIG").contains("staticlib")) { |
|
718 writeMmpFileLibraryPart(t); |
|
719 } |
|
720 |
|
721 writeMmpFileCapabilityPart(t); |
|
722 |
|
723 writeMmpFileCompilerOptionPart(t); |
|
724 |
|
725 writeMmpFileBinaryVersionPart(t); |
|
726 |
|
727 writeMmpFileRulesPart(t); |
|
728 } else { |
|
729 PRINT_FILE_CREATE_ERROR(filename) |
|
730 } |
|
731 } |
|
732 |
|
733 void SymbianMakefileGenerator::writeMmpFileMacrosPart(QTextStream& t) |
|
734 { |
|
735 t << endl; |
|
736 |
|
737 QStringList &defines = project->values("DEFINES"); |
|
738 if (defines.size()) |
|
739 t << "// Qt Macros" << endl; |
|
740 for (int i = 0; i < defines.size(); ++i) { |
|
741 QString def = defines.at(i); |
|
742 addMacro(t, def); |
|
743 } |
|
744 |
|
745 // These are required in order that all methods will be correctly exported e.g from qtestlib |
|
746 QStringList &exp_defines = project->values("PRL_EXPORT_DEFINES"); |
|
747 if (exp_defines.size()) |
|
748 t << endl << "// Qt Export Defines" << endl; |
|
749 for (int i = 0; i < exp_defines.size(); ++i) { |
|
750 QString def = exp_defines.at(i); |
|
751 addMacro(t, def); |
|
752 } |
|
753 |
|
754 t << endl; |
|
755 } |
|
756 |
|
757 void SymbianMakefileGenerator::addMacro(QTextStream& t, const QString& value) |
|
758 { |
|
759 t << "MACRO" << "\t\t" << value << endl; |
|
760 } |
|
761 |
|
762 |
|
763 void SymbianMakefileGenerator::writeMmpFileTargetPart(QTextStream& t) |
|
764 { |
|
765 QString targetTypeValue(""); |
|
766 |
|
767 if (targetType == TypeExe) { |
|
768 t << MMP_TARGET << "\t\t" << fixedTarget << ".exe" << endl; |
|
769 if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) |
|
770 targetTypeValue = QString("STDEXE"); |
|
771 else |
|
772 targetTypeValue = QString("EXE"); |
|
773 } else if (targetType == TypeDll || targetType == TypePlugin) { |
|
774 t << MMP_TARGET << "\t\t" << fixedTarget << ".dll" << endl; |
|
775 if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) |
|
776 targetTypeValue = QString("STDDLL"); |
|
777 else |
|
778 targetTypeValue = QString("DLL"); |
|
779 } else if (targetType == TypeLib) { |
|
780 t << MMP_TARGET << "\t\t" << fixedTarget << ".lib" << endl; |
|
781 if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) |
|
782 targetTypeValue = QString("STDLIB"); |
|
783 else |
|
784 targetTypeValue = QString("LIB"); |
|
785 } else { |
|
786 fprintf(stderr, "Error: Unexpected targettype (%d) in SymbianMakefileGenerator::writeMmpFileTargetPart\n", targetType); |
|
787 } |
|
788 |
|
789 if (0 != project->values("TARGETTYPE_OVERRIDE").size()) { |
|
790 targetTypeValue = project->first("TARGETTYPE_OVERRIDE"); |
|
791 } |
|
792 |
|
793 t << MMP_TARGETTYPE << "\t\t" << targetTypeValue << endl; |
|
794 |
|
795 t << endl; |
|
796 |
|
797 t << "UID" << "\t\t" << uid2 << " " << uid3 << endl; |
|
798 |
|
799 if (0 != project->values("TARGET.SID").size()) { |
|
800 t << MMP_SECUREID << "\t\t" << project->values("TARGET.SID").join(" ") << endl; |
|
801 } else { |
|
802 if (0 == uid3.size()) |
|
803 t << MMP_SECUREID << "\t\t" << "0" << endl; |
|
804 else |
|
805 t << MMP_SECUREID << "\t\t" << uid3 << endl; |
|
806 } |
|
807 |
|
808 // default value used from mkspecs is 0 |
|
809 if (0 != project->values("TARGET.VID").size()) { |
|
810 t << "VENDORID" << "\t\t" << project->values("TARGET.VID").join(" ") << endl; |
|
811 } |
|
812 |
|
813 t << endl; |
|
814 |
|
815 if (0 != project->first("TARGET.EPOCSTACKSIZE").size()) |
|
816 t << "EPOCSTACKSIZE" << "\t\t" << project->first("TARGET.EPOCSTACKSIZE") << endl; |
|
817 if (0 != project->values("TARGET.EPOCHEAPSIZE").size()) |
|
818 t << "EPOCHEAPSIZE" << "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl; |
|
819 if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size()) |
|
820 t << "EPOCALLOWDLLDATA" << endl; |
|
821 |
|
822 if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) { |
|
823 // Use custom def file for Qt plugins |
|
824 t << "DEFFILE " PLUGIN_COMMON_DEF_FILE_FOR_MMP << endl; |
|
825 } |
|
826 |
|
827 t << endl; |
|
828 } |
|
829 |
|
830 |
|
831 /* |
|
832 Application registration resource files should be installed to the |
|
833 \private\10003a3f\import\apps directory. |
|
834 */ |
|
835 void SymbianMakefileGenerator::writeMmpFileResourcePart(QTextStream& t, QStringList &symbianLangCodes) |
|
836 { |
|
837 if ((targetType == TypeExe) && |
|
838 !project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) { |
|
839 |
|
840 QString locTarget = fixedTarget; |
|
841 locTarget.append(".rss"); |
|
842 |
|
843 t << "SOURCEPATH\t\t\t. " << endl; |
|
844 t << "LANG SC "; // no endl |
|
845 foreach(QString lang, symbianLangCodes) { |
|
846 t << lang << " "; // no endl |
|
847 } |
|
848 t << endl; |
|
849 t << "START RESOURCE\t\t" << locTarget << endl; |
|
850 t << "HEADER" << endl; |
|
851 t << "TARGETPATH\t\t\t" RESOURCE_DIRECTORY_MMP << endl; |
|
852 t << "END" << endl << endl; |
|
853 |
|
854 QString regTarget = fixedTarget; |
|
855 regTarget.append("_reg.rss"); |
|
856 |
|
857 t << "SOURCEPATH\t\t\t." << endl; |
|
858 t << "START RESOURCE\t\t" << regTarget << endl; |
|
859 if (isForSymbianSbsv2()) |
|
860 t << "DEPENDS " << fixedTarget << ".rsg" << endl; |
|
861 t << "TARGETPATH\t\t" REGISTRATION_RESOURCE_DIRECTORY_HW << endl; |
|
862 t << "END" << endl << endl; |
|
863 } |
|
864 } |
|
865 |
|
866 void SymbianMakefileGenerator::writeMmpFileSystemIncludePart(QTextStream& t) |
|
867 { |
|
868 QDir current = QDir::current(); |
|
869 |
|
870 for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) { |
|
871 QStringList values = it.value(); |
|
872 for (int i = 0; i < values.size(); ++i) { |
|
873 QString handledPath = values.at(i); |
|
874 t << "SYSTEMINCLUDE" << "\t\t" << fixPathForMmp(handledPath, current) << endl; |
|
875 } |
|
876 } |
|
877 |
|
878 t << endl; |
|
879 } |
|
880 |
|
881 void SymbianMakefileGenerator::writeMmpFileIncludePart(QTextStream& t) |
|
882 { |
|
883 writeMmpFileSystemIncludePart(t); |
|
884 } |
|
885 |
|
886 void SymbianMakefileGenerator::writeMmpFileLibraryPart(QTextStream& t) |
|
887 { |
|
888 QStringList &libs = project->values("LIBS"); |
|
889 libs << project->values("QMAKE_LIBS") << project->values("QMAKE_LIBS_PRIVATE"); |
|
890 |
|
891 removeDuplicatedStrings(libs); |
|
892 |
|
893 for (int i = 0; i < libs.size(); ++i) { |
|
894 QString lib = libs.at(i); |
|
895 // The -L flag is uninteresting, since all symbian libraries exist in the same directory. |
|
896 if (lib.startsWith("-l")) { |
|
897 lib.remove(0, 2); |
|
898 QString mmpStatement; |
|
899 if (lib.endsWith(".dll")) { |
|
900 lib.chop(4); |
|
901 mmpStatement = "LIBRARY\t\t"; |
|
902 } else if (lib.endsWith(".lib")) { |
|
903 lib.chop(4); |
|
904 mmpStatement = "STATICLIBRARY\t"; |
|
905 } else { |
|
906 // Hacky way to find out what kind of library it is. Check the |
|
907 // ARMV5 build directory for library type. We default to shared |
|
908 // library, since that is more common. |
|
909 QString udebStaticLibLocation(epocRoot()); |
|
910 QString urelStaticLibLocation(udebStaticLibLocation); |
|
911 udebStaticLibLocation += QString("epoc32/release/armv5/udeb/%1.lib").arg(lib); |
|
912 urelStaticLibLocation += QString("epoc32/release/armv5/urel/%1.lib").arg(lib); |
|
913 if (QFile::exists(udebStaticLibLocation) || QFile::exists(urelStaticLibLocation)) { |
|
914 mmpStatement = "STATICLIBRARY\t"; |
|
915 } else { |
|
916 mmpStatement = "LIBRARY\t\t"; |
|
917 } |
|
918 } |
|
919 t << mmpStatement << lib << ".lib" << endl; |
|
920 } |
|
921 } |
|
922 |
|
923 t << endl; |
|
924 } |
|
925 |
|
926 void SymbianMakefileGenerator::writeMmpFileCapabilityPart(QTextStream& t) |
|
927 { |
|
928 if (0 != project->first("TARGET.CAPABILITY").size()) { |
|
929 QStringList &capabilities = project->values("TARGET.CAPABILITY"); |
|
930 t << "CAPABILITY" << "\t\t"; |
|
931 |
|
932 for (int i = 0; i < capabilities.size(); ++i) { |
|
933 QString cap = capabilities.at(i); |
|
934 t << cap << " "; |
|
935 } |
|
936 } else { |
|
937 t << "CAPABILITY" << "\t\t" << "None"; |
|
938 } |
|
939 t << endl << endl; |
|
940 } |
|
941 |
|
942 void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) |
|
943 { |
|
944 QString cw, armcc; |
|
945 |
|
946 if (0 != project->values("QMAKE_CXXFLAGS.CW").size()) { |
|
947 cw.append(project->values("QMAKE_CXXFLAGS.CW").join(" ")); |
|
948 cw.append(" "); |
|
949 } |
|
950 |
|
951 if (0 != project->values("QMAKE_CXXFLAGS.ARMCC").size()) { |
|
952 armcc.append(project->values("QMAKE_CXXFLAGS.ARMCC").join(" ")); |
|
953 armcc.append(" "); |
|
954 } |
|
955 |
|
956 if (0 != project->values("QMAKE_CFLAGS.CW").size()) { |
|
957 cw.append(project->values("QMAKE_CFLAGS.CW").join(" ")); |
|
958 cw.append(" "); |
|
959 } |
|
960 |
|
961 if (0 != project->values("QMAKE_CFLAGS.ARMCC").size()) { |
|
962 armcc.append(project->values("QMAKE_CFLAGS.ARMCC").join(" ")); |
|
963 armcc.append(" "); |
|
964 } |
|
965 |
|
966 if (0 != project->values("QMAKE_CXXFLAGS").size()) { |
|
967 cw.append(project->values("QMAKE_CXXFLAGS").join(" ")); |
|
968 cw.append(" "); |
|
969 armcc.append(project->values("QMAKE_CXXFLAGS").join(" ")); |
|
970 armcc.append(" "); |
|
971 } |
|
972 |
|
973 if (0 != project->values("QMAKE_CFLAGS").size()) { |
|
974 cw.append(project->values("QMAKE_CFLAGS").join(" ")); |
|
975 cw.append(" "); |
|
976 armcc.append(project->values("QMAKE_CFLAGS").join(" ")); |
|
977 armcc.append(" "); |
|
978 } |
|
979 |
|
980 if (!cw.isEmpty() && cw[cw.size()-1] == ' ') |
|
981 cw.chop(1); |
|
982 if (!armcc.isEmpty() && armcc[armcc.size()-1] == ' ') |
|
983 armcc.chop(1); |
|
984 |
|
985 if (!cw.isEmpty()) |
|
986 t << "OPTION" << '\t' << " CW " << cw << endl; |
|
987 if (!armcc.isEmpty()) |
|
988 t << "OPTION" << '\t' << " ARMCC " << armcc << endl; |
|
989 |
|
990 t << endl; |
|
991 } |
|
992 |
|
993 void SymbianMakefileGenerator::writeMmpFileBinaryVersionPart(QTextStream& t) |
|
994 { |
|
995 QString applicationVersion = project->first("VERSION"); |
|
996 QStringList verNumList = applicationVersion.split('.'); |
|
997 uint major = 0; |
|
998 uint minor = 0; |
|
999 uint patch = 0; |
|
1000 bool success = false; |
|
1001 |
|
1002 if (verNumList.size() > 0) { |
|
1003 major = verNumList[0].toUInt(&success); |
|
1004 if (success && verNumList.size() > 1) { |
|
1005 minor = verNumList[1].toUInt(&success); |
|
1006 if (success && verNumList.size() > 2) { |
|
1007 patch = verNumList[2].toUInt(&success); |
|
1008 } |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 QString mmpVersion; |
|
1013 if (success && major <= 0xFFFF && minor <= 0xFF && patch <= 0xFF) { |
|
1014 // Symbian binary version only has major and minor components, so compress |
|
1015 // Qt's minor and patch values into the minor component. Since Symbian's minor |
|
1016 // component is a 16 bit value, only allow 8 bits for each to avoid overflow. |
|
1017 mmpVersion.append(QString::number(major)) |
|
1018 .append('.') |
|
1019 .append(QString::number((minor << 8) + patch)); |
|
1020 } else { |
|
1021 if (!applicationVersion.isEmpty()) |
|
1022 fprintf(stderr, "Invalid VERSION string: %s\n", qPrintable(applicationVersion)); |
|
1023 mmpVersion = "10.0"; // Default binary version for symbian is 10.0 |
|
1024 } |
|
1025 |
|
1026 t << "VERSION " << mmpVersion << endl; |
|
1027 } |
|
1028 |
|
1029 void SymbianMakefileGenerator::writeMmpFileRulesPart(QTextStream& t) |
|
1030 { |
|
1031 foreach(QString item, project->values("MMP_RULES")) { |
|
1032 t << endl; |
|
1033 // If there is no stringlist defined for a rule, use rule name directly |
|
1034 // This is convenience for defining single line mmp statements |
|
1035 if (project->values(item).isEmpty()) { |
|
1036 t << item << endl; |
|
1037 } else { |
|
1038 foreach(QString itemRow, project->values(item)) { |
|
1039 t << itemRow << endl; |
|
1040 } |
|
1041 } |
|
1042 } |
|
1043 } |
|
1044 |
|
1045 void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension) |
|
1046 { |
|
1047 // Read user defined bld inf rules |
|
1048 QMap<QString, QStringList> userBldInfRules; |
|
1049 for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) { |
|
1050 if (it.key().startsWith(BLD_INF_RULES_BASE)) { |
|
1051 QString newKey = it.key().mid(sizeof(BLD_INF_RULES_BASE) - 1); |
|
1052 if (newKey.isEmpty()) { |
|
1053 fprintf(stderr, "Warning: Empty BLD_INF_RULES key encountered\n"); |
|
1054 continue; |
|
1055 } |
|
1056 QStringList newValues; |
|
1057 QStringList values = it.value(); |
|
1058 foreach(QString item, values) { |
|
1059 // If there is no stringlist defined for a rule, use rule name directly |
|
1060 // This is convenience for defining single line statements |
|
1061 if (project->values(item).isEmpty()) { |
|
1062 newValues << item; |
|
1063 } else { |
|
1064 foreach(QString itemRow, project->values(item)) { |
|
1065 newValues << itemRow; |
|
1066 } |
|
1067 } |
|
1068 } |
|
1069 userBldInfRules.insert(newKey, newValues); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 // Add includes of subdirs bld.inf files |
|
1074 |
|
1075 QString mmpfilename = escapeFilePath(fileFixify(project->projectFile())); |
|
1076 mmpfilename = mmpfilename.replace(mmpfilename.lastIndexOf("."), 4, Option::mmp_ext); |
|
1077 QString currentPath = qmake_getpwd(); |
|
1078 |
|
1079 if (!currentPath.endsWith(QString("/"))) |
|
1080 currentPath.append("/"); |
|
1081 |
|
1082 QStringList mmpProjects = project->values("MMPFILES_DIRECT_DEPENDS"); |
|
1083 QStringList shadowProjects = project->values("SHADOW_BLD_INFS"); |
|
1084 |
|
1085 removeDuplicatedStrings(mmpProjects); |
|
1086 removeDuplicatedStrings(shadowProjects); |
|
1087 |
|
1088 // Go in reverse order as that is the way how we build the list |
|
1089 QListIterator<QString> iT(mmpProjects); |
|
1090 iT.toBack(); |
|
1091 while (iT.hasPrevious()) { |
|
1092 QString fullMmpName = iT.previous(); |
|
1093 QString relativePath; |
|
1094 QString bldinfFilename; |
|
1095 |
|
1096 QString fullProFilename = fullMmpName; |
|
1097 fullProFilename.replace(Option::mmp_ext, Option::pro_ext); |
|
1098 QString uid = generate_uid(fullProFilename); |
|
1099 |
|
1100 QString cleanMmpName = fullProFilename; |
|
1101 cleanMmpName.replace(Option::pro_ext, QString("")); |
|
1102 cleanMmpName.replace(0, cleanMmpName.lastIndexOf("/") + 1, QString("")); |
|
1103 |
|
1104 if (shadowProjects.contains(BLD_INF_FILENAME "." + cleanMmpName)) { // shadow project |
|
1105 QDir directory(currentPath); |
|
1106 relativePath = directory.relativeFilePath(fullProFilename); |
|
1107 bldinfFilename = BLD_INF_FILENAME "." + cleanMmpName; |
|
1108 if (relativePath.contains("/")) { |
|
1109 // Shadow .pro not in same directory as parent .pro |
|
1110 if (relativePath.startsWith("..")) { |
|
1111 // Shadow .pro out of parent .pro |
|
1112 relativePath.replace(relativePath.lastIndexOf("/"), relativePath.length(), QString("")); |
|
1113 bldinfFilename.prepend("/").prepend(relativePath); |
|
1114 } else { |
|
1115 relativePath.replace(relativePath.lastIndexOf("/"), relativePath.length(), QString("")); |
|
1116 bldinfFilename.prepend("/").prepend(relativePath); |
|
1117 } |
|
1118 } else { |
|
1119 // Shadow .pro and parent .pro in same directory |
|
1120 bldinfFilename.prepend("./"); |
|
1121 } |
|
1122 } else { // regular project |
|
1123 QDir directory(currentPath); |
|
1124 relativePath = directory.relativeFilePath(fullProFilename); |
|
1125 relativePath.replace(relativePath.lastIndexOf("/"), relativePath.length(), QString("")); |
|
1126 bldinfFilename = relativePath.append("/").append(BLD_INF_FILENAME); |
|
1127 } |
|
1128 |
|
1129 QString bldinfDefine = QString("BLD_INF_") + cleanMmpName + QString("_") + uid; |
|
1130 bldinfDefine = bldinfDefine.toUpper(); |
|
1131 removeSpecialCharacters(bldinfDefine); |
|
1132 |
|
1133 t << "#ifndef " << bldinfDefine << endl; |
|
1134 t << "\t#include \"" << QDir::toNativeSeparators(bldinfFilename) << "\"" << endl; |
|
1135 t << "#endif // " << bldinfDefine << endl; |
|
1136 } |
|
1137 |
|
1138 // Add supported project platforms |
|
1139 |
|
1140 t << endl << BLD_INF_TAG_PLATFORMS << endl << endl; |
|
1141 if (0 != project->values("SYMBIAN_PLATFORMS").size()) |
|
1142 t << project->values("SYMBIAN_PLATFORMS").join(" ") << endl; |
|
1143 |
|
1144 QStringList userItems = userBldInfRules.value(BLD_INF_TAG_PLATFORMS); |
|
1145 foreach(QString item, userItems) |
|
1146 t << item << endl; |
|
1147 userBldInfRules.remove(BLD_INF_TAG_PLATFORMS); |
|
1148 t << endl; |
|
1149 |
|
1150 // Add project mmps and old style extension makefiles |
|
1151 QString mmpTag; |
|
1152 if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive)) |
|
1153 mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES); |
|
1154 else |
|
1155 mmpTag = QLatin1String(BLD_INF_TAG_MMPFILES); |
|
1156 |
|
1157 t << endl << mmpTag << endl << endl; |
|
1158 |
|
1159 writeBldInfMkFilePart(t, addDeploymentExtension); |
|
1160 if (targetType == TypeSubdirs) { |
|
1161 mmpProjects.removeOne(mmpfilename); |
|
1162 } else { |
|
1163 QString shortProFilename = project->projectFile(); |
|
1164 shortProFilename.replace(0, shortProFilename.lastIndexOf("/") + 1, QString("")); |
|
1165 shortProFilename.replace(Option::pro_ext, QString("")); |
|
1166 |
|
1167 QString mmpFilename = shortProFilename + QString("_") + uid3 + Option::mmp_ext; |
|
1168 |
|
1169 t << mmpFilename << endl; |
|
1170 } |
|
1171 |
|
1172 userItems = userBldInfRules.value(mmpTag); |
|
1173 foreach(QString item, userItems) |
|
1174 t << item << endl; |
|
1175 userBldInfRules.remove(mmpTag); |
|
1176 |
|
1177 t << endl << BLD_INF_TAG_EXTENSIONS << endl << endl; |
|
1178 |
|
1179 // Generate extension rules |
|
1180 writeBldInfExtensionRulesPart(t); |
|
1181 |
|
1182 userItems = userBldInfRules.value(BLD_INF_TAG_EXTENSIONS); |
|
1183 foreach(QString item, userItems) |
|
1184 t << item << endl; |
|
1185 userBldInfRules.remove(BLD_INF_TAG_EXTENSIONS); |
|
1186 |
|
1187 // Add rest of the user defined content |
|
1188 |
|
1189 for (QMap<QString, QStringList>::iterator it = userBldInfRules.begin(); it != userBldInfRules.end(); ++it) { |
|
1190 t << endl << endl << it.key() << endl << endl; |
|
1191 userItems = it.value(); |
|
1192 foreach(QString item, userItems) |
|
1193 t << item << endl; |
|
1194 } |
|
1195 } |
|
1196 |
|
1197 void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) |
|
1198 { |
|
1199 QString filename(fixedTarget); |
|
1200 filename.append("_reg.rss"); |
|
1201 QFile ft(filename); |
|
1202 if (ft.open(QIODevice::WriteOnly)) { |
|
1203 generatedFiles << ft.fileName(); |
|
1204 QTextStream t(&ft); |
|
1205 t << "// ============================================================================" << endl; |
|
1206 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
1207 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
1208 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
1209 t << "// * user." << endl; |
|
1210 t << "// ============================================================================" << endl; |
|
1211 t << endl; |
|
1212 t << "#include <" << fixedTarget << ".rsg>" << endl; |
|
1213 t << "#include <appinfo.rh>" << endl; |
|
1214 t << endl; |
|
1215 //t << "#include <data_caging_paths.hrh>" << "\n" << endl; |
|
1216 t << "UID2 " << "KUidAppRegistrationResourceFile" << endl; |
|
1217 t << "UID3 " << uid3 << endl << endl; |
|
1218 t << "RESOURCE APP_REGISTRATION_INFO" << endl; |
|
1219 t << "\t{" << endl; |
|
1220 t << "\tapp_file=\"" << fixedTarget << "\";" << endl; |
|
1221 t << "\tlocalisable_resource_file=\"" RESOURCE_DIRECTORY_RESOURCE << fixedTarget << "\";" << endl; |
|
1222 t << endl; |
|
1223 |
|
1224 foreach(QString item, userItems) |
|
1225 t << "\t" << item << endl; |
|
1226 t << "\t}" << endl; |
|
1227 } else { |
|
1228 PRINT_FILE_CREATE_ERROR(filename) |
|
1229 } |
|
1230 } |
|
1231 |
|
1232 void SymbianMakefileGenerator::writeRssFile(QString &numberOfIcons, QString &iconFile) |
|
1233 { |
|
1234 QString filename(fixedTarget); |
|
1235 filename.append(".rss"); |
|
1236 QFile ft(filename); |
|
1237 if (ft.open(QIODevice::WriteOnly)) { |
|
1238 generatedFiles << ft.fileName(); |
|
1239 QTextStream t(&ft); |
|
1240 t << "// ============================================================================" << endl; |
|
1241 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
1242 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
1243 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
1244 t << "// * user." << endl; |
|
1245 t << "// ============================================================================" << endl; |
|
1246 t << endl; |
|
1247 t << "#include <appinfo.rh>" << endl; |
|
1248 t << "#include \"" << fixedTarget << ".loc\"" << endl; |
|
1249 t << endl; |
|
1250 t << "RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info" << endl; |
|
1251 t << "\t{" << endl; |
|
1252 t << "\tshort_caption = STRING_r_short_caption;" << endl; |
|
1253 t << "\tcaption_and_icon =" << endl; |
|
1254 t << "\tCAPTION_AND_ICON_INFO" << endl; |
|
1255 t << "\t\t{" << endl; |
|
1256 t << "\t\tcaption = STRING_r_caption;" << endl; |
|
1257 |
|
1258 if (numberOfIcons.isEmpty() || iconFile.isEmpty()) { |
|
1259 // There can be maximum one item in this tag, validated when parsed |
|
1260 t << "\t\tnumber_of_icons = 0;" << endl; |
|
1261 t << "\t\ticon_file = \"\";" << endl; |
|
1262 } else { |
|
1263 // There can be maximum one item in this tag, validated when parsed |
|
1264 t << "\t\tnumber_of_icons = " << numberOfIcons << ";" << endl; |
|
1265 t << "\t\ticon_file = \"" << iconFile << "\";" << endl; |
|
1266 } |
|
1267 t << "\t\t};" << endl; |
|
1268 t << "\t}" << endl; |
|
1269 t << endl; |
|
1270 } else { |
|
1271 PRINT_FILE_CREATE_ERROR(filename); |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes) |
|
1276 { |
|
1277 QString filename(fixedTarget); |
|
1278 filename.append(".loc"); |
|
1279 QFile ft(filename); |
|
1280 if (ft.open(QIODevice::WriteOnly)) { |
|
1281 generatedFiles << ft.fileName(); |
|
1282 QTextStream t(&ft); |
|
1283 t << "// ============================================================================" << endl; |
|
1284 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
1285 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
1286 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
1287 t << "// * user." << endl; |
|
1288 t << "// ============================================================================" << endl; |
|
1289 t << endl; |
|
1290 t << "#ifdef LANGUAGE_SC" << endl; |
|
1291 t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl; |
|
1292 t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl; |
|
1293 foreach(QString lang, symbianLangCodes) { |
|
1294 t << "#elif defined LANGUAGE_" << lang << endl; |
|
1295 t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl; |
|
1296 t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl; |
|
1297 } |
|
1298 t << "#else" << endl; |
|
1299 t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl; |
|
1300 t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl; |
|
1301 t << "#endif" << endl; |
|
1302 } else { |
|
1303 PRINT_FILE_CREATE_ERROR(filename); |
|
1304 } |
|
1305 } |
|
1306 |
|
1307 void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &iconFile, QStringList &userRssRules) |
|
1308 { |
|
1309 for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) { |
|
1310 if (it.key().startsWith(RSS_RULES_BASE)) { |
|
1311 QString newKey = it.key().mid(sizeof(RSS_RULES_BASE) - 1); |
|
1312 if (newKey.isEmpty()) { |
|
1313 fprintf(stderr, "Warning: Empty RSS_RULES_BASE key encountered\n"); |
|
1314 continue; |
|
1315 } |
|
1316 QStringList newValues; |
|
1317 QStringList values = it.value(); |
|
1318 foreach(QString item, values) { |
|
1319 // If there is no stringlist defined for a rule, use rule name directly |
|
1320 // This is convenience for defining single line statements |
|
1321 if (project->values(item).isEmpty()) { |
|
1322 newValues << item; |
|
1323 } else { |
|
1324 foreach(QString itemRow, project->values(item)) { |
|
1325 newValues << itemRow; |
|
1326 } |
|
1327 } |
|
1328 } |
|
1329 // Verify thet there is exactly one value in RSS_TAG_NBROFICONS |
|
1330 if (newKey == RSS_TAG_NBROFICONS) { |
|
1331 if (newValues.count() == 1) { |
|
1332 numberOfIcons = newValues[0]; |
|
1333 } else { |
|
1334 fprintf(stderr, "Warning: There must be exactly one value in '%s%s'\n", |
|
1335 RSS_RULES_BASE, RSS_TAG_NBROFICONS); |
|
1336 continue; |
|
1337 } |
|
1338 // Verify thet there is exactly one value in RSS_TAG_ICONFILE |
|
1339 } else if (newKey == RSS_TAG_ICONFILE) { |
|
1340 if (newValues.count() == 1) { |
|
1341 iconFile = newValues[0]; |
|
1342 } else { |
|
1343 fprintf(stderr, "Warning: There must be exactly one value in '%s%s'\n", |
|
1344 RSS_RULES_BASE, RSS_TAG_ICONFILE); |
|
1345 continue; |
|
1346 } |
|
1347 } else { |
|
1348 fprintf(stderr, "Warning: Unsupported key:'%s%s'\n", |
|
1349 RSS_RULES_BASE, newKey.toLatin1().constData()); |
|
1350 continue; |
|
1351 } |
|
1352 } |
|
1353 } |
|
1354 |
|
1355 foreach(QString item, project->values(RSS_RULES)) { |
|
1356 // If there is no stringlist defined for a rule, use rule name directly |
|
1357 // This is convenience for defining single line mmp statements |
|
1358 if (project->values(item).isEmpty()) { |
|
1359 userRssRules << item; |
|
1360 } else { |
|
1361 userRssRules << project->values(item); |
|
1362 } |
|
1363 } |
|
1364 |
|
1365 // Validate that either both RSS_TAG_NBROFICONS and RSS_TAG_ICONFILE keys exist |
|
1366 // or neither of them exist |
|
1367 if (!((numberOfIcons.isEmpty() && iconFile.isEmpty()) || |
|
1368 (!numberOfIcons.isEmpty() && !iconFile.isEmpty()))) { |
|
1369 numberOfIcons.clear(); |
|
1370 iconFile.clear(); |
|
1371 fprintf(stderr, "Warning: Both or neither of '%s%s' and '%s%s' keys must exist.\n", |
|
1372 RSS_RULES_BASE, RSS_TAG_NBROFICONS, RSS_RULES_BASE, RSS_TAG_ICONFILE); |
|
1373 } |
|
1374 |
|
1375 // Validate that RSS_TAG_NBROFICONS contains only numbers |
|
1376 if (!numberOfIcons.isEmpty()) { |
|
1377 bool ok; |
|
1378 numberOfIcons = numberOfIcons.simplified(); |
|
1379 int tmp = numberOfIcons.toInt(&ok); |
|
1380 if (!ok) { |
|
1381 numberOfIcons.clear(); |
|
1382 iconFile.clear(); |
|
1383 fprintf(stderr, "Warning: '%s%s' must be integer in decimal format.\n", |
|
1384 RSS_RULES_BASE, RSS_TAG_NBROFICONS); |
|
1385 } |
|
1386 } |
|
1387 } |
|
1388 |
|
1389 QStringList SymbianMakefileGenerator::symbianLangCodesFromTsFiles() |
|
1390 { |
|
1391 QStringList tsfiles; |
|
1392 QStringList symbianLangCodes; |
|
1393 tsfiles << project->values("TRANSLATIONS"); |
|
1394 |
|
1395 fillQt2S60LangMapTable(); |
|
1396 |
|
1397 foreach(QString file, tsfiles) { |
|
1398 int extIndex = file.lastIndexOf("."); |
|
1399 int langIndex = file.lastIndexOf("_", (extIndex - file.length())); |
|
1400 langIndex += 1; |
|
1401 QString qtlang = file.mid(langIndex, extIndex - langIndex); |
|
1402 QString s60lang = qt2S60LangMapTable.value(qtlang, QString("SC")); |
|
1403 |
|
1404 if (!symbianLangCodes.contains(s60lang) && s60lang != "SC") |
|
1405 symbianLangCodes += s60lang; |
|
1406 } |
|
1407 |
|
1408 return symbianLangCodes; |
|
1409 } |
|
1410 |
|
1411 void SymbianMakefileGenerator::fillQt2S60LangMapTable() |
|
1412 { |
|
1413 qt2S60LangMapTable.reserve(170); // 165 items at time of writing. |
|
1414 qt2S60LangMapTable.insert("ab", "SC"); //Abkhazian // |
|
1415 qt2S60LangMapTable.insert("om", "SC"); //Afan // |
|
1416 qt2S60LangMapTable.insert("aa", "SC"); //Afar // |
|
1417 qt2S60LangMapTable.insert("af", "34"); //Afrikaans //Afrikaans |
|
1418 qt2S60LangMapTable.insert("sq", "35"); //Albanian //Albanian |
|
1419 qt2S60LangMapTable.insert("am", "36"); //Amharic //Amharic |
|
1420 qt2S60LangMapTable.insert("ar", "37"); //Arabic //Arabic |
|
1421 qt2S60LangMapTable.insert("hy", "38"); //Armenian //Armenian |
|
1422 qt2S60LangMapTable.insert("as", "SC"); //Assamese // |
|
1423 qt2S60LangMapTable.insert("ay", "SC"); //Aymara // |
|
1424 qt2S60LangMapTable.insert("az", "SC"); //Azerbaijani // |
|
1425 qt2S60LangMapTable.insert("ba", "SC"); //Bashkir // |
|
1426 qt2S60LangMapTable.insert("eu", "SC"); //Basque // |
|
1427 qt2S60LangMapTable.insert("bn", "41"); //Bengali //Bengali |
|
1428 qt2S60LangMapTable.insert("dz", "SC"); //Bhutani // |
|
1429 qt2S60LangMapTable.insert("bh", "SC"); //Bihari // |
|
1430 qt2S60LangMapTable.insert("bi", "SC"); //Bislama // |
|
1431 qt2S60LangMapTable.insert("br", "SC"); //Breton // |
|
1432 qt2S60LangMapTable.insert("bg", "42"); //Bulgarian //Bulgarian |
|
1433 qt2S60LangMapTable.insert("my", "43"); //Burmese //Burmese |
|
1434 qt2S60LangMapTable.insert("be", "40"); //Byelorussian //Belarussian |
|
1435 qt2S60LangMapTable.insert("km", "SC"); //Cambodian // |
|
1436 qt2S60LangMapTable.insert("ca", "44"); //Catalan //Catalan |
|
1437 qt2S60LangMapTable.insert("zh", "SC"); //Chinese // |
|
1438 qt2S60LangMapTable.insert("co", "SC"); //Corsican // |
|
1439 qt2S60LangMapTable.insert("hr", "45"); //Croatian //Croatian |
|
1440 qt2S60LangMapTable.insert("cs", "25"); //Czech //Czech |
|
1441 qt2S60LangMapTable.insert("da", "07"); //Danish //Danish |
|
1442 qt2S60LangMapTable.insert("nl", "18"); //Dutch //Dutch |
|
1443 qt2S60LangMapTable.insert("en", "01"); //English //English(UK) |
|
1444 qt2S60LangMapTable.insert("eo", "SC"); //Esperanto // |
|
1445 qt2S60LangMapTable.insert("et", "49"); //Estonian //Estonian |
|
1446 qt2S60LangMapTable.insert("fo", "SC"); //Faroese // |
|
1447 qt2S60LangMapTable.insert("fj", "SC"); //Fiji // |
|
1448 qt2S60LangMapTable.insert("fi", "09"); //Finnish //Finnish |
|
1449 qt2S60LangMapTable.insert("fr", "02"); //French //French |
|
1450 qt2S60LangMapTable.insert("fy", "SC"); //Frisian // |
|
1451 qt2S60LangMapTable.insert("gd", "52"); //Gaelic //Gaelic |
|
1452 qt2S60LangMapTable.insert("gl", "SC"); //Galician // |
|
1453 qt2S60LangMapTable.insert("ka", "53"); //Georgian //Georgian |
|
1454 qt2S60LangMapTable.insert("de", "03"); //German //German |
|
1455 qt2S60LangMapTable.insert("el", "54"); //Greek //Greek |
|
1456 qt2S60LangMapTable.insert("kl", "SC"); //Greenlandic // |
|
1457 qt2S60LangMapTable.insert("gn", "SC"); //Guarani // |
|
1458 qt2S60LangMapTable.insert("gu", "56"); //Gujarati //Gujarati |
|
1459 qt2S60LangMapTable.insert("ha", "SC"); //Hausa // |
|
1460 qt2S60LangMapTable.insert("he", "57"); //Hebrew //Hebrew |
|
1461 qt2S60LangMapTable.insert("hi", "58"); //Hindi //Hindi |
|
1462 qt2S60LangMapTable.insert("hu", "17"); //Hungarian //Hungarian |
|
1463 qt2S60LangMapTable.insert("is", "15"); //Icelandic //Icelandic |
|
1464 qt2S60LangMapTable.insert("id", "59"); //Indonesian //Indonesian |
|
1465 qt2S60LangMapTable.insert("ia", "SC"); //Interlingua // |
|
1466 qt2S60LangMapTable.insert("ie", "SC"); //Interlingue // |
|
1467 qt2S60LangMapTable.insert("iu", "SC"); //Inuktitut // |
|
1468 qt2S60LangMapTable.insert("ik", "SC"); //Inupiak // |
|
1469 qt2S60LangMapTable.insert("ga", "60"); //Irish //Irish |
|
1470 qt2S60LangMapTable.insert("it", "05"); //Italian //Italian |
|
1471 qt2S60LangMapTable.insert("ja", "32"); //Japanese //Japanese |
|
1472 qt2S60LangMapTable.insert("jv", "SC"); //Javanese // |
|
1473 qt2S60LangMapTable.insert("kn", "62"); //Kannada //Kannada |
|
1474 qt2S60LangMapTable.insert("ks", "SC"); //Kashmiri // |
|
1475 qt2S60LangMapTable.insert("kk", "63"); //Kazakh //Kazakh |
|
1476 qt2S60LangMapTable.insert("rw", "SC"); //Kinyarwanda // |
|
1477 qt2S60LangMapTable.insert("ky", "SC"); //Kirghiz // |
|
1478 qt2S60LangMapTable.insert("ko", "65"); //Korean //Korean |
|
1479 qt2S60LangMapTable.insert("ku", "SC"); //Kurdish // |
|
1480 qt2S60LangMapTable.insert("rn", "SC"); //Kurundi // |
|
1481 qt2S60LangMapTable.insert("lo", "66"); //Laothian //Laothian |
|
1482 qt2S60LangMapTable.insert("la", "SC"); //Latin // |
|
1483 qt2S60LangMapTable.insert("lv", "67"); //Latvian //Latvian |
|
1484 qt2S60LangMapTable.insert("ln", "SC"); //Lingala // |
|
1485 qt2S60LangMapTable.insert("lt", "68"); //Lithuanian //Lithuanian |
|
1486 qt2S60LangMapTable.insert("mk", "69"); //Macedonian //Macedonian |
|
1487 qt2S60LangMapTable.insert("mg", "SC"); //Malagasy // |
|
1488 qt2S60LangMapTable.insert("ms", "70"); //Malay //Malay |
|
1489 qt2S60LangMapTable.insert("ml", "71"); //Malayalam //Malayalam |
|
1490 qt2S60LangMapTable.insert("mt", "SC"); //Maltese // |
|
1491 qt2S60LangMapTable.insert("mi", "SC"); //Maori // |
|
1492 qt2S60LangMapTable.insert("mr", "72"); //Marathi //Marathi |
|
1493 qt2S60LangMapTable.insert("mo", "73"); //Moldavian //Moldovian |
|
1494 qt2S60LangMapTable.insert("mn", "74"); //Mongolian //Mongolian |
|
1495 qt2S60LangMapTable.insert("na", "SC"); //Nauru // |
|
1496 qt2S60LangMapTable.insert("ne", "SC"); //Nepali // |
|
1497 qt2S60LangMapTable.insert("nb", "08"); //Norwegian //Norwegian |
|
1498 qt2S60LangMapTable.insert("oc", "SC"); //Occitan // |
|
1499 qt2S60LangMapTable.insert("or", "SC"); //Oriya // |
|
1500 qt2S60LangMapTable.insert("ps", "SC"); //Pashto // |
|
1501 qt2S60LangMapTable.insert("fa", "SC"); //Persian // |
|
1502 qt2S60LangMapTable.insert("pl", "27"); //Polish //Polish |
|
1503 qt2S60LangMapTable.insert("pt", "13"); //Portuguese //Portuguese |
|
1504 qt2S60LangMapTable.insert("pa", "77"); //Punjabi //Punjabi |
|
1505 qt2S60LangMapTable.insert("qu", "SC"); //Quechua // |
|
1506 qt2S60LangMapTable.insert("rm", "SC"); //RhaetoRomance // |
|
1507 qt2S60LangMapTable.insert("ro", "78"); //Romanian //Romanian |
|
1508 qt2S60LangMapTable.insert("ru", "16"); //Russian //Russian |
|
1509 qt2S60LangMapTable.insert("sm", "SC"); //Samoan // |
|
1510 qt2S60LangMapTable.insert("sg", "SC"); //Sangho // |
|
1511 qt2S60LangMapTable.insert("sa", "SC"); //Sanskrit // |
|
1512 qt2S60LangMapTable.insert("sr", "79"); //Serbian //Serbian |
|
1513 qt2S60LangMapTable.insert("sh", "SC"); //SerboCroatian // |
|
1514 qt2S60LangMapTable.insert("st", "SC"); //Sesotho // |
|
1515 qt2S60LangMapTable.insert("tn", "SC"); //Setswana // |
|
1516 qt2S60LangMapTable.insert("sn", "SC"); //Shona // |
|
1517 qt2S60LangMapTable.insert("sd", "SC"); //Sindhi // |
|
1518 qt2S60LangMapTable.insert("si", "80"); //Singhalese //Sinhalese |
|
1519 qt2S60LangMapTable.insert("ss", "SC"); //Siswati // |
|
1520 qt2S60LangMapTable.insert("sk", "26"); //Slovak //Slovak |
|
1521 qt2S60LangMapTable.insert("sl", "28"); //Slovenian //Slovenian |
|
1522 qt2S60LangMapTable.insert("so", "81"); //Somali //Somali |
|
1523 qt2S60LangMapTable.insert("es", "04"); //Spanish //Spanish |
|
1524 qt2S60LangMapTable.insert("su", "SC"); //Sundanese // |
|
1525 qt2S60LangMapTable.insert("sw", "84"); //Swahili //Swahili |
|
1526 qt2S60LangMapTable.insert("sv", "06"); //Swedish //Swedish |
|
1527 qt2S60LangMapTable.insert("tl", "39"); //Tagalog //Tagalog |
|
1528 qt2S60LangMapTable.insert("tg", "SC"); //Tajik // |
|
1529 qt2S60LangMapTable.insert("ta", "87"); //Tamil //Tamil |
|
1530 qt2S60LangMapTable.insert("tt", "SC"); //Tatar // |
|
1531 qt2S60LangMapTable.insert("te", "88"); //Telugu //Telugu |
|
1532 qt2S60LangMapTable.insert("th", "33"); //Thai //Thai |
|
1533 qt2S60LangMapTable.insert("bo", "89"); //Tibetan //Tibetan |
|
1534 qt2S60LangMapTable.insert("ti", "90"); //Tigrinya //Tigrinya |
|
1535 qt2S60LangMapTable.insert("to", "SC"); //Tonga // |
|
1536 qt2S60LangMapTable.insert("ts", "SC"); //Tsonga // |
|
1537 qt2S60LangMapTable.insert("tr", "14"); //Turkish //Turkish |
|
1538 qt2S60LangMapTable.insert("tk", "92"); //Turkmen //Turkmen |
|
1539 qt2S60LangMapTable.insert("tw", "SC"); //Twi // |
|
1540 qt2S60LangMapTable.insert("ug", "SC"); //Uigur // |
|
1541 qt2S60LangMapTable.insert("uk", "93"); //Ukrainian //Ukrainian |
|
1542 qt2S60LangMapTable.insert("ur", "94"); //Urdu //Urdu |
|
1543 qt2S60LangMapTable.insert("uz", "SC"); //Uzbek // |
|
1544 qt2S60LangMapTable.insert("vi", "96"); //Vietnamese //Vietnamese |
|
1545 qt2S60LangMapTable.insert("vo", "SC"); //Volapuk // |
|
1546 qt2S60LangMapTable.insert("cy", "97"); //Welsh //Welsh |
|
1547 qt2S60LangMapTable.insert("wo", "SC"); //Wolof // |
|
1548 qt2S60LangMapTable.insert("xh", "SC"); //Xhosa // |
|
1549 qt2S60LangMapTable.insert("yi", "SC"); //Yiddish // |
|
1550 qt2S60LangMapTable.insert("yo", "SC"); //Yoruba // |
|
1551 qt2S60LangMapTable.insert("za", "SC"); //Zhuang // |
|
1552 qt2S60LangMapTable.insert("zu", "98"); //Zulu //Zulu |
|
1553 qt2S60LangMapTable.insert("nn", "75"); //Nynorsk //NorwegianNynorsk |
|
1554 qt2S60LangMapTable.insert("bs", "SC"); //Bosnian // |
|
1555 qt2S60LangMapTable.insert("dv", "SC"); //Divehi // |
|
1556 qt2S60LangMapTable.insert("gv", "SC"); //Manx // |
|
1557 qt2S60LangMapTable.insert("kw", "SC"); //Cornish // |
|
1558 qt2S60LangMapTable.insert("ak", "SC"); //Akan // |
|
1559 qt2S60LangMapTable.insert("kok", "SC"); //Konkani // |
|
1560 qt2S60LangMapTable.insert("gaa", "SC"); //Ga // |
|
1561 qt2S60LangMapTable.insert("ig", "SC"); //Igbo // |
|
1562 qt2S60LangMapTable.insert("kam", "SC"); //Kamba // |
|
1563 qt2S60LangMapTable.insert("syr", "SC"); //Syriac // |
|
1564 qt2S60LangMapTable.insert("byn", "SC"); //Blin // |
|
1565 qt2S60LangMapTable.insert("gez", "SC"); //Geez // |
|
1566 qt2S60LangMapTable.insert("kfo", "SC"); //Koro // |
|
1567 qt2S60LangMapTable.insert("sid", "SC"); //Sidamo // |
|
1568 qt2S60LangMapTable.insert("cch", "SC"); //Atsam // |
|
1569 qt2S60LangMapTable.insert("tig", "SC"); //Tigre // |
|
1570 qt2S60LangMapTable.insert("kaj", "SC"); //Jju // |
|
1571 qt2S60LangMapTable.insert("fur", "SC"); //Friulian // |
|
1572 qt2S60LangMapTable.insert("ve", "SC"); //Venda // |
|
1573 qt2S60LangMapTable.insert("ee", "SC"); //Ewe // |
|
1574 qt2S60LangMapTable.insert("wa", "SC"); //Walamo // |
|
1575 qt2S60LangMapTable.insert("haw", "SC"); //Hawaiian // |
|
1576 qt2S60LangMapTable.insert("kcg", "SC"); //Tyap // |
|
1577 qt2S60LangMapTable.insert("ny", "SC"); //Chewa // |
|
1578 } |
|
1579 |
|
1580 void SymbianMakefileGenerator::appendIfnotExist(QStringList &list, QString value) |
|
1581 { |
|
1582 if (!list.contains(value)) |
|
1583 list += value; |
|
1584 } |
|
1585 |
|
1586 void SymbianMakefileGenerator::appendIfnotExist(QStringList &list, QStringList values) |
|
1587 { |
|
1588 foreach(QString item, values) |
|
1589 appendIfnotExist(list, item); |
|
1590 } |
|
1591 |
|
1592 QString SymbianMakefileGenerator::removePathSeparators(QString &file) |
|
1593 { |
|
1594 QString ret = file; |
|
1595 while (ret.indexOf(QDir::separator()) > 0) { |
|
1596 ret.remove(0, ret.indexOf(QDir::separator()) + 1); |
|
1597 } |
|
1598 |
|
1599 return ret; |
|
1600 } |
|
1601 |
|
1602 |
|
1603 QString SymbianMakefileGenerator::removeTrailingPathSeparators(QString &file) |
|
1604 { |
|
1605 QString ret = file; |
|
1606 if (ret.endsWith(QDir::separator())) { |
|
1607 ret.remove(ret.length() - 1, 1); |
|
1608 } |
|
1609 |
|
1610 return ret; |
|
1611 } |
|
1612 |
|
1613 void SymbianMakefileGenerator::generateCleanCommands(QTextStream& t, |
|
1614 const QStringList& toClean, |
|
1615 const QString& cmd, |
|
1616 const QString& cmdOptions, |
|
1617 const QString& itemPrefix, |
|
1618 const QString& itemSuffix) |
|
1619 { |
|
1620 for (int i = 0; i < toClean.size(); ++i) { |
|
1621 QString item = toClean.at(i); |
|
1622 item.prepend(itemPrefix).append(itemSuffix); |
|
1623 #if defined(Q_OS_WIN) |
|
1624 t << "\t-@ if EXIST \"" << QDir::toNativeSeparators(item) << "\" "; |
|
1625 t << cmd << " " << cmdOptions << " \"" << QDir::toNativeSeparators(item) << "\"" << endl; |
|
1626 #else |
|
1627 t << "\t-if test -f " << QDir::toNativeSeparators(item) << "; then "; |
|
1628 t << cmd << " " << cmdOptions << " " << QDir::toNativeSeparators(item) << "; fi" << endl; |
|
1629 #endif |
|
1630 } |
|
1631 } |
|
1632 |
|
1633 void SymbianMakefileGenerator::removeSpecialCharacters(QString& str) |
|
1634 { |
|
1635 str.replace(QString("/"), QString("_")); |
|
1636 str.replace(QString("\\"), QString("_")); |
|
1637 str.replace(QString("-"), QString("_")); |
|
1638 str.replace(QString(":"), QString("_")); |
|
1639 str.replace(QString("."), QString("_")); |
|
1640 str.replace(QString(" "), QString("_")); |
|
1641 } |
|
1642 |
|
1643 void SymbianMakefileGenerator::writeSisTargets(QTextStream &t) |
|
1644 { |
|
1645 t << SIS_TARGET ": " RESTORE_BUILD_TARGET << endl; |
|
1646 QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \ |
|
1647 "$(MAKE) -s -f $(MAKEFILE) %4,$(MAKE) -s -f $(MAKEFILE) %5)," \ |
|
1648 "$(MAKE) -s -f $(MAKEFILE) %6)") |
|
1649 .arg(fixedTarget) |
|
1650 .arg("pkg") |
|
1651 .arg(MAKE_CACHE_NAME) |
|
1652 .arg(OK_SIS_TARGET) |
|
1653 .arg(FAIL_SIS_NOCACHE_TARGET) |
|
1654 .arg(FAIL_SIS_NOPKG_TARGET); |
|
1655 t << siscommand << endl; |
|
1656 t << endl; |
|
1657 |
|
1658 t << OK_SIS_TARGET ":" << endl; |
|
1659 |
|
1660 QString pkgcommand = QString("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \ |
|
1661 "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)") |
|
1662 .arg(fixedTarget) |
|
1663 .arg("pkg"); |
|
1664 t << pkgcommand << endl; |
|
1665 t << endl; |
|
1666 |
|
1667 t << FAIL_SIS_NOPKG_TARGET ":" << endl; |
|
1668 t << "\t$(error PKG file does not exist, 'SIS' target is only supported for executables or projects with DEPLOYMENT statement)" << endl; |
|
1669 t << endl; |
|
1670 |
|
1671 t << FAIL_SIS_NOCACHE_TARGET ":" << endl; |
|
1672 t << "\t$(error Project has to be build before calling 'SIS' target)" << endl; |
|
1673 t << endl; |
|
1674 |
|
1675 |
|
1676 t << RESTORE_BUILD_TARGET ":" << endl; |
|
1677 t << "-include " MAKE_CACHE_NAME << endl; |
|
1678 t << endl; |
|
1679 } |
|
1680 |
|
1681 void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t) |
|
1682 { |
|
1683 t << "dodistclean:" << endl; |
|
1684 foreach(QString item, project->values("SUBDIRS")) { |
|
1685 bool fromFile = false; |
|
1686 QString fixedItem; |
|
1687 if (!project->isEmpty(item + ".file")) { |
|
1688 fixedItem = project->first(item + ".file"); |
|
1689 fromFile = true; |
|
1690 } else if (!project->isEmpty(item + ".subdir")) { |
|
1691 fixedItem = project->first(item + ".subdir"); |
|
1692 fromFile = false; |
|
1693 } else { |
|
1694 fromFile = item.endsWith(Option::pro_ext); |
|
1695 fixedItem = item; |
|
1696 } |
|
1697 QFileInfo fi(fileInfo(fixedItem)); |
|
1698 if (!fromFile) { |
|
1699 t << "\t-$(MAKE) -f \"" << Option::fixPathToTargetOS(fi.absoluteFilePath() + "/Makefile") << "\" dodistclean" << endl; |
|
1700 } else { |
|
1701 QString itemName = fi.fileName(); |
|
1702 int extIndex = itemName.lastIndexOf(Option::pro_ext); |
|
1703 if (extIndex) |
|
1704 fixedItem = fi.absolutePath() + "/" + QString("Makefile.") + itemName.mid(0, extIndex); |
|
1705 t << "\t-$(MAKE) -f \"" << Option::fixPathToTargetOS(fixedItem) << "\" dodistclean" << endl; |
|
1706 } |
|
1707 |
|
1708 } |
|
1709 |
|
1710 generatedFiles << Option::fixPathToTargetOS(fileInfo(Option::output.fileName()).absoluteFilePath()); // bld.inf |
|
1711 generatedFiles << project->values("QMAKE_INTERNAL_PRL_FILE"); // Add generated prl files for cleanup |
|
1712 generatedFiles << project->values("QMAKE_DISTCLEAN"); // Add any additional files marked for distclean |
|
1713 QStringList fixedFiles; |
|
1714 QStringList fixedDirs; |
|
1715 foreach(QString item, generatedFiles) { |
|
1716 QString fixedItem = Option::fixPathToTargetOS(fileInfo(item).absoluteFilePath()); |
|
1717 if (!fixedFiles.contains(fixedItem)) { |
|
1718 fixedFiles << fixedItem; |
|
1719 } |
|
1720 } |
|
1721 foreach(QString item, generatedDirs) { |
|
1722 QString fixedItem = Option::fixPathToTargetOS(fileInfo(item).absoluteFilePath()); |
|
1723 if (!fixedDirs.contains(fixedItem)) { |
|
1724 fixedDirs << fixedItem; |
|
1725 } |
|
1726 } |
|
1727 generateCleanCommands(t, fixedFiles, "$(DEL_FILE)", "", "", ""); |
|
1728 generateCleanCommands(t, fixedDirs, "$(DEL_DIR)", "", "", ""); |
|
1729 t << endl; |
|
1730 |
|
1731 t << "distclean: clean dodistclean" << endl; |
|
1732 t << endl; |
|
1733 } |