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

Last change on this file since 591 was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 17.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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 [email protected].
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
51SymbianSbsv2MakefileGenerator::SymbianSbsv2MakefileGenerator() : SymbianMakefileGenerator() { }
52SymbianSbsv2MakefileGenerator::~SymbianSbsv2MakefileGenerator() { }
53
54#define FLM_DEST_DIR "epoc32/tools/makefile_templates/qt"
55#define FLM_SOURCE_DIR "/mkspecs/symbian-sbsv2/flm/qt"
56
57// Copies Qt FLMs to correct location under epocroot.
58// This is not done by configure as it is possible to change epocroot after configure.
59void SymbianSbsv2MakefileGenerator::exportFlm()
60{
61 static bool flmExportDone = false;
62
63 if (!flmExportDone) {
64 QDir sourceDir = QDir(QLibraryInfo::location(QLibraryInfo::PrefixPath) + FLM_SOURCE_DIR);
65 QFileInfoList sourceInfos = sourceDir.entryInfoList(QDir::Files);
66
67 QDir destDir(epocRoot() + FLM_DEST_DIR);
68 if (!destDir.exists()) {
69 if (destDir.mkpath(destDir.absolutePath()))
70 generatedDirs << destDir.absolutePath();
71 }
72
73 foreach(QFileInfo item, sourceInfos) {
74 QFileInfo destInfo = QFileInfo(destDir.absolutePath() + "/" + item.fileName());
75 if (!destInfo.exists() || destInfo.lastModified() < item.lastModified()) {
76 if (destInfo.exists())
77 QFile::remove(destInfo.absoluteFilePath());
78 if (QFile::copy(item.absoluteFilePath(), destInfo.absoluteFilePath()))
79 generatedFiles << destInfo.absoluteFilePath();
80 else
81 fprintf(stderr, "Error: Could not copy '%s' -> '%s'\n",
82 qPrintable(item.absoluteFilePath()),
83 qPrintable(destInfo.absoluteFilePath()));
84 }
85 }
86 flmExportDone = true;
87 }
88}
89
90void SymbianSbsv2MakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly)
91{
92 // Can't use extension makefile with sbsv2
93 Q_UNUSED(wrapperFileName);
94 Q_UNUSED(deploymentOnly);
95}
96
97void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile)
98{
99 QStringList allPlatforms;
100 foreach(QString platform, project->values("SYMBIAN_PLATFORMS")) {
101 allPlatforms << platform.toLower();
102 }
103
104 QStringList debugPlatforms = allPlatforms;
105 QStringList releasePlatforms = allPlatforms;
106 releasePlatforms.removeAll("winscw"); // No release for emulator
107
108 QString testClause;
109 if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive))
110 testClause = QLatin1String(".test");
111 else
112 testClause = QLatin1String("");
113
114 QTextStream t(&wrapperFile);
115
116 t << "# ==============================================================================" << endl;
117 t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: ";
118 t << QDateTime::currentDateTime().toString() << endl;
119 t << "# This file is generated by qmake and should not be modified by the" << endl;
120 t << "# user." << endl;
121 t << "# Name : " << wrapperFile.fileName() << endl;
122 t << "# Description : Wrapper Makefile for calling Symbian build tools" << endl;
123 t << "#" << endl;
124 t << "# ==============================================================================" << "\n" << endl;
125 t << endl;
126 t << "MAKEFILE = " << wrapperFile.fileName() << endl;
127 t << "QMAKE = " << Option::fixPathToTargetOS(var("QMAKE_QMAKE")) << endl;
128 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
129 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
130 t << "MOVE = " << var("QMAKE_MOVE") << endl;
131 t << "DEBUG_PLATFORMS = " << debugPlatforms.join(" ") << endl;
132 t << "RELEASE_PLATFORMS = " << releasePlatforms.join(" ") << endl;
133 t << "MAKE = make" << endl;
134 t << "SBS = sbs" << endl;
135 t << endl;
136 t << "DEFINES" << '\t' << " = "
137 << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
138 << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
139 << varGlue("DEFINES","-D"," -D","") << endl;
140
141 t << "INCPATH" << '\t' << " = ";
142
143 for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
144 QStringList values = it.value();
145 for (int i = 0; i < values.size(); ++i) {
146 t << " -I\"" << values.at(i) << "\" ";
147 }
148 }
149 t << endl;
150 t << "first: default" << endl;
151 if (debugPlatforms.contains("winscw"))
152 t << "default: debug-winscw";
153 else if (debugPlatforms.contains("armv5"))
154 t << "default: debug-armv5";
155 else if (debugPlatforms.size())
156 t << "default: debug-" << debugPlatforms.first();
157 else
158 t << "default: all";
159
160 t << endl;
161 if (!isPrimaryMakefile) {
162 t << "all:" << endl;
163 } else {
164 t << "all: debug release" << endl;
165 t << endl;
166 t << "qmake:" << endl;
167 t << "\t$(QMAKE) -spec symbian-sbsv2 -o \"" << fileInfo(Option::output.fileName()).fileName()
168 << "\" \"" << project->projectFile() << "\"" << endl;
169 t << endl;
170 t << BLD_INF_FILENAME ":" << endl;
171 t << "\t$(QMAKE)" << endl;
172 t << endl;
173
174 QString winscw("winscw");
175 t << "debug: " << BLD_INF_FILENAME << endl;
176 t << "\t$(SBS)";
177 foreach(QString item, debugPlatforms) {
178 if(QString::compare(item, winscw) == 0)
179 t << " -c " << item << "_udeb.mwccinc" << testClause;
180 else
181 t << " -c " << item << "_udeb" << testClause;
182 }
183 t << endl;
184 t << "release: " << BLD_INF_FILENAME << endl;
185 t << "\t$(SBS)";
186 foreach(QString item, releasePlatforms) {
187 if(QString::compare(item, winscw) == 0)
188 t << " -c " << item << "_urel.mwccinc" << testClause;
189 else
190 t << " -c " << item << "_urel" << testClause;
191 }
192 t << endl;
193
194 // For more specific builds, targets are in this form: build-platform, e.g. release-armv5
195 foreach(QString item, debugPlatforms) {
196 t << "debug-" << item << ": " << BLD_INF_FILENAME << endl;
197 if(QString::compare(item, winscw) == 0)
198 t << "\t$(SBS) -c " << item << "_udeb.mwccinc" << testClause << endl;
199 else
200 t << "\t$(SBS) -c " << item << "_udeb" << testClause << endl;
201 }
202
203 foreach(QString item, releasePlatforms) {
204 t << "release-" << item << ": " << BLD_INF_FILENAME << endl;
205 if(QString::compare(item, winscw) == 0)
206 t << "\t$(SBS) -c " << item << "_urel.mwccinc" << testClause << endl;
207 else
208 t << "\t$(SBS) -c " << item << "_urel" << testClause << endl;
209 }
210
211 t << endl;
212 t << "export: " << BLD_INF_FILENAME << endl;
213 t << "\t$(SBS) export" << endl;
214 t << endl;
215
216 t << "cleanexport: " << BLD_INF_FILENAME << endl;
217 t << "\t$(SBS) cleanexport" << endl;
218 t << endl;
219
220 }
221
222 // Add all extra targets including extra compiler targest also to wrapper makefile,
223 // even though many of them may have already been added to bld.inf as FLMs.
224 // This is to enable use of targets like 'mocables', which call targets generated by extra compilers.
225 if (targetType != TypeSubdirs) {
226 t << extraTargetsCache;
227 t << extraCompilersCache;
228 } else {
229 QList<MakefileGenerator::SubTarget*> subtargets = findSubDirsSubTargets();
230 writeSubTargets(t, subtargets, SubTargetSkipDefaultVariables|SubTargetSkipDefaultTargets);
231 qDeleteAll(subtargets);
232 }
233
234 writeSisTargets(t);
235
236 generateDistcleanTargets(t);
237
238 t << "clean: " << BLD_INF_FILENAME << endl;
239 t << "\t-$(SBS) reallyclean" << endl;
240 t << endl;
241
242 t << "clean-debug: " << BLD_INF_FILENAME << endl;
243 t << "\t$(SBS) reallyclean";
244 foreach(QString item, debugPlatforms) {
245 t << " -c " << item << "_udeb" << testClause;
246 }
247 t << endl;
248 t << "clean-release: " << BLD_INF_FILENAME << endl;
249 t << "\t$(SBS) reallyclean";
250 foreach(QString item, releasePlatforms) {
251 t << " -c " << item << "_urel" << testClause;
252 }
253 t << endl;
254
255 // For more specific builds, targets are in this form: clean-build-platform, e.g. clean-release-armv5
256 foreach(QString item, debugPlatforms) {
257 t << "clean-debug-" << item << ": " << BLD_INF_FILENAME << endl;
258 t << "\t$(SBS) reallyclean -c " << item << "_udeb" << testClause << endl;
259 }
260 foreach(QString item, releasePlatforms) {
261 t << "clean-release-" << item << ": " << BLD_INF_FILENAME << endl;
262 t << "\t$(SBS) reallyclean -c " << item << "_urel" << testClause << endl;
263 }
264 t << endl;
265
266 generateExecutionTargets(t, debugPlatforms);
267}
268
269void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile)
270{
271 // Makes sure we have needed FLMs in place.
272 exportFlm();
273
274 // Parse extra compilers data
275 QStringList defines;
276 QStringList incPath;
277
278 defines << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
279 << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
280 << varGlue("DEFINES","-D"," -D","");
281 for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
282 QStringList values = it.value();
283 for (int i = 0; i < values.size(); ++i) {
284 incPath << QLatin1String(" -I\"") + values.at(i) + "\"";
285 }
286 }
287
288 // Write extra compilers and targets to initialize QMAKE_ET_* variables
289 // Cache results to avoid duplicate calls when creating wrapper makefile
290 QTextStream extraCompilerStream(&extraCompilersCache);
291 QTextStream extraTargetStream(&extraTargetsCache);
292 writeExtraCompilerTargets(extraCompilerStream);
293 writeExtraTargets(extraTargetStream);
294
295 // Figure out everything the target depends on as we don't want to run extra targets that
296 // are not necessary.
297 QStringList allPreDeps;
298 foreach(QString item, project->values("PRE_TARGETDEPS")) {
299 // Predeps get mangled in windows, so fix them to more sbsv2 friendly format
300#if defined(Q_OS_WIN)
301 if (item.mid(1, 1) == ":")
302 item = item.mid(0, 1).toUpper().append(item.mid(1)); // Fix drive to uppercase
303#endif
304 item.replace("\\", "/");
305 allPreDeps << escapeDependencyPath(item);
306 }
307
308 foreach (QString item, project->values("GENERATED_SOURCES")) {
309 allPreDeps.append(fileInfo(item).absoluteFilePath());
310 }
311
312 for (QMap<QString, QStringList>::iterator it = sources.begin(); it != sources.end(); ++it) {
313 QString currentSourcePath = it.key();
314 QStringList values = it.value();
315 for (int i = 0; i < values.size(); ++i) {
316 QString sourceFile = currentSourcePath + "/" + values.at(i);
317 QStringList deps = findDependencies(QDir::toNativeSeparators(sourceFile));
318 foreach(QString depItem, deps) {
319 appendIfnotExist(allPreDeps, fileInfo(depItem).absoluteFilePath());
320 }
321 }
322 }
323
324 // Write FLM rules for all extra targets and compilers that we depend on to build the target.
325 QStringList extraTargets;
326 extraTargets << project->values("QMAKE_EXTRA_TARGETS") << project->values("QMAKE_EXTRA_COMPILERS");
327 foreach(QString item, extraTargets) {
328 foreach(QString targetItem, project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_TARGETS.") + item)) {
329 // Make sure targetpath is absolute
330 QString absoluteTarget = fileInfo(targetItem).absoluteFilePath();
331 if (allPreDeps.contains(absoluteTarget)) {
332 QStringList deps = project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_DEPS.") + item + targetItem);
333 QString commandItem = project->values(QLatin1String("QMAKE_INTERNAL_ET_PARSED_CMD.") + item + targetItem).join(" ");
334
335
336 // Make sure all deps paths are absolute
337 QString absoluteDeps;
338 foreach (QString depItem, deps) {
339 if (!depItem.isEmpty()) {
340 absoluteDeps.append(fileInfo(depItem).absoluteFilePath());
341 absoluteDeps.append(" ");
342 }
343 }
344
345 t << "START EXTENSION qt/qmake_extra_pre_targetdep" << endl;
346 t << "OPTION PREDEP_TARGET " << absoluteTarget << endl;
347 t << "OPTION DEPS " << absoluteDeps << endl;
348
349 if (commandItem.indexOf("$(INCPATH)") != -1)
350 commandItem.replace("$(INCPATH)", incPath.join(" "));
351 if (commandItem.indexOf("$(DEFINES)") != -1)
352 commandItem.replace("$(DEFINES)", defines.join(" "));
353
354 // Sbsv2 strips all backslashes (even doubles ones) from option parameters, so just replace them with slashes
355 // Problem: If some command actually needs backslashes for something else than dir separator, we are out of luck...
356 commandItem.replace("\\", "/");
357 t << "OPTION COMMAND " << commandItem << endl;
358 t << "END" << endl;
359 }
360 }
361 }
362
363 t << endl;
364
365 // Write winscw deployment rules
366 QString remoteTestPath = epocRoot() + QLatin1String("epoc32/winscw/c/private/") + privateDirUid;
367 DeploymentList depList;
368 initProjectDeploySymbian(project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles);
369
370 t << "#if defined(WINSCW)" << endl;
371 for (int i = 0; i < depList.size(); ++i) {
372 t << "START EXTENSION qt/qmake_emulator_deployment" << endl;
373 QString fromItem = depList.at(i).from;
374 QString toItem = depList.at(i).to;
375 fromItem.replace("\\", "/");
376 toItem.replace("\\", "/");
377#if defined(Q_OS_WIN)
378 toItem.prepend(QDir::current().absolutePath().left(2)); // add drive
379#endif
380 t << "OPTION DEPLOY_SOURCE " << fromItem << endl;
381 t << "OPTION DEPLOY_TARGET " << toItem << endl;
382 t << "END" << endl;
383 }
384 t << "#endif" << endl;
385
386 t << endl;
387
388 // Write post link rules
389 if (!project->isEmpty("QMAKE_POST_LINK")) {
390 t << "START EXTENSION qt/qmake_post_link" << endl;
391 t << "OPTION POST_LINK_CMD " << var("QMAKE_POST_LINK") << endl;
392 t << "OPTION LINK_TARGET " << removePathSeparators(escapeFilePath(fileFixify(project->first("TARGET"))).append(".").append(getTargetExtension())) << endl;
393 t << "END" << endl;
394 t << endl;
395 }
396
397 // Application icon generation
398 QStringList icons = project->values("ICON");
399 if (icons.size()) {
400 QString icon = icons.first();
401 if (icons.size() > 1)
402 fprintf(stderr, "Warning: Only first icon specified in ICON variable is used: '%s'.", qPrintable(icon));
403
404 t << "START EXTENSION s60/mifconv" << endl;
405
406 QFileInfo iconInfo = fileInfo(icon);
407
408 QFileInfo bldinf(project->values("MAKEFILE").first());
409 QString iconPath = bldinf.dir().relativeFilePath(iconInfo.path());
410
411 QString iconFile = iconInfo.baseName();
412
413 QFileInfo iconTargetInfo = fileInfo(iconTargetFile);
414 QString iconTarget = iconTargetInfo.fileName();
415
416 t << "OPTION SOURCES -c32 " << iconFile << endl;
417 t << "OPTION SOURCEDIR " << iconPath << endl;
418 t << "OPTION TARGETFILE " << iconTarget << endl;
419 t << "OPTION SVGENCODINGVERSION 3" << endl; // Compatibility with S60 3.1 devices and up
420 t << "END" << endl;
421 }
422
423 t << "START EXTENSION qt/qmake_store_build" << endl;
424 t << "END" << endl;
425 t << endl;
426
427 t << endl;
428}
429
430void SymbianSbsv2MakefileGenerator::writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension)
431{
432 // We don't generate extension makefile in sbsb2
433 Q_UNUSED(t);
434 Q_UNUSED(addDeploymentExtension);
435}
436
437void SymbianSbsv2MakefileGenerator::appendAbldTempDirs(QStringList& sysincspaths, QString includepath)
438{
439 //Do nothing
440 Q_UNUSED(sysincspaths);
441 Q_UNUSED(includepath);
442}
Note: See TracBrowser for help on using the repository browser.