summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-08-19 12:34:28 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-08-19 12:34:28 (GMT)
commite7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e (patch)
tree6e7a4cc2e237c847a28b3d97549abe0762f6795d /qmake
parenta1cfdc273bac90d58754c286810353ccb0be4b2e (diff)
downloadQt-e7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e.zip
Qt-e7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e.tar.gz
Qt-e7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e.tar.bz2
Review fixes for qmake (project.cpp cleanup)
Removed symbian specific functionality from project.cpp: - generate_test_uid qmake function removed - Uids are now generated automatically for projects that don't have one. - Usage of ICON (in application_icon.prf) now requires explicit UID3 definition. - Autotests that require UID3 in .pro now define it explicitly - Move most symbian specific function implementations away from project.cpp to files under generators/symbian Reviewed-by: Janne Anttila
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/symbian/epocroot.h51
-rw-r--r--qmake/generators/symbian/initprojectdeploy_symbian.cpp133
-rw-r--r--qmake/generators/symbian/initprojectdeploy_symbian.h5
-rw-r--r--qmake/generators/symbian/symmake.cpp5
-rw-r--r--qmake/project.cpp169
-rw-r--r--qmake/project.h5
-rw-r--r--qmake/qmake.pri1
7 files changed, 197 insertions, 172 deletions
diff --git a/qmake/generators/symbian/epocroot.h b/qmake/generators/symbian/epocroot.h
new file mode 100644
index 0000000..02884b1
--- /dev/null
+++ b/qmake/generators/symbian/epocroot.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake application of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EPOCROOT_H
+#define EPOCROOT_H
+
+#include <qstring.h>
+
+// Implementation of epocRoot method is in initprojectdeploy_symbian.cpp
+// Defined in separate header for inclusion clarity
+extern QString epocRoot();
+
+#endif // EPOCROOT_H
diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp
index 392eca2..7b58adc 100644
--- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp
+++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp
@@ -42,6 +42,8 @@
#include "initprojectdeploy_symbian.h"
#include <QDirIterator>
#include <project.h>
+#include <qxmlstream.h>
+#include <qsettings.h>
#include <qdebug.h>
#define PLUGIN_STUB_DIR "qmakepluginstubs"
@@ -51,6 +53,99 @@
#define SUFFIX_EXE "exe"
#define SUFFIX_QTPLUGIN "qtplugin"
+static void fixEpocRootStr(QString& path)
+{
+ path.replace("\\", "/");
+
+ if (path.size() > 1 && path[1] == QChar(':')) {
+ path = path.mid(2);
+ }
+
+ if (!path.size() || path[path.size()-1] != QChar('/')) {
+ path += QChar('/');
+ }
+}
+
+#define SYMBIAN_SDKS_KEY "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs"
+
+static QString epocRootStr;
+
+QString epocRoot()
+{
+ if (!epocRootStr.isEmpty()) {
+ return epocRootStr;
+ }
+
+ // First, check the env variable
+ epocRootStr = qgetenv("EPOCROOT");
+
+ if (epocRootStr.isEmpty()) {
+ // No EPOCROOT set, check the default device
+ // First check EPOCDEVICE env variable
+ QString defaultDevice = qgetenv("EPOCDEVICE");
+
+ // Check the windows registry via QSettings for devices.xml path
+ QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat);
+ QString devicesXmlPath = settings.value("CommonPath").toString();
+
+ if (!devicesXmlPath.isEmpty()) {
+ // Parse xml for correct device
+ devicesXmlPath += "/devices.xml";
+ QFile devicesFile(devicesXmlPath);
+ if (devicesFile.open(QIODevice::ReadOnly)) {
+ QXmlStreamReader xml(&devicesFile);
+ while (!xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == "devices") {
+ if (xml.attributes().value("version") == "1.0") {
+ // Look for correct device
+ while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == "device") {
+ if ((defaultDevice.isEmpty() && xml.attributes().value("default") == "yes") ||
+ (!defaultDevice.isEmpty() && (xml.attributes().value("id").toString() + QString(":") + xml.attributes().value("name").toString()) == defaultDevice)) {
+ // Found the correct device
+ while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == "epocroot") {
+ epocRootStr = xml.readElementText();
+ fixEpocRootStr(epocRootStr);
+ return epocRootStr;
+ }
+ }
+ xml.raiseError("No epocroot element found");
+ }
+ }
+ }
+ } else {
+ xml.raiseError("Invalid 'devices' element version");
+ }
+ }
+ }
+ if (xml.hasError()) {
+ fprintf(stderr, "ERROR: \"%s\" when parsing devices.xml\n", qPrintable(xml.errorString()));
+ }
+ } else {
+ fprintf(stderr, "Could not open devices.xml (%s)\n", qPrintable(devicesXmlPath));
+ }
+ } else {
+ fprintf(stderr, "Could not retrieve " SYMBIAN_SDKS_KEY " setting\n");
+ }
+
+ fprintf(stderr, "Failed to determine epoc root.\n");
+ if (!defaultDevice.isEmpty())
+ fprintf(stderr, "The device indicated by EPOCDEVICE environment variable (%s) could not be found.\n", qPrintable(defaultDevice));
+ fprintf(stderr, "Either set EPOCROOT or EPOCDEVICE environment variable to a valid value, or provide a default Symbian device.\n");
+
+ // No valid device found; set epocroot to "/"
+ epocRootStr = QLatin1String("/");
+ }
+
+ fixEpocRootStr(epocRootStr);
+ return epocRootStr;
+}
+
+
static bool isPlugin(const QFileInfo& info, const QString& devicePath)
{
// Libraries are plugins if deployment path is something else than
@@ -103,6 +198,44 @@ static void createPluginStub(const QFileInfo& info,
Option::fixPathToLocalOS(devicePath + "\\" + stubInfo.fileName())));
}
+QString generate_uid(const QString& target)
+{
+ static QMap<QString, QString> targetToUid;
+
+ QString tmp = targetToUid[target];
+
+ if (!tmp.isEmpty()) {
+ return tmp;
+ }
+
+ unsigned long hash = 5381;
+ int c;
+
+ for (int i = 0; i < target.size(); ++i) {
+ c = target.at(i).toAscii();
+ hash ^= c + ((c - i) << i % 20) + ((c + i) << (i + 5) % 20) + ((c - 2 * i) << (i + 10) % 20) + ((c + 2 * i) << (i + 15) % 20);
+ }
+
+ tmp.setNum(hash, 16);
+ for (int i = tmp.size(); i < 8; ++i)
+ tmp.prepend("0");
+
+ targetToUid[target] = tmp;
+
+ return tmp;
+}
+
+// UIDs starting with 0xE are test UIDs in symbian
+QString generate_test_uid(const QString& target)
+{
+ QString tmp = generate_uid(target);
+ tmp.replace(0, 1, "E");
+ tmp.prepend("0x");
+
+ return tmp;
+}
+
+
void initProjectDeploySymbian(QMakeProject* project,
DeploymentList &deploymentList,
const QString &testPath,
diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h
index a104985..867a910 100644
--- a/qmake/generators/symbian/initprojectdeploy_symbian.h
+++ b/qmake/generators/symbian/initprojectdeploy_symbian.h
@@ -50,6 +50,8 @@
#include <qfile.h>
#include <stdlib.h>
+#include "epocroot.h"
+
struct CopyItem
{
CopyItem(const QString& f, const QString& t) : from(f) , to(t) { }
@@ -58,6 +60,9 @@ struct CopyItem
};
typedef QList<CopyItem> DeploymentList;
+extern QString generate_uid(const QString& target);
+extern QString generate_test_uid(const QString& target);
+
extern void initProjectDeploySymbian(QMakeProject* project,
DeploymentList &deploymentList,
const QString &testPath,
diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp
index b3fa0f2..f4886d5 100644
--- a/qmake/generators/symbian/symmake.cpp
+++ b/qmake/generators/symbian/symmake.cpp
@@ -486,7 +486,7 @@ void SymbianMakefileGenerator::init()
// .mmp
initMmpVariables();
- // Check TARGET.UID2 and TARGET.UID3 presence
+ // Check TARGET.UID3 presence
if (0 != project->values("TARGET.UID3").size()) {
uid3 = project->first("TARGET.UID3");
} else {
@@ -1686,4 +1686,5 @@ void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t)
t << "distclean: clean dodistclean" << endl;
t << endl;
-} \ No newline at end of file
+}
+
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 8455c6d..7239ee9 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -44,6 +44,8 @@
#include "option.h"
#include "cachekeys.h"
+#include "epocroot.h"
+
#include <qdatetime.h>
#include <qfile.h>
#include <qfileinfo.h>
@@ -52,8 +54,6 @@
#include <qtextstream.h>
#include <qstack.h>
#include <qhash.h>
-#include <qxmlstream.h>
-#include <qsettings.h>
#include <qdebug.h>
#ifdef Q_OS_UNIX
#include <unistd.h>
@@ -79,7 +79,7 @@ enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST
E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_REPLACE,
- E_GENERATE_TEST_UID, E_SIZE };
+ E_SIZE };
QMap<QString, ExpandFunc> qmake_expandFunctions()
{
static QMap<QString, ExpandFunc> *qmake_expand_functions = 0;
@@ -110,7 +110,6 @@ QMap<QString, ExpandFunc> qmake_expandFunctions()
qmake_expand_functions->insert("files", E_FILES);
qmake_expand_functions->insert("prompt", E_PROMPT);
qmake_expand_functions->insert("replace", E_REPLACE);
- qmake_expand_functions->insert("generate_test_uid", E_GENERATE_TEST_UID);
qmake_expand_functions->insert("size", E_SIZE);
}
return *qmake_expand_functions;
@@ -2395,22 +2394,6 @@ QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
ret += it->replace(before, after);
}
break; }
- case E_GENERATE_TEST_UID: {
- if(args.count() != 1) {
- fprintf(stderr, "%s:%d: generate_test_uid(targetname) requires one argument.\n",
- parser.file.toLatin1().constData(), parser.line_no);
- } else {
- QString target = args[0];
-
- QString currPath = qmake_getpwd();
- target.prepend("/").prepend(currPath);
-
-
- QString tmp = generate_test_uid(target);
-
- ret += tmp;
- }
- break; }
case E_SIZE: {
if(args.count() != 1) {
fprintf(stderr, "%s:%d: size(var) requires one argument.\n",
@@ -3308,150 +3291,4 @@ QStringList &QMakeProject::values(const QString &_var, QMap<QString, QStringList
return place[var];
}
-
-// UIDs starting with 0xE are test UIDs in symbian
-QString generate_test_uid(const QString& target)
-{
- QString tmp = generate_uid(target);
- tmp.replace(0, 1, "E");
- tmp.prepend("0x");
-
- return tmp;
-}
-
-
-// UIDs starting with 0xE are test UIDs in symbian
-QString generate_uid(const QString& target)
-{
- static QMap<QString, QString> targetToUid;
-
- QString tmp = targetToUid[target];
-
- if (!tmp.isEmpty()) {
- return tmp;
- }
-
- unsigned long hash = 5381;
- int c;
-
- for (int i = 0; i < target.size(); ++i) {
- c = target.at(i).toAscii();
- hash ^= c + ((c - i) << i % 20) + ((c + i) << (i + 5) % 20) + ((c - 2 * i) << (i + 10) % 20) + ((c + 2 * i) << (i + 15) % 20);
- }
-
- tmp.setNum(hash, 16);
- for (int i = tmp.size(); i < 8; ++i)
- tmp.prepend("0");
-
-#if 0
- static QMap<QString, QString> uidConflictCheckList;
- QString testStr = tmp;
- testStr.replace(0, 1, "E"); // Simulate actual UID generation
- if (uidConflictCheckList.contains(testStr)) {
- printf("\n\n!!!! generated duplicate uid for %s is %s <-> %s !!!!\n\n\n",
- qPrintable(target),
- qPrintable(testStr),
- qPrintable(uidConflictCheckList.value(testStr)));
- }
- uidConflictCheckList.insert(testStr, target);
- printf("generate_uid for %s is %s \n", qPrintable(target), qPrintable(tmp));
-#endif
-
- targetToUid[target] = tmp;
-
- return tmp;
-}
-
-static void fixEpocRootStr(QString& path)
-{
- path.replace("\\", "/");
-
- if (path.size() > 1 && path[1] == QChar(':')) {
- path = path.mid(2);
- }
-
- if (!path.size() || path[path.size()-1] != QChar('/')) {
- path += QChar('/');
- }
-}
-
-#define SYMBIAN_SDKS_KEY "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs"
-
-static QString epocRootStr;
-
-QString epocRoot()
-{
- if (!epocRootStr.isEmpty()) {
- return epocRootStr;
- }
-
- // First, check the env variable
- epocRootStr = qgetenv("EPOCROOT");
-
- if (epocRootStr.isEmpty()) {
- // No EPOCROOT set, check the default device
- // First check EPOCDEVICE env variable
- QString defaultDevice = qgetenv("EPOCDEVICE");
-
- // Check the windows registry via QSettings for devices.xml path
- QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat);
- QString devicesXmlPath = settings.value("CommonPath").toString();
-
- if (!devicesXmlPath.isEmpty()) {
- // Parse xml for correct device
- devicesXmlPath += "/devices.xml";
- QFile devicesFile(devicesXmlPath);
- if (devicesFile.open(QIODevice::ReadOnly)) {
- QXmlStreamReader xml(&devicesFile);
- while (!xml.atEnd()) {
- xml.readNext();
- if (xml.isStartElement() && xml.name() == "devices") {
- if (xml.attributes().value("version") == "1.0") {
- // Look for correct device
- while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) {
- xml.readNext();
- if (xml.isStartElement() && xml.name() == "device") {
- if ((defaultDevice.isEmpty() && xml.attributes().value("default") == "yes") ||
- (!defaultDevice.isEmpty() && (xml.attributes().value("id").toString() + QString(":") + xml.attributes().value("name").toString()) == defaultDevice)) {
- // Found the correct device
- while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) {
- xml.readNext();
- if (xml.isStartElement() && xml.name() == "epocroot") {
- epocRootStr = xml.readElementText();
- fixEpocRootStr(epocRootStr);
- return epocRootStr;
- }
- }
- xml.raiseError("No epocroot element found");
- }
- }
- }
- } else {
- xml.raiseError("Invalid 'devices' element version");
- }
- }
- }
- if (xml.hasError()) {
- fprintf(stderr, "ERROR: \"%s\" when parsing devices.xml\n", qPrintable(xml.errorString()));
- }
- } else {
- fprintf(stderr, "Could not open devices.xml (%s)\n", qPrintable(devicesXmlPath));
- }
- } else {
- fprintf(stderr, "Could not retrieve " SYMBIAN_SDKS_KEY " setting\n");
- }
-
- fprintf(stderr, "Failed to determine epoc root.\n");
- if (!defaultDevice.isEmpty())
- fprintf(stderr, "The device indicated by EPOCDEVICE environment variable (%s) could not be found.\n", qPrintable(defaultDevice));
- fprintf(stderr, "Either set EPOCROOT or EPOCDEVICE environment variable to a valid value, or provide a default Symbian device.\n");
-
- // No valid device found; set epocroot to "/"
- epocRootStr = QLatin1String("/");
- }
-
- fixEpocRootStr(epocRootStr);
- return epocRootStr;
-}
-
QT_END_NAMESPACE
diff --git a/qmake/project.h b/qmake/project.h
index 8d15724..7273c2b 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -203,10 +203,7 @@ inline QString QMakeProject::first(const QString &v)
inline QMap<QString, QStringList> &QMakeProject::variables()
{ return vars; }
-// Helper functions needed for Symbian .mmp files and deployment
-QString generate_test_uid(const QString& target);
-QString generate_uid(const QString& target);
-QString epocRoot();
+// Helper functions needed for Symbian
bool isForSymbian();
bool isForSymbianSbsv2();
diff --git a/qmake/qmake.pri b/qmake/qmake.pri
index fe15d71..206c1c2 100644
--- a/qmake/qmake.pri
+++ b/qmake/qmake.pri
@@ -29,6 +29,7 @@ HEADERS += project.h property.h generators/makefile.h \
generators/symbian/symmake.h \
generators/symbian/symmake_abld.h \
generators/symbian/symmake_sbsv2.h \
+ generators/symbian/epocroot.h \
generators/symbian/initprojectdeploy_symbian.h
contains(QT_EDITION, OpenSource) {