diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-08-19 12:34:28 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-08-19 12:34:28 (GMT) |
commit | e7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e (patch) | |
tree | 6e7a4cc2e237c847a28b3d97549abe0762f6795d /qmake/generators/symbian/initprojectdeploy_symbian.cpp | |
parent | a1cfdc273bac90d58754c286810353ccb0be4b2e (diff) | |
download | Qt-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/symbian/initprojectdeploy_symbian.cpp')
-rw-r--r-- | qmake/generators/symbian/initprojectdeploy_symbian.cpp | 133 |
1 files changed, 133 insertions, 0 deletions
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, |