source: trunk/qmake/generators/symbian/symmake_sbsv2.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 30.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the qmake application of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "symmake_sbsv2.h"
43#include "initprojectdeploy_symbian.h"
44
45#include <qstring.h>
46#include <qstringlist.h>
47#include <qdir.h>
48#include <qdatetime.h>
49#include <qdebug.h>
50
51// Included from tools/shared
52#include <symbian/epocroot_p.h>
53
54SymbianSbsv2MakefileGenerator::SymbianSbsv2MakefileGenerator() : SymbianMakefileGenerator() { }
55SymbianSbsv2MakefileGenerator::~SymbianSbsv2MakefileGenerator() { }
56
57#define FLM_DEST_DIR "epoc32/tools/makefile_templates/qt"
58#define FLM_SOURCE_DIR "/mkspecs/symbian-sbsv2/flm/qt"
59#define PLATFORM_GCCE "gcce"
60#define PLATFORM_WINSCW "winscw"
61#define PLATFORM_ARM_PREFIX "arm"
62#define BUILD_DEBUG "udeb"
63#define BUILD_RELEASE "urel"
64#define SBS_RVCT_PREFIX "rvct"
65
66static QString winscwPlatform;
67static QString armPlatformPrefix;
68static QString gccePlatform;
69static QString sbsRvctPrefix;
70
71#if defined(Q_OS_UNIX)
72 extern char **environ;
73#endif
74
75static void fixFlmCmd(QString *cmdLine, const QMap<QString, QString> &commandsToReplace)
76{
77 // If commandItem starts with any $$QMAKE_* commands, do a replace for SBS equivalent.
78 // Command replacement is done only for the start of the command or right after
79 // concatenation operators (&& and ||), as otherwise unwanted replacements might occur.
80 static QString cmdFind(QLatin1String("(^|&&\\s*|\\|\\|\\s*)%1"));
81 static QString cmdReplace(QLatin1String("\\1%1"));
82
83 // $$escape_expand(\\n\\t) doesn't work for bld.inf files, but is often used as command
84 // separator, so replace it with "&&" command concatenator.
85 cmdLine->replace("\n\t", "&&");
86
87 // Iterate command replacements in reverse alphabetical order of keys so
88 // that keys which are starts of other longer keys are iterated after longer keys.
89 QMapIterator<QString, QString> cmdIter(commandsToReplace);
90 cmdIter.toBack();
91 while (cmdIter.hasPrevious()) {
92 cmdIter.previous();
93 if (cmdLine->contains(cmdIter.key()))
94 cmdLine->replace(QRegExp(cmdFind.arg(cmdIter.key())), cmdReplace.arg(cmdIter.value()));
95 }
96
97 // Sbsv2 toolchain strips all backslashes (even double ones) from option parameters, so just
98 // assume all backslashes are directory separators and replace them with slashes.
99 // Problem: If some command actually needs backslashes for something else than dir separator,
100 // we are out of luck.
101 cmdLine->replace("\\", "/");
102}
103
104// Copies Qt FLMs to correct location under epocroot.
105// This is not done by configure as it is possible to change epocroot after configure.
106void SymbianSbsv2MakefileGenerator::exportFlm()
107{
108 static bool flmExportDone = false;
109
110 if (!flmExportDone) {
111 QDir sourceDir = QDir(QLibraryInfo::location(QLibraryInfo::PrefixPath) + FLM_SOURCE_DIR);
112 QFileInfoList sourceInfos = sourceDir.entryInfoList(QDir::Files);
113
114 QDir destDir(qt_epocRoot() + FLM_DEST_DIR);
115 if (!destDir.exists()) {
116 if (destDir.mkpath(destDir.absolutePath()))
117 generatedDirs << destDir.absolutePath();
118 }
119
120 foreach(QFileInfo item, sourceInfos) {
121 QFileInfo destInfo = QFileInfo(destDir.absolutePath() + "/" + item.fileName());
122 if (!destInfo.exists() || destInfo.lastModified() != item.lastModified()) {
123 if (destInfo.exists())
124 QFile::remove(destInfo.absoluteFilePath());
125 if (QFile::copy(item.absoluteFilePath(), destInfo.absoluteFilePath()))
126 generatedFiles << destInfo.absoluteFilePath();
127 else
128 fprintf(stderr, "Error: Could not copy '%s' -> '%s'\n",
129 qPrintable(item.absoluteFilePath()),
130 qPrintable(destInfo.absoluteFilePath()));
131 }
132 }
133 flmExportDone = true;
134 }
135}
136
137void SymbianSbsv2MakefileGenerator::findInstalledCompilerVersions(const QString &matchExpression,
138 const QString &versionPrefix,
139 QStringList *versionList)
140{
141 // No need to be able to find env variables on other operating systems,
142 // as only linux and windows have support for symbian-sbsv2 toolchain
143#if defined(Q_OS_UNIX) || defined(Q_OS_WIN)
144 char *entry = 0;
145 int count = 0;
146 QRegExp matcher(matchExpression);
147 while ((entry = environ[count++])) {
148 if (matcher.exactMatch(QString::fromLocal8Bit(entry))
149 && fileInfo(matcher.cap(matcher.captureCount())).exists()) {
150 // First capture (index 0) is the whole match, which is skipped.
151 // Next n captures are version numbers, which are interesting.
152 // Final capture is the env var value, which we already used, so that is skipped, too.
153 int capture = 1;
154 int finalCapture = matcher.captureCount() - 1;
155 QString version = versionPrefix;
156 while (capture <= finalCapture) {
157 version.append(matcher.cap(capture));
158 if (capture != finalCapture)
159 version.append(QLatin1Char('.'));
160 capture++;
161 }
162 *versionList << version;
163 }
164 }
165#endif
166}
167
168void SymbianSbsv2MakefileGenerator::findGcceVersions(QStringList *gcceVersionList,
169 QString *defaultVersion)
170{
171 QString matchStr = QLatin1String("SBS_GCCE(\\d)(\\d)(\\d)BIN=(.*)");
172 findInstalledCompilerVersions(matchStr, gccePlatform, gcceVersionList);
173
174 QString qtGcceVersion = QString::fromLocal8Bit(qgetenv("QT_GCCE_VERSION"));
175
176 if (!qtGcceVersion.isEmpty()) {
177 if (QRegExp("\\d+\\.\\d+\\.\\d+").exactMatch(qtGcceVersion)) {
178 *defaultVersion = gccePlatform + qtGcceVersion;
179 } else {
180 fprintf(stderr, "Warning: Variable QT_GCCE_VERSION ('%s') is in incorrect "
181 "format, expected format is: 'x.y.z'. Attempting to autodetect GCCE version.\n",
182 qPrintable(qtGcceVersion));
183 }
184 }
185
186 if (defaultVersion->isEmpty() && gcceVersionList->size()) {
187 gcceVersionList->sort();
188 *defaultVersion = gcceVersionList->last();
189 }
190}
191
192void SymbianSbsv2MakefileGenerator::findRvctVersions(QStringList *rvctVersionList,
193 QString *defaultVersion)
194{
195 QString matchStr = QLatin1String("RVCT(\\d)(\\d)BIN=(.*)");
196 findInstalledCompilerVersions(matchStr, sbsRvctPrefix, rvctVersionList);
197
198 QString qtRvctVersion = QString::fromLocal8Bit(qgetenv("QT_RVCT_VERSION"));
199
200 if (!qtRvctVersion.isEmpty()) {
201 if (QRegExp("\\d+\\.\\d+").exactMatch(qtRvctVersion)) {
202 *defaultVersion = sbsRvctPrefix + qtRvctVersion;
203 } else {
204 fprintf(stderr, "Warning: Variable QT_RVCT_VERSION ('%s') is in incorrect "
205 "format, expected format is: 'x.y'.\n",
206 qPrintable(qtRvctVersion));
207 }
208 }
209}
210
211QString SymbianSbsv2MakefileGenerator::configClause(const QString &platform,
212 const QString &build,
213 const QString &compilerVersion,
214 const QString &clauseTemplate)
215{
216 QString retval;
217 if (QString::compare(platform, winscwPlatform) == 0) {
218 retval = clauseTemplate.arg(build);
219 } else if (platform.startsWith(armPlatformPrefix)) {
220 QString fixedCompilerVersion = compilerVersion;
221 fixedCompilerVersion.replace(".","_");
222 retval = clauseTemplate.arg(platform.mid(sizeof(PLATFORM_ARM_PREFIX)-1))
223 .arg(build)
224 .arg(fixedCompilerVersion);
225 } // else - Unsupported platform for makefile target, return empty clause
226 return retval;
227}
228
229void SymbianSbsv2MakefileGenerator::writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t)
230{
231 for (int i = 0; i < depList.size(); ++i) {
232 t << "START EXTENSION qt/qmake_emulator_deployment" << endl;
233 QString fromItem = depList.at(i).from;
234 QString toItem = depList.at(i).to;
235 fromItem.replace("\\", "/");
236 toItem.replace("\\", "/");
237#if defined(Q_OS_WIN)
238 // add drive if it doesn't have one yet
239 if (toItem.size() > 1 && toItem[1] != QLatin1Char(':'))
240 toItem.prepend(QDir::current().absolutePath().left(2));
241#endif
242 t << "OPTION DEPLOY_SOURCE " << fromItem << endl;
243 t << "OPTION DEPLOY_TARGET " << toItem << endl;
244 t << "END" << endl;
245 }
246}
247
248void SymbianSbsv2MakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly)
249{
250 // Can't use extension makefile with sbsv2
251 Q_UNUSED(wrapperFileName);
252 Q_UNUSED(deploymentOnly);
253}
254
255void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile)
256{
257 static QString debugBuild;
258 static QString releaseBuild;
259 static QString defaultGcceCompilerVersion;
260 static QString defaultRvctCompilerVersion;
261 static QStringList rvctVersions;
262 static QStringList gcceVersions;
263 static QStringList allArmCompilerVersions;
264
265 // Initialize static variables used in makefile creation
266 if (debugBuild.isEmpty()) {
267 debugBuild.append(QLatin1String(BUILD_DEBUG));
268 releaseBuild.append(QLatin1String(BUILD_RELEASE));
269 winscwPlatform.append(QLatin1String(PLATFORM_WINSCW));
270 gccePlatform.append(QLatin1String(PLATFORM_GCCE));
271 armPlatformPrefix.append(QLatin1String(PLATFORM_ARM_PREFIX));
272 sbsRvctPrefix.append(QLatin1String(SBS_RVCT_PREFIX));
273
274 findGcceVersions(&gcceVersions, &defaultGcceCompilerVersion);
275 findRvctVersions(&rvctVersions, &defaultRvctCompilerVersion);
276
277 allArmCompilerVersions << rvctVersions << gcceVersions;
278
279 if (!allArmCompilerVersions.size()) {
280 fprintf(stderr, "Warning: No HW compilers detected. "
281 "Please install either GCCE or RVCT compiler to enable release builds.\n");
282 }
283 }
284
285 QStringList allPlatforms;
286 foreach(QString platform, project->values("SYMBIAN_PLATFORMS")) {
287 allPlatforms << platform.toLower();
288 }
289
290 if (!gcceVersions.size())
291 allPlatforms.removeAll(gccePlatform);
292
293 QString testClause;
294 if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
295 testClause = QLatin1String(".test");
296 else
297 testClause = QLatin1String("");
298
299 // Note: armClause is used for gcce, too, which has a side effect
300 // of requiring armv* platform(s) in SYMBIAN_PLATFORMS in order
301 // to get any compiler version specific targets.
302 QString armClause = " -c " PLATFORM_ARM_PREFIX ".%1.%2.%3" + testClause;
303 QString genericArmClause;
304 if (defaultRvctCompilerVersion.isEmpty()) {
305 // Note: Argument %3 needs to be empty string in this version of clause
306 genericArmClause = " -c " PLATFORM_ARM_PREFIX "%1_%2%3" + testClause;
307 } else {
308 // If defaultRvctCompilerVersion is defined, use specific sbs clause for "generic" clause
309 genericArmClause = armClause;
310 }
311 QString winscwClause = " -c " PLATFORM_WINSCW "_%1.mwccinc" + testClause;;
312
313 QStringList armPlatforms = allPlatforms.filter(QRegExp("^" PLATFORM_ARM_PREFIX));
314
315 if (!allArmCompilerVersions.size()) {
316 foreach (QString item, armPlatforms) {
317 allPlatforms.removeAll(item);
318 }
319 armPlatforms.clear();
320 }
321
322 QStringList allClauses;
323 QStringList debugClauses;
324 QStringList releaseClauses;
325
326 // Only winscw and arm platforms are supported
327 QStringList debugPlatforms = allPlatforms;
328 QStringList releasePlatforms = allPlatforms;
329 releasePlatforms.removeAll(winscwPlatform); // No release for emulator
330
331 if (!releasePlatforms.size()) {
332 fprintf(stderr, "Warning: No valid release platforms in SYMBIAN_PLATFORMS (%s)\n"
333 "Most likely required compiler(s) are not properly installed.\n",
334 qPrintable(project->values("SYMBIAN_PLATFORMS").join(" ")));
335 }
336
337 if (debugPlatforms.contains(winscwPlatform))
338 debugClauses << configClause(winscwPlatform, debugBuild, QString(), winscwClause);
339
340 foreach(QString item, armPlatforms) {
341 // Only use single clause per arm platform even if multiple compiler versions were found,
342 // otherwise we get makefile target collisions from sbsv2 toolchain.
343 if (rvctVersions.size()) {
344 debugClauses << configClause(item, debugBuild, defaultRvctCompilerVersion, genericArmClause);
345 releaseClauses << configClause(item, releaseBuild, defaultRvctCompilerVersion, genericArmClause);
346 } else {
347 debugClauses << configClause(item, debugBuild, defaultGcceCompilerVersion, armClause);
348 releaseClauses << configClause(item, releaseBuild, defaultGcceCompilerVersion, armClause);
349 }
350 }
351
352 allClauses << debugClauses << releaseClauses;
353
354 QTextStream t(&wrapperFile);
355
356 MakefileGenerator::writeHeader(t);
357
358 t << "MAKEFILE = " << fileInfo(wrapperFile.fileName()).fileName() << endl;
359 t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
360 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
361 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
362 t << "CHK_DIR_EXISTS = " << var("QMAKE_CHK_DIR_EXISTS") << endl;
363 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
364 t << "MOVE = " << var("QMAKE_MOVE") << endl;
365 t << "DEBUG_PLATFORMS = " << debugPlatforms.join(" ") << endl;
366 t << "RELEASE_PLATFORMS = " << releasePlatforms.join(" ") << endl;
367 t << "MAKE = make" << endl;
368 t << "SBS = sbs" << endl;
369 t << endl;
370 t << "DEFINES" << '\t' << " = "
371 << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
372 << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
373 << varGlue("DEFINES","-D"," -D","") << endl;
374
375 t << "INCPATH" << '\t' << " = ";
376
377 for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
378 QStringList values = it.value();
379 for (int i = 0; i < values.size(); ++i) {
380 t << " -I\"" << values.at(i) << "\" ";
381 }
382 }
383
384 t << endl;
385 t << "first: default" << endl << endl;
386 if (!isPrimaryMakefile) {
387 t << "all:" << endl << endl;
388 t << "default: all" << endl << endl;
389 } else {
390 t << "all: debug release" << endl << endl;
391 if (debugPlatforms.contains(winscwPlatform))
392 t << "default: debug-winscw";
393 else if (debugPlatforms.size())
394 t << "default: debug-" << debugPlatforms.first();
395 else
396 t << "default: all";
397 t << endl;
398
399 QString qmakeCmd = "\t$(QMAKE) \"" + project->projectFile() + "\" " + buildArgs();
400
401 t << "qmake:" << endl;
402 t << qmakeCmd << endl;
403 t << endl;
404
405 t << BLD_INF_FILENAME ": " << project->projectFile() << endl;
406 t << qmakeCmd << endl;
407 t << endl;
408
409 QString locFileDep = generateLocFileTarget(t, qmakeCmd);
410
411 t << "debug: " << locFileDep << BLD_INF_FILENAME << endl;
412 t << "\t$(SBS)";
413 foreach(QString clause, debugClauses) {
414 t << clause;
415 }
416 t << endl;
417 t << "clean-debug: " << BLD_INF_FILENAME << endl;
418 t << "\t$(SBS) reallyclean --toolcheck=off";
419 foreach(QString clause, debugClauses) {
420 t << clause;
421 }
422 t << endl;
423
424 t << "freeze-debug: " << BLD_INF_FILENAME << endl;
425 t << "\t$(SBS) freeze";
426 foreach(QString clause, debugClauses) {
427 t << clause;
428 }
429 t << endl;
430
431 t << "release: " << locFileDep << BLD_INF_FILENAME << endl;
432 t << "\t$(SBS)";
433 foreach(QString clause, releaseClauses) {
434 t << clause;
435 }
436 t << endl;
437 t << "clean-release: " << BLD_INF_FILENAME << endl;
438 t << "\t$(SBS) reallyclean --toolcheck=off";
439 foreach(QString clause, releaseClauses) {
440 t << clause;
441 }
442 t << endl;
443
444 t << "freeze-release: " << BLD_INF_FILENAME << endl;
445 t << "\t$(SBS) freeze";
446 foreach(QString clause, releaseClauses) {
447 t << clause;
448 }
449 t << endl << endl;
450
451 QString defaultGcceArmVersion;
452 if (armPlatforms.size()) {
453 defaultGcceArmVersion = armPlatforms.first();
454 } else {
455 defaultGcceArmVersion = QLatin1String("armv5");
456 }
457
458 // For more specific builds, targets are in this form:
459 // release-armv5 - generic target, compiler version determined by toolchain or autodetection
460 // release-armv5-rvct4.0 - compiler version specific target
461 foreach(QString item, debugPlatforms) {
462 QString clause;
463 if (item.compare(winscwPlatform) == 0)
464 clause = configClause(item, debugBuild, QString(), winscwClause);
465 else if (item.compare(gccePlatform) == 0 )
466 clause = configClause(defaultGcceArmVersion, debugBuild, defaultGcceCompilerVersion, armClause);
467 else // use generic arm clause
468 clause = configClause(item, debugBuild, defaultRvctCompilerVersion, genericArmClause);
469
470 t << "debug-" << item << ": " << locFileDep << BLD_INF_FILENAME << endl;
471 t << "\t$(SBS)" << clause << endl;
472 t << "clean-debug-" << item << ": " << BLD_INF_FILENAME << endl;
473 t << "\t$(SBS) reallyclean" << clause << endl;
474 t << "freeze-debug-" << item << ": " << BLD_INF_FILENAME << endl;
475 t << "\t$(SBS) freeze" << clause << endl;
476 }
477
478 foreach(QString item, releasePlatforms) {
479 QString clause;
480 if (item.compare(gccePlatform) == 0 )
481 clause = configClause(defaultGcceArmVersion, releaseBuild, defaultGcceCompilerVersion, armClause);
482 else // use generic arm clause
483 clause = configClause(item, releaseBuild, defaultRvctCompilerVersion, genericArmClause);
484
485 t << "release-" << item << ": " << locFileDep << BLD_INF_FILENAME << endl;
486 t << "\t$(SBS)" << clause << endl;
487 t << "clean-release-" << item << ": " << BLD_INF_FILENAME << endl;
488 t << "\t$(SBS) reallyclean" << clause << endl;
489 t << "freeze-release-" << item << ": " << BLD_INF_FILENAME << endl;
490 t << "\t$(SBS) freeze" << clause << endl;
491 }
492
493 foreach(QString item, armPlatforms) {
494 foreach(QString compilerVersion, allArmCompilerVersions) {
495 QString debugClause = configClause(item, debugBuild, compilerVersion, armClause);
496 QString releaseClause = configClause(item, releaseBuild, compilerVersion, armClause);
497 t << "debug-" << item << "-" << compilerVersion << ": " << locFileDep << BLD_INF_FILENAME << endl;
498 t << "\t$(SBS)" << debugClause << endl;
499 t << "clean-debug-" << item << "-" << compilerVersion << ": " << BLD_INF_FILENAME << endl;
500 t << "\t$(SBS) reallyclean" << debugClause << endl;
501 t << "freeze-debug-" << item << "-" << compilerVersion << ": " << BLD_INF_FILENAME << endl;
502 t << "\t$(SBS) freeze" << debugClause << endl;
503 t << "release-" << item << "-" << compilerVersion << ": " << locFileDep << BLD_INF_FILENAME << endl;
504 t << "\t$(SBS)" << releaseClause << endl;
505 t << "clean-release-" << item << "-" << compilerVersion << ": " << BLD_INF_FILENAME << endl;
506 t << "\t$(SBS) reallyclean" << releaseClause << endl;
507 t << "freeze-release-" << item << "-" << compilerVersion << ": " << BLD_INF_FILENAME << endl;
508 t << "\t$(SBS) freeze" << releaseClause << endl;
509 }
510 }
511
512 t << endl;
513 t << "export: " << BLD_INF_FILENAME << endl;
514 t << "\t$(SBS) export";
515 foreach(QString clause, allClauses) {
516 t << clause;
517 }
518 t << endl << endl;
519
520 t << "cleanexport: " << BLD_INF_FILENAME << endl;
521 t << "\t$(SBS) cleanexport";
522 foreach(QString clause, allClauses) {
523 t << clause;
524 }
525 t << endl << endl;
526
527 // Typically one wants to freeze release binaries, so make plain freeze target equal to
528 // freeze-release. If freezing of debug binaries is needed for some reason, then
529 // freeze-debug target should be used. There is no point to try freezing both with one
530 // target as both produce the same def file.
531 t << "freeze: freeze-release" << endl << endl;
532 }
533
534 // Add all extra targets including extra compiler targets also to wrapper makefile,
535 // even though many of them may have already been added to bld.inf as FLMs.
536 // This is to enable use of targets like 'mocables', which call targets generated by extra compilers.
537 if (targetType != TypeSubdirs) {
538 t << extraTargetsCache;
539 t << extraCompilersCache;
540 } else {
541 QList<MakefileGenerator::SubTarget*> subtargets = findSubDirsSubTargets();
542 writeSubTargets(t, subtargets, SubTargetSkipDefaultVariables|SubTargetSkipDefaultTargets);
543 qDeleteAll(subtargets);
544 }
545
546 generateDistcleanTargets(t);
547
548 // Do not check for tools when doing generic clean, as most tools are not actually needed for
549 // cleaning. Mainly this is relevant for environments that do not have winscw compiler.
550 t << "clean: " << BLD_INF_FILENAME << endl;
551 t << "\t-$(SBS) reallyclean --toolcheck=off";
552 foreach(QString clause, allClauses) {
553 t << clause;
554 }
555 t << endl << endl;
556
557 t << endl;
558}
559
560void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile)
561{
562 // Makes sure we have needed FLMs in place.
563 exportFlm();
564
565 // Parse extra compilers data
566 QStringList defines;
567 QStringList incPath;
568
569 defines << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
570 << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
571 << varGlue("DEFINES","-D"," -D","");
572 for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
573 QStringList values = it.value();
574 for (int i = 0; i < values.size(); ++i) {
575 incPath << QLatin1String(" -I\"") + values.at(i) + "\"";
576 }
577 }
578
579 QMap<QString, QString> commandsToReplace;
580 commandsToReplace.insert(project->values("QMAKE_COPY").join(" "),
581 project->values("QMAKE_SBSV2_COPY").join(" "));
582 commandsToReplace.insert(project->values("QMAKE_COPY_DIR").join(" "),
583 project->values("QMAKE_SBSV2_COPY_DIR").join(" "));
584 commandsToReplace.insert(project->values("QMAKE_MOVE").join(" "),
585 project->values("QMAKE_SBSV2_MOVE").join(" "));
586 commandsToReplace.insert(project->values("QMAKE_DEL_FILE").join(" "),
587 project->values("QMAKE_SBSV2_DEL_FILE").join(" "));
588 commandsToReplace.insert(project->values("QMAKE_MKDIR").join(" "),
589 project->values("QMAKE_SBSV2_MKDIR").join(" "));
590 commandsToReplace.insert(project->values("QMAKE_DEL_DIR").join(" "),
591 project->values("QMAKE_SBSV2_DEL_DIR").join(" "));
592 commandsToReplace.insert(project->values("QMAKE_DEL_TREE").join(" "),
593 project->values("QMAKE_SBSV2_DEL_TREE").join(" "));
594
595 // Write extra compilers and targets to initialize QMAKE_ET_* variables
596 // Cache results to avoid duplicate calls when creating wrapper makefile
597 QTextStream extraCompilerStream(&extraCompilersCache);
598 QTextStream extraTargetStream(&extraTargetsCache);
599 writeExtraCompilerTargets(extraCompilerStream);
600 writeExtraTargets(extraTargetStream);
601
602 // Figure out everything the target depends on as we don't want to run extra targets that
603 // are not necessary.
604 QStringList allPreDeps;
605 foreach(QString item, project->values("PRE_TARGETDEPS")) {
606 allPreDeps.append(fileInfo(item).absoluteFilePath());
607 }
608
609 foreach (QString item, project->values("GENERATED_SOURCES")) {
610 allPreDeps.append(fileInfo(item).absoluteFilePath());
611 }
612
613 for (QMap<QString, QStringList>::iterator it = sources.begin(); it != sources.end(); ++it) {
614 QString currentSourcePath = it.key();
615 QStringList values = it.value();
616 for (int i = 0; i < values.size(); ++i) {
617 QString sourceFile = currentSourcePath + "/" + values.at(i);
618 QStringList deps = findDependencies(QDir::toNativeSeparators(sourceFile));
619 foreach(QString depItem, deps) {
620 appendIfnotExist(allPreDeps, fileInfo(depItem).absoluteFilePath());
621 }
622 }
623 }
624
625 // Write FLM rules for all extra targets and compilers that we depend on to build the target.
626 QStringList extraTargets;
627 extraTargets << project->values("QMAKE_EXTRA_TARGETS") << project->values("QMAKE_EXTRA_COMPILERS");
628 foreach(QString item, extraTargets) {
629 foreach(QString targetItem, project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_TARGETS.") + item)) {
630 // Make sure targetpath is absolute
631 QString absoluteTarget = fileInfo(targetItem).absoluteFilePath();
632 if (allPreDeps.contains(absoluteTarget)) {
633 QStringList deps = project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_DEPS.") + item + targetItem);
634 QString commandItem = project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_CMD.") + item + targetItem).join(" ");
635
636 // Make sure all deps paths are absolute
637 QString absoluteDeps;
638 foreach (QString depItem, deps) {
639 if (!depItem.isEmpty()) {
640 absoluteDeps.append(fileInfo(depItem).absoluteFilePath());
641 absoluteDeps.append(" ");
642 }
643 }
644
645 t << "START EXTENSION qt/qmake_extra_pre_targetdep.export" << endl;
646 t << "OPTION PREDEP_TARGET " << absoluteTarget << endl;
647 t << "OPTION DEPS " << absoluteDeps << endl;
648
649 if (commandItem.indexOf("$(INCPATH)") != -1)
650 commandItem.replace("$(INCPATH)", incPath.join(" "));
651 if (commandItem.indexOf("$(DEFINES)") != -1)
652 commandItem.replace("$(DEFINES)", defines.join(" "));
653
654 fixFlmCmd(&commandItem, commandsToReplace);
655
656 t << "OPTION COMMAND " << commandItem << endl;
657 t << "END" << endl;
658 }
659 }
660 }
661
662 t << endl;
663
664 // Write deployment rules
665 QString remoteTestPath = qt_epocRoot() + QLatin1String("epoc32/winscw/c/private/") + privateDirUid;
666 DeploymentList depList;
667
668 //write emulator deployment
669 t << "#if defined(WINSCW)" << endl;
670 initProjectDeploySymbian(project, depList, remoteTestPath, false, true,
671 QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles);
672 writeSbsDeploymentList(depList, t);
673 t << "#endif" << endl;
674
675 //write ROM deployment
676 remoteTestPath = qt_epocRoot() + QLatin1String("epoc32/data/z/private/") + privateDirUid;
677 depList.clear();
678 initProjectDeploySymbian(project, depList, remoteTestPath, false, true,
679 QLatin1String(ROM_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles);
680 writeSbsDeploymentList(depList, t);
681 t << endl;
682
683 // Write post link rules
684 if (!project->isEmpty("QMAKE_POST_LINK")) {
685 QString postLinkCmd = var("QMAKE_POST_LINK");
686 fixFlmCmd(&postLinkCmd, commandsToReplace);
687 t << "START EXTENSION qt/qmake_post_link" << endl;
688 t << "OPTION POST_LINK_CMD " << postLinkCmd << endl;
689 t << "OPTION LINK_TARGET " << fixedTarget << QLatin1String(".") << getTargetExtension() << endl;
690 t << "END" << endl;
691 t << endl;
692 }
693
694 // Application icon generation
695 QStringList icons = project->values("ICON");
696 if (icons.size()) {
697 QString icon = icons.first();
698 if (icons.size() > 1)
699 fprintf(stderr, "Warning: Only first icon specified in ICON variable is used: '%s'.", qPrintable(icon));
700
701 t << "START EXTENSION s60/mifconv" << endl;
702
703 QFileInfo iconInfo = fileInfo(icon);
704
705 QFileInfo bldinf(project->values("MAKEFILE").first());
706 QString iconPath = bldinf.dir().relativeFilePath(iconInfo.path());
707
708 QString iconFile = iconInfo.baseName();
709
710 QFileInfo iconTargetInfo = fileInfo(iconTargetFile);
711 QString iconTarget = iconTargetInfo.fileName();
712
713 t << "OPTION SOURCES -c32 " << iconFile << endl;
714 t << "OPTION SOURCEDIR " << iconPath << endl;
715 t << "OPTION TARGETFILE " << iconTarget << endl;
716 t << "OPTION SVGENCODINGVERSION 3" << endl; // Compatibility with S60 3.1 devices and up
717 t << "END" << endl;
718 }
719
720 t << "START EXTENSION qt/qmake_store_build" << endl;
721 t << "END" << endl;
722 t << endl;
723
724 t << endl;
725}
726
727void SymbianSbsv2MakefileGenerator::writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension)
728{
729 // We don't generate extension makefile in sbsb2
730 Q_UNUSED(t);
731 Q_UNUSED(addDeploymentExtension);
732}
733
734void SymbianSbsv2MakefileGenerator::appendAbldTempDirs(QStringList& sysincspaths, QString includepath)
735{
736 //Do nothing
737 Q_UNUSED(sysincspaths);
738 Q_UNUSED(includepath);
739}
Note: See TracBrowser for help on using the repository browser.