From ba301c2e265f3132906254b145fad394eeb4091f Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 23 Feb 2010 09:22:50 +0100 Subject: Factored readRegistryKey implementation out of qmake This function is now implemented with its own header and source files, rather than being embedded within the MSVC qmake generator. The motivation for this is to allow code to be shared between qmake and configure, both of which query the registry when built for Windows. Reviewed-by: Miikka Heikkinen (cherry picked from commit 5254184c07b4da800e29000a251ed2a026bd2be5) Conflicts: qmake/Makefile.unix --- qmake/Makefile.unix | 9 +- qmake/Makefile.win32 | 7 ++ qmake/Makefile.win32-g++ | 5 + qmake/Makefile.win32-g++-sh | 5 + qmake/generators/win32/msvc_vcproj.cpp | 97 +------------------- qmake/qmake.pri | 7 +- qmake/qmake.pro | 4 + tools/shared/windows/registry.cpp | 161 +++++++++++++++++++++++++++++++++ tools/shared/windows/registry.h | 64 +++++++++++++ 9 files changed, 259 insertions(+), 100 deletions(-) create mode 100644 tools/shared/windows/registry.cpp create mode 100644 tools/shared/windows/registry.h diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 5e3190d..0d6c117 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -10,7 +10,8 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ mingw_make.o option.o winmakefile.o projectgenerator.o \ meta.o makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ borland_bmake.o msvc_vcproj.o msvc_nmake.o msvc_objectmodel.o \ - symmake.o initprojectdeploy_symbian.o symmake_abld.o symmake_sbsv2.o + symmake.o initprojectdeploy_symbian.o symmake_abld.o symmake_sbsv2.o \ + registry.o #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ @@ -20,6 +21,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qgl qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ qmap.o qmetatype.o qsettings.o qlibraryinfo.o qvariant.o qvsnprintf.o \ qlocale.o qlinkedlist.o qurl.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o \ + registry.o \ $(QTOBJS) @@ -32,6 +34,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge generators/makefiledeps.cpp option.cpp generators/win32/mingw_make.cpp generators/makefile.cpp \ generators/win32/msvc_objectmodel.cpp generators/win32/msvc_nmake.cpp generators/win32/borland_bmake.cpp \ generators/symbian/symmake.cpp generators/symbian/initprojectdeploy_symbian.cpp \ + $(SOURCE_PATH)/tools/shared/windows/registry.cpp \ generators/symbian/symmake_abld.cpp generators/symbian/symmake_sbsv2.cpp \ $(SOURCE_PATH)/src/corelib/codecs/qtextcodec.cpp $(SOURCE_PATH)/src/corelib/codecs/qutfcodec.cpp \ $(SOURCE_PATH)/src/corelib/tools/qstring.cpp $(SOURCE_PATH)/src/corelib/io/qfile.cpp \ @@ -62,6 +65,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge CPPFLAGS = -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac -Igenerators/symbian \ -I$(BUILD_PATH)/include -I$(BUILD_PATH)/include/QtCore \ -I$(BUILD_PATH)/src/corelib/global -I$(BUILD_PATH)/src/corelib/xml \ + -I$(BUILD_PATH)/tools/shared \ -DQT_NO_PCRE \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_STL \ @@ -278,6 +282,9 @@ symmake_sbsv2.o: generators/symbian/symmake_sbsv2.cpp initprojectdeploy_symbian.o: generators/symbian/initprojectdeploy_symbian.cpp $(CXX) -c -o $@ $(CXXFLAGS) generators/symbian/initprojectdeploy_symbian.cpp +registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp + projectgenerator.o: generators/projectgenerator.cpp $(CXX) -c -o $@ $(CXXFLAGS) generators/projectgenerator.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 1f3092a..bbc37c1 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -34,6 +34,7 @@ CFLAGS = -c -Fo$@ \ -I$(BUILD_PATH)\src\corelib\global \ -I$(BUILD_PATH)\src\corelib\xml \ -I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \ + -I$(SOURCE_PATH)\tools\shared \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL \ -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD \ -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED \ @@ -59,6 +60,7 @@ CFLAGS = -c -o$@ \ -I$(SOURCE_PATH)\include -I$(SOURCE_PATH)\include\QtCore \ -I$(BUILD_PATH)\src\corelib\global \ -I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \ + -I$(SOURCE_PATH)\tools\shared \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL \ -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD \ -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT @@ -75,6 +77,7 @@ OBJS = project.obj main.obj makefile.obj unixmake.obj unixmake2.obj mingw makefiledeps.obj metamakefile.obj xmloutput.obj pbuilder_pbx.obj \ borland_bmake.obj msvc_nmake.obj msvc_vcproj.obj \ msvc_objectmodel.obj symmake.obj initprojectdeploy_symbian.obj \ + registry.obj \ symmake_abld.obj symmake_sbsv2.obj !IFDEF QMAKE_OPENSOURCE_EDITION @@ -197,6 +200,7 @@ clean:: -del symmake_abld.obj -del symmake_sbsv2.obj -del initprojectdeploy_symbian.obj + -del registry.obj -del pbuilder_pbx.obj -del qxmlstream.obj -del qxmlutils.obj @@ -393,6 +397,9 @@ symmake_sbsv2.obj: $(SOURCE_PATH)/qmake/generators/symbian/symmake_sbsv2.cpp initprojectdeploy_symbian.obj: $(SOURCE_PATH)/qmake/generators/symbian/initprojectdeploy_symbian.cpp $(CXX) $(CXXFLAGS) generators/symbian/initprojectdeploy_symbian.cpp +registry.obj: $(SOURCE_PATH)/tools/shared/windows/registry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp + md5.obj: $(SOURCE_PATH)\src\3rdparty\md5\md5.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\3rdparty\md5\md5.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index 41a1d8c..0b47905 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -21,6 +21,7 @@ CFLAGS = -c -o$@ -O \ -I$(BUILD_PATH)/src/corelib/global \ -I$(BUILD_PATH)/src/corelib/xml \ -I$(SOURCE_PATH)/mkspecs/win32-g++ \ + -I$(SOURCE_PATH)/tools/shared \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_PCRE \ -DQT_NODLL -DQT_NO_STL -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ @@ -38,6 +39,7 @@ OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ + registry.o \ symmake_abld.o symmake_sbsv2.o ifdef QMAKE_OPENSOURCE_EDITION @@ -275,6 +277,9 @@ symmake_sbsv2.o: $(SOURCE_PATH)/qmake/generators/symbian/symmake_sbsv2.cpp initprojectdeploy_symbian.o: $(SOURCE_PATH)/qmake/generators/symbian/initprojectdeploy_symbian.cpp $(CXX) $(CXXFLAGS) generators/symbian/initprojectdeploy_symbian.cpp +registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp + project.o: $(SOURCE_PATH)/qmake/project.cpp $(SOURCE_PATH)/qmake/project.h $(SOURCE_PATH)/qmake/option.h $(CXX) $(CXXFLAGS) project.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 0b08320..0772aff 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -21,6 +21,7 @@ CFLAGS = -c -o$@ -O \ -I$(BUILD_PATH)/src/corelib/global \ -I$(BUILD_PATH)/src/corelib/xml \ -I$(SOURCE_PATH)/mkspecs/win32-g++ \ + -I$(SOURCE_PATH)/tools/shared \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_PCRE \ -DQT_NODLL -DQT_NO_STL -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ @@ -38,6 +39,7 @@ OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ + registry.o \ symmake_abld.o symmake_sbsv2.o ifdef QMAKE_OPENSOURCE_EDITION @@ -274,6 +276,9 @@ symmake_sbsv2.o: $(SOURCE_PATH)/qmake/generators/symbian/symmake_sbsv2.cpp initprojectdeploy_symbian.o: $(SOURCE_PATH)/qmake/generators/symbian/initprojectdeploy_symbian.cpp $(CXX) $(CXXFLAGS) generators/symbian/initprojectdeploy_symbian.cpp +registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp + project.o: $(SOURCE_PATH)/qmake/project.cpp $(SOURCE_PATH)/qmake/project.h $(SOURCE_PATH)/qmake/option.h $(CXX) $(CXXFLAGS) project.cpp diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 3536a02..f1777e1 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -67,6 +67,7 @@ QT_END_NAMESPACE #ifdef Q_OS_WIN32 #include +#include QT_BEGIN_NAMESPACE @@ -93,102 +94,6 @@ struct { {NETUnknown, "", ""}, }; -static QString keyPath(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return QString(); - return rKey.left(idx + 1); -} - -static QString keyName(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return rKey; - - QString res(rKey.mid(idx + 1)); - if (res == "Default" || res == ".") - res = ""; - return res; -} - -static QString readRegistryKey(HKEY parentHandle, const QString &rSubkey) -{ - - QString rSubkeyName = keyName(rSubkey); - QString rSubkeyPath = keyPath(rSubkey); - - HKEY handle = 0; - LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle); - - if (res != ERROR_SUCCESS) - return QString(); - - // get the size and type of the value - DWORD dataType; - DWORD dataSize; - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - // get the value - QByteArray data(dataSize, 0); - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0, - reinterpret_cast(data.data()), &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - QString result; - switch (dataType) { - case REG_EXPAND_SZ: - case REG_SZ: { - result = QString::fromWCharArray(((const wchar_t *)data.constData())); - break; - } - - case REG_MULTI_SZ: { - QStringList l; - int i = 0; - for (;;) { - QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); - i += s.length() + 1; - - if (s.isEmpty()) - break; - l.append(s); - } - result = l.join(", "); - break; - } - - case REG_NONE: - case REG_BINARY: { - result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); - break; - } - - case REG_DWORD_BIG_ENDIAN: - case REG_DWORD: { - Q_ASSERT(data.size() == sizeof(int)); - int i; - memcpy((char*)&i, data.constData(), sizeof(int)); - result = QString::number(i); - break; - } - - default: - qWarning("QSettings: unknown data %d type in windows registry", dataType); - break; - } - - RegCloseKey(handle); - return result; -} QT_END_NAMESPACE #endif diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 17d9518..187232f 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -17,7 +17,8 @@ SOURCES += project.cpp property.cpp main.cpp generators/makefile.cpp \ generators/symbian/symmake.cpp \ generators/symbian/symmake_abld.cpp \ generators/symbian/symmake_sbsv2.cpp \ - generators/symbian/initprojectdeploy_symbian.cpp + generators/symbian/initprojectdeploy_symbian.cpp \ + windows/registry.cpp HEADERS += project.h property.h generators/makefile.h \ generators/unix/unixmake.h meta.h option.h cachekeys.h \ @@ -29,8 +30,8 @@ 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 + generators/symbian/initprojectdeploy_symbian.h \ + windows/registry.h contains(QT_EDITION, OpenSource) { DEFINES += QMAKE_OPENSOURCE_EDITION diff --git a/qmake/qmake.pro b/qmake/qmake.pro index 00dcbce..f3f9d53 100644 --- a/qmake/qmake.pro +++ b/qmake/qmake.pro @@ -27,5 +27,9 @@ INCPATH += generators \ $$QT_SOURCE_TREE/include \ $$QT_SOURCE_TREE/include/QtCore \ $$QT_SOURCE_TREE/qmake + +VPATH += $$QT_SOURCE_TREE/tools/shared +INCPATH += $$QT_SOURCE_TREE/tools/shared + include(qmake.pri) diff --git a/tools/shared/windows/registry.cpp b/tools/shared/windows/registry.cpp new file mode 100644 index 0000000..d342d78 --- /dev/null +++ b/tools/shared/windows/registry.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "registry.h" + +/*! + Returns the path part of a registry key. + e.g. + For a key + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" + it returns + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\" +*/ +static QString keyPath(const QString &rKey) +{ + int idx = rKey.lastIndexOf(QLatin1Char('\\')); + if (idx == -1) + return QString(); + return rKey.left(idx + 1); +} + +/*! + Returns the name part of a registry key. + e.g. + For a key + "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" + it returns + "ProductDir" +*/ +static QString keyName(const QString &rKey) +{ + int idx = rKey.lastIndexOf(QLatin1Char('\\')); + if (idx == -1) + return rKey; + + QString res(rKey.mid(idx + 1)); + if (res == "Default" || res == ".") + res = ""; + return res; +} + +QString readRegistryKey(HKEY parentHandle, const QString &rSubkey) +{ + QString result; + +#ifdef Q_OS_WIN32 + QString rSubkeyName = keyName(rSubkey); + QString rSubkeyPath = keyPath(rSubkey); + + HKEY handle = 0; + LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle); + + if (res != ERROR_SUCCESS) + return QString(); + + // get the size and type of the value + DWORD dataType; + DWORD dataSize; + res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize); + if (res != ERROR_SUCCESS) { + RegCloseKey(handle); + return QString(); + } + + // get the value + QByteArray data(dataSize, 0); + res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0, + reinterpret_cast(data.data()), &dataSize); + if (res != ERROR_SUCCESS) { + RegCloseKey(handle); + return QString(); + } + + switch (dataType) { + case REG_EXPAND_SZ: + case REG_SZ: { + result = QString::fromWCharArray(((const wchar_t *)data.constData())); + break; + } + + case REG_MULTI_SZ: { + QStringList l; + int i = 0; + for (;;) { + QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); + i += s.length() + 1; + + if (s.isEmpty()) + break; + l.append(s); + } + result = l.join(", "); + break; + } + + case REG_NONE: + case REG_BINARY: { + result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); + break; + } + + case REG_DWORD_BIG_ENDIAN: + case REG_DWORD: { + Q_ASSERT(data.size() == sizeof(int)); + int i; + memcpy((char*)&i, data.constData(), sizeof(int)); + result = QString::number(i); + break; + } + + default: + qWarning("QSettings: unknown data %d type in windows registry", dataType); + break; + } + + RegCloseKey(handle); +#endif + + return result; +} + + diff --git a/tools/shared/windows/registry.h b/tools/shared/windows/registry.h new file mode 100644 index 0000000..3896527 --- /dev/null +++ b/tools/shared/windows/registry.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOWS_REGISTRY_H +#define WINDOWS_REGISTRY_H + +#include + +#ifdef Q_OS_WIN32 + #include +#else + typedef void* HKEY; +#endif + +#include + +/** + * Read a value from the Windows registry. + * + * If the key is not found, or the registry cannot be accessed (for example + * if this code is compiled for a platform other than Windows), a null + * string is returned. + */ +QString readRegistryKey(HKEY parentHandle, const QString &rSubkey); + +#endif // WINDOWS_REGISTRY_H -- cgit v0.12 From 295e3dd7e07c7a1788e3dce4446eab9a608f99e6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 10 Feb 2010 14:57:51 +0000 Subject: Factored epocRoot implementation out of qmake This function is now implemented in its own source file, rather than being embedded within the Symbian qmake generator. The motivation for this is to allow code to be shared between qmake and configure - the latter needs to determine the epoc root path in order to perform feature detection on Symbian SDKs. Reviewed-by: Miikka Heikkinen (cherry picked from commit 6ebcf2c24b43fdc1d6da50e9d7ec9dd63dd507d7) --- qmake/Makefile.unix | 9 +- qmake/Makefile.win32 | 5 + qmake/Makefile.win32-g++ | 4 + qmake/Makefile.win32-g++-sh | 4 + qmake/generators/symbian/epocroot.h | 51 ----- .../symbian/initprojectdeploy_symbian.cpp | 96 +-------- .../generators/symbian/initprojectdeploy_symbian.h | 2 - qmake/generators/symbian/symmake.cpp | 3 + qmake/generators/symbian/symmake_abld.cpp | 3 + qmake/generators/symbian/symmake_sbsv2.cpp | 3 + qmake/project.cpp | 5 +- qmake/qmake.pri | 6 +- tools/shared/symbian/epocroot.cpp | 230 +++++++++++++++++++++ tools/shared/symbian/epocroot.h | 67 ++++++ 14 files changed, 337 insertions(+), 151 deletions(-) delete mode 100644 qmake/generators/symbian/epocroot.h create mode 100644 tools/shared/symbian/epocroot.cpp create mode 100644 tools/shared/symbian/epocroot.h diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 0d6c117..94b34b7 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -11,7 +11,8 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ meta.o makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o \ borland_bmake.o msvc_vcproj.o msvc_nmake.o msvc_objectmodel.o \ symmake.o initprojectdeploy_symbian.o symmake_abld.o symmake_sbsv2.o \ - registry.o + registry.o \ + epocroot.o #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ @@ -22,6 +23,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qgl qmap.o qmetatype.o qsettings.o qlibraryinfo.o qvariant.o qvsnprintf.o \ qlocale.o qlinkedlist.o qurl.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o \ registry.o \ + epocroot.o \ $(QTOBJS) @@ -35,6 +37,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge generators/win32/msvc_objectmodel.cpp generators/win32/msvc_nmake.cpp generators/win32/borland_bmake.cpp \ generators/symbian/symmake.cpp generators/symbian/initprojectdeploy_symbian.cpp \ $(SOURCE_PATH)/tools/shared/windows/registry.cpp \ + $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp \ generators/symbian/symmake_abld.cpp generators/symbian/symmake_sbsv2.cpp \ $(SOURCE_PATH)/src/corelib/codecs/qtextcodec.cpp $(SOURCE_PATH)/src/corelib/codecs/qutfcodec.cpp \ $(SOURCE_PATH)/src/corelib/tools/qstring.cpp $(SOURCE_PATH)/src/corelib/io/qfile.cpp \ @@ -285,6 +288,9 @@ initprojectdeploy_symbian.o: generators/symbian/initprojectdeploy_symbian.cpp registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp +epocroot.o: $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + projectgenerator.o: generators/projectgenerator.cpp $(CXX) -c -o $@ $(CXXFLAGS) generators/projectgenerator.cpp @@ -293,6 +299,7 @@ qxmlstream.o: $(SOURCE_PATH)/src/corelib/xml/qxmlstream.cpp qxmlutils.o: $(SOURCE_PATH)/src/corelib/xml/qxmlutils.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/xml/qxmlutils.cpp + #default rules .cpp.o: $(CXX) -c -o $@ $(CXXFLAGS) $< diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index bbc37c1..a598350 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -78,6 +78,7 @@ OBJS = project.obj main.obj makefile.obj unixmake.obj unixmake2.obj mingw borland_bmake.obj msvc_nmake.obj msvc_vcproj.obj \ msvc_objectmodel.obj symmake.obj initprojectdeploy_symbian.obj \ registry.obj \ + epocroot.obj \ symmake_abld.obj symmake_sbsv2.obj !IFDEF QMAKE_OPENSOURCE_EDITION @@ -201,6 +202,7 @@ clean:: -del symmake_sbsv2.obj -del initprojectdeploy_symbian.obj -del registry.obj + -del epocroot.obj -del pbuilder_pbx.obj -del qxmlstream.obj -del qxmlutils.obj @@ -400,6 +402,9 @@ initprojectdeploy_symbian.obj: $(SOURCE_PATH)/qmake/generators/symbian/initproje registry.obj: $(SOURCE_PATH)/tools/shared/windows/registry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp +epocroot.obj: $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + md5.obj: $(SOURCE_PATH)\src\3rdparty\md5\md5.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\3rdparty\md5\md5.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index 0b47905..d4d6e0e 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -40,6 +40,7 @@ OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ registry.o \ + epocroot.o \ symmake_abld.o symmake_sbsv2.o ifdef QMAKE_OPENSOURCE_EDITION @@ -280,6 +281,9 @@ initprojectdeploy_symbian.o: $(SOURCE_PATH)/qmake/generators/symbian/initproject registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp +epocroot.o: $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + project.o: $(SOURCE_PATH)/qmake/project.cpp $(SOURCE_PATH)/qmake/project.h $(SOURCE_PATH)/qmake/option.h $(CXX) $(CXXFLAGS) project.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 0772aff..5061089 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -40,6 +40,7 @@ OBJS = project.o main.o makefile.o unixmake.o unixmake2.o mingw_make.o \ borland_bmake.o msvc_nmake.o msvc_vcproj.o \ msvc_objectmodel.o symmake.o initprojectdeploy_symbian.o \ registry.o \ + epocroot.o \ symmake_abld.o symmake_sbsv2.o ifdef QMAKE_OPENSOURCE_EDITION @@ -279,6 +280,9 @@ initprojectdeploy_symbian.o: $(SOURCE_PATH)/qmake/generators/symbian/initproject registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp +epocroot.o: $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/symbian/epocroot.cpp + project.o: $(SOURCE_PATH)/qmake/project.cpp $(SOURCE_PATH)/qmake/project.h $(SOURCE_PATH)/qmake/option.h $(CXX) $(CXXFLAGS) project.cpp diff --git a/qmake/generators/symbian/epocroot.h b/qmake/generators/symbian/epocroot.h deleted file mode 100644 index be26438..0000000 --- a/qmake/generators/symbian/epocroot.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef EPOCROOT_H -#define EPOCROOT_H - -#include - -// 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 7279a4c..0d50112 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -46,105 +46,15 @@ #include #include +// Included from tools/shared +#include + #define SYSBIN_DIR "\\sys\\bin" #define SUFFIX_DLL "dll" #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 diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h index e23e6a9..b409225 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.h +++ b/qmake/generators/symbian/initprojectdeploy_symbian.h @@ -50,8 +50,6 @@ #include #include -#include "epocroot.h" - #define PLUGIN_STUB_DIR "qmakepluginstubs" struct CopyItem diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 6854084..ac4bca3 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -49,6 +49,9 @@ #include #include +// Included from tools/shared +#include + #define RESOURCE_DIRECTORY_MMP "/resource/apps" #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\" #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps" diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 9b7ae3e..81165f5 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -48,6 +48,9 @@ #include #include +// Included from tools/shared +#include + #define DO_NOTHING_TARGET "do_nothing" #define CREATE_TEMPS_TARGET "create_temps" #define EXTENSION_CLEAN "extension_clean" diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index f610181..4366f0e 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -48,6 +48,9 @@ #include #include +// Included from tools/shared +#include + SymbianSbsv2MakefileGenerator::SymbianSbsv2MakefileGenerator() : SymbianMakefileGenerator() { } SymbianSbsv2MakefileGenerator::~SymbianSbsv2MakefileGenerator() { } diff --git a/qmake/project.cpp b/qmake/project.cpp index 8871152..4193163 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -44,8 +44,6 @@ #include "option.h" #include "cachekeys.h" -#include "epocroot.h" - #include #include #include @@ -64,6 +62,9 @@ #include #include +// Included from tools/shared +#include + #ifdef Q_OS_WIN32 #define QT_POPEN _popen #define QT_PCLOSE _pclose diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 187232f..0821f00 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -18,7 +18,8 @@ SOURCES += project.cpp property.cpp main.cpp generators/makefile.cpp \ generators/symbian/symmake_abld.cpp \ generators/symbian/symmake_sbsv2.cpp \ generators/symbian/initprojectdeploy_symbian.cpp \ - windows/registry.cpp + windows/registry.cpp \ + symbian/epocroot.cpp HEADERS += project.h property.h generators/makefile.h \ generators/unix/unixmake.h meta.h option.h cachekeys.h \ @@ -31,7 +32,8 @@ HEADERS += project.h property.h generators/makefile.h \ generators/symbian/symmake_abld.h \ generators/symbian/symmake_sbsv2.h \ generators/symbian/initprojectdeploy_symbian.h \ - windows/registry.h + windows/registry.h \ + symbian/epocroot.h contains(QT_EDITION, OpenSource) { DEFINES += QMAKE_OPENSOURCE_EDITION diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp new file mode 100644 index 0000000..071477d --- /dev/null +++ b/tools/shared/symbian/epocroot.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include + +#include "epocroot.h" +#include "../windows/registry.h" + +// Registry key under which the location of the Symbian devices.xml file is +// stored. +// Note that, on 64-bit machines, this key is located under the 32-bit +// compatibility key: +// HKEY_LOCAL_MACHINE\Software\Wow6432Node +#define SYMBIAN_SDKS_REG_SUBKEY "Software\\Symbian\\EPOC SDKs\\CommonPath" + +#ifdef Q_OS_WIN32 +# define SYMBIAN_SDKS_REG_HANDLE HKEY_LOCAL_MACHINE +#else +# define SYMBIAN_SDKS_REG_HANDLE 0 +#endif + +// Value which is populated and returned by the epocRoot() function. +// Stored as a static value in order to avoid unnecessary re-evaluation. +static QString epocRootValue; + +#ifdef QT_BUILD_QMAKE +std::ostream &operator<<(std::ostream &s, const QString &val) { + s << val.toLocal8Bit().data(); + return s; +} +#else +// Operator implemented in configureapp.cpp +std::ostream &operator<<(std::ostream &s, const QString &val); +#endif + +QString getDevicesXmlPath() + { + // Note that the following call will return a null string on platforms other + // than Windows. If support is required on other platforms for devices.xml, + // an alternative mechanism for retrieving the location of this file will + // be required. + return readRegistryKey(SYMBIAN_SDKS_REG_HANDLE, SYMBIAN_SDKS_REG_SUBKEY); + } + +/** + * Checks whether epocRootValue points to an existent directory. + * If not, epocRootValue is set to an empty string and an error message is printed. + */ +void checkEpocRootExists(const QString &source) +{ + if (!epocRootValue.isEmpty()) { + QDir dir(epocRootValue); + if (!dir.exists()) { + std::cerr << "Warning: " << source << " is set to an invalid path: " << epocRootValue << std::endl; + epocRootValue = QString(); + } + } +} + +/** + * Translate path from Windows to Qt format. + */ +static void fixEpocRoot(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('/'); + } +} + +/** + * Determine the epoc root for the currently active SDK. + */ +QString epocRoot() +{ + if (epocRootValue.isEmpty()) { + // 1. If environment variable EPOCROOT is set and points to an existent + // directory, this is returned. + epocRootValue = qgetenv("EPOCROOT"); + checkEpocRootExists("EPOCROOT"); + + if (epocRootValue.isEmpty()) { + // 2. The location of devices.xml is specified by a registry key. If this + // file exists, it is parsed. + QString devicesXmlPath = getDevicesXmlPath(); + if (devicesXmlPath.isEmpty()) { + std::cerr << "Error: Symbian SDK registry key not found" << std::endl; + } else { + devicesXmlPath += "/devices.xml"; + QFile devicesFile(devicesXmlPath); + if (devicesFile.open(QIODevice::ReadOnly)) { + + // 3. If the EPOCDEVICE environment variable is set and a corresponding + // entry is found in devices.xml, and its epocroot value points to an + // existent directory, it is returned. + // 4. If a device element marked as default is found in devices.xml and its + // epocroot value points to an existent directory, this is returned. + + const QString epocDeviceValue = qgetenv("EPOCDEVICE"); + bool epocDeviceFound = false; + + QXmlStreamReader xml(&devicesFile); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "devices") { + if (xml.attributes().value("version") == "1.0") { + while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "device") { + const bool isDefault = xml.attributes().value("default") == "yes"; + const QString id = xml.attributes().value("id").toString(); + const QString name = xml.attributes().value("name").toString(); + const bool epocDeviceMatch = (id + ":" + name) == epocDeviceValue; + epocDeviceFound |= epocDeviceMatch; + + if((epocDeviceValue.isEmpty() && isDefault) || epocDeviceMatch) { + // Found a matching device + while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "epocroot") { + epocRootValue = xml.readElementText(); + const QString deviceSource = epocDeviceValue.isEmpty() + ? "default device" + : "EPOCDEVICE (" + epocDeviceValue + ")"; + checkEpocRootExists(deviceSource); + } + } + + if (epocRootValue.isEmpty()) + xml.raiseError("No epocroot element found"); + } + } + } + } else { + xml.raiseError("Invalid 'devices' element version"); + } + } + } + if (xml.hasError()) { + std::cerr << "Error: \"" << xml.errorString() << "\" when parsing devices.xml" << std::endl; + } else { + if (epocRootValue.isEmpty()) { + if (!epocDeviceValue.isEmpty()) { + if (epocDeviceFound) { + std::cerr << "Error: missing or invalid epocroot attribute " + << "in device '" << epocDeviceValue << "'"; + } else { + std::cerr << "Error: no device matching EPOCDEVICE (" + << epocDeviceValue << ")"; + } + } else { + if (epocDeviceFound) { + std::cerr << "Error: missing or invalid epocroot attribute " + << "in default device"; + } else { + std::cerr << "Error: no default device"; + } + } + std::cerr << " found in devices.xml file." << std::endl; + } + } + } else { + std::cerr << "Error: could not open file " << devicesXmlPath << std::endl; + } + } + } + + if (epocRootValue.isEmpty()) { + // 5. An empty string is returned. + std::cerr << "Error: failed to find epoc root" << std::endl + << "Either" << std::endl + << " 1. Set EPOCROOT environment variable to a valid value" << std::endl + << " or 2. Ensure that the HKEY_LOCAL_MACHINE\\" SYMBIAN_SDKS_REG_SUBKEY + " registry key is set, and then" << std::endl + << " a. Set EPOCDEVICE environment variable to a valid device" << std::endl + << " or b. Specify a default device in the devices.xml file." << std::endl; + } else { + fixEpocRoot(epocRootValue); + } + } + + return epocRootValue; +} + diff --git a/tools/shared/symbian/epocroot.h b/tools/shared/symbian/epocroot.h new file mode 100644 index 0000000..9846485 --- /dev/null +++ b/tools/shared/symbian/epocroot.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SYMBIAN_EPOCROOT_H +#define SYMBIAN_EPOCROOT_H + +#include + +/** + * Determine the epoc root for the currently active SDK. + * + * The algorithm used is as follows: + * 1. If environment variable EPOCROOT is set and points to an existent + * directory, this is returned. + * 2. The location of devices.xml is specified by a registry key. If this + * file exists, it is parsed. + * 3. If the EPOCDEVICE environment variable is set and a corresponding + * entry is found in devices.xml, and its epocroot value points to an + * existent directory, it is returned. + * 4. If a device element marked as default is found in devices.xml and its + * epocroot value points to an existent directory, this is returned. + * 5. An empty string is returned. + * + * Any return value other than the empty string therefore is guaranteed to + * point to an existent directory. + */ +QString epocRoot(); + +#endif // EPOCROOT_H -- cgit v0.12 From 8fcb0b6618610cb2ff947fc62f57abd33c8438b6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 19 Feb 2010 11:16:34 +0100 Subject: Fixed linkage failure when building qmake on Unix platforms Commits f641369c/5254184c and 13cb80be/6ebcf2c2 caused registry.o and epocroot.o respectively to be included twice during the linkage step of qmake/Makefile.unix. (cherry picked from commit 480f3df2eab9ad13e0d7ea1245158866a0b942bd) --- qmake/Makefile.unix | 2 -- 1 file changed, 2 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 94b34b7..54d52f2 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -22,8 +22,6 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qgl qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ qmap.o qmetatype.o qsettings.o qlibraryinfo.o qvariant.o qvsnprintf.o \ qlocale.o qlinkedlist.o qurl.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o \ - registry.o \ - epocroot.o \ $(QTOBJS) -- cgit v0.12 From 6bd5eba10a787a8458f6f77af2d24f4773b22f98 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 23 Feb 2010 09:47:33 +0100 Subject: Fixed shadow builds on Unix. --- qmake/Makefile.unix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 54d52f2..c101626 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -66,7 +66,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge CPPFLAGS = -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac -Igenerators/symbian \ -I$(BUILD_PATH)/include -I$(BUILD_PATH)/include/QtCore \ -I$(BUILD_PATH)/src/corelib/global -I$(BUILD_PATH)/src/corelib/xml \ - -I$(BUILD_PATH)/tools/shared \ + -I$(SOURCE_PATH)/tools/shared \ -DQT_NO_PCRE \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_STL \ -- cgit v0.12