summaryrefslogtreecommitdiffstats
path: root/qmake/generators
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/generators
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/generators')
-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
4 files changed, 192 insertions, 2 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
+}
+