diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:34:13 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:34:13 (GMT) |
commit | 67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch) | |
tree | 1dbf50b3dff8d5ca7e9344733968c72704eb15ff /tools/checksdk | |
download | Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2 |
Long live Qt!
Diffstat (limited to 'tools/checksdk')
-rw-r--r-- | tools/checksdk/README | 3 | ||||
-rw-r--r-- | tools/checksdk/cesdkhandler.cpp | 131 | ||||
-rw-r--r-- | tools/checksdk/cesdkhandler.h | 111 | ||||
-rw-r--r-- | tools/checksdk/checksdk.pro | 71 | ||||
-rw-r--r-- | tools/checksdk/main.cpp | 159 |
5 files changed, 475 insertions, 0 deletions
diff --git a/tools/checksdk/README b/tools/checksdk/README new file mode 100644 index 0000000..7eba1db --- /dev/null +++ b/tools/checksdk/README @@ -0,0 +1,3 @@ +checkSDK is used to build Qt/WinCE successfully. It parses the Visual +Studio configuration and sets up the environment for cross-compilation. + diff --git a/tools/checksdk/cesdkhandler.cpp b/tools/checksdk/cesdkhandler.cpp new file mode 100644 index 0000000..c1dd6ab --- /dev/null +++ b/tools/checksdk/cesdkhandler.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "cesdkhandler.h" +#include <QtCore/QFile> +#include <QtCore/QDebug> +#include <QtCore/QXmlStreamReader> + +CeSdkInfo::CeSdkInfo() : m_major(0) , m_minor(0) +{ +} + +QStringList CeSdkInfo::environment() +{ + QStringList result; + QString argument = QLatin1String("PATH="); + argument += m_bin; + result.append(argument); + argument = QLatin1String("INCLUDE="); + argument += m_include; + result.append(argument); + argument = QLatin1String("LIB="); + argument += m_lib; + result.append(argument); + return result; +} + +CeSdkHandler::CeSdkHandler() +{ +} + +bool CeSdkHandler::parse() +{ + // look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config + // and scan through all installed sdks... + m_list.clear(); + VCInstallDir = qgetenv("VCInstallDir"); + VCInstallDir += QLatin1String("\\"); + VSInstallDir = qgetenv("VSInstallDir"); + VSInstallDir += QLatin1String("\\"); + if (VCInstallDir.isEmpty() || VSInstallDir.isEmpty()) + return false; + + QDir vStudioDir(VCInstallDir); + if (!vStudioDir.cd("vcpackages")) + return false; + + QFile configFile(vStudioDir.absoluteFilePath(QLatin1String("WCE.VCPlatform.config"))); + if (!configFile.exists() || !configFile.open(QIODevice::ReadOnly)) + return false; + + QString currentElement; + CeSdkInfo currentItem; + QXmlStreamReader xml(&configFile); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement()) { + currentElement = xml.name().toString(); + if (currentElement == QLatin1String("Platform")) + currentItem = CeSdkInfo(); + else if (currentElement == QLatin1String("Directories")) { + QXmlStreamAttributes attr = xml.attributes(); + currentItem.m_include = fixPaths(attr.value(QLatin1String("Include")).toString()); + currentItem.m_lib = fixPaths(attr.value(QLatin1String("Library")).toString()); + currentItem.m_bin = fixPaths(attr.value(QLatin1String("Path")).toString()); + } + } else if (xml.isEndElement()) { + if (xml.name().toString() == QLatin1String("Platform")) + m_list.append(currentItem); + } else if (xml.isCharacters() && !xml.isWhitespace()) { + if (currentElement == QLatin1String("PlatformName")) + currentItem.m_name = xml.text().toString(); + else if (currentElement == QLatin1String("OSMajorVersion")) + currentItem.m_major = xml.text().toString().toInt(); + else if (currentElement == QLatin1String("OSMinorVersion")) + currentItem.m_minor = xml.text().toString().toInt(); + } + } + + if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) { + qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString(); + return false; + } + return m_list.size() > 0 ? true : false; +} + +CeSdkInfo CeSdkHandler::find(const QString &name) +{ + for (QList<CeSdkInfo>::iterator it = m_list.begin(); it != m_list.end(); ++it) { + if (it->name() == name) + return *it; + } + return CeSdkInfo(); +} diff --git a/tools/checksdk/cesdkhandler.h b/tools/checksdk/cesdkhandler.h new file mode 100644 index 0000000..22a3e0e --- /dev/null +++ b/tools/checksdk/cesdkhandler.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CE_SDK_HANDLER_INCL +#define CE_SDK_HANDLER_INCL + +#include <QStringList> +#include <QDir> + +QT_USE_NAMESPACE + +#define VCINSTALL_MACRO "$(VCInstallDir)" +#define VSINSTALL_MACRO "$(VSInstallDir)" + +class CeSdkInfo +{ +public: + CeSdkInfo(); + inline QString name(); + inline QString binPath(); + inline QString includePath(); + inline QString libPath(); + QStringList environment(); + inline bool isValid(); + inline int majorVersion(); + inline int minorVersion(); + inline bool isSupported(); +private: + friend class CeSdkHandler; + QString m_name; + QString m_bin; + QString m_include; + QString m_lib; + int m_major; + int m_minor; +}; + +inline QString CeSdkInfo::name(){ return m_name; } +inline QString CeSdkInfo::binPath(){ return m_bin; } +inline QString CeSdkInfo::includePath(){ return m_include; } +inline QString CeSdkInfo::libPath(){ return m_lib; } +inline bool CeSdkInfo::isValid(){ return !m_name.isEmpty() && !m_bin.isEmpty() && !m_include.isEmpty() && !m_lib.isEmpty(); } +inline int CeSdkInfo::majorVersion(){ return m_major; } +inline int CeSdkInfo::minorVersion(){ return m_minor; } +inline bool CeSdkInfo::isSupported() { return m_major >= 5; } + +class CeSdkHandler +{ +public: + CeSdkHandler(); + bool parse(); + inline QList<CeSdkInfo> listAll() const; + CeSdkInfo find(const QString &name); +private: + inline QString fixPaths(QString path) const; + QList<CeSdkInfo> m_list; + QString VCInstallDir; + QString VSInstallDir; +}; + +inline QList<CeSdkInfo> CeSdkHandler::listAll() const +{ + return m_list; +} + +inline QString CeSdkHandler::fixPaths(QString path) const +{ + QString str = QDir::toNativeSeparators(QDir::cleanPath(path.replace(VCINSTALL_MACRO, VCInstallDir).replace(VSINSTALL_MACRO, VSInstallDir).replace(QLatin1String("$(PATH)"), QLatin1String("%PATH%")))); + if (str.endsWith(';')) + str.truncate(str.length() - 1); + return str; +} + +#endif diff --git a/tools/checksdk/checksdk.pro b/tools/checksdk/checksdk.pro new file mode 100644 index 0000000..e364f26 --- /dev/null +++ b/tools/checksdk/checksdk.pro @@ -0,0 +1,71 @@ +TEMPLATE = app +DESTDIR = ../../bin +TARGET = checksdk +DEPENDPATH += . +INCLUDEPATH += . +QT = +CONFIG += console + +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +DEFINES += QT_BOOTSTRAPPED QT_NO_CODECS QT_LITE_UNICODE QT_NO_LIBRARY \ + QT_NO_STL QT_NO_COMPRESS QT_NO_DATASTREAM \ + QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_NO_THREAD \ + QT_NO_SYSTEMLOCALE QT_NO_GEOM_VARIANT \ + QT_NODLL QT_NO_QOBJECT + +INCLUDEPATH = \ + $$QT_BUILD_TREE/src/corelib/arch \ + $$QT_BUILD_TREE/include \ + $$QT_BUILD_TREE/include/QtCore + +DEPENDPATH += $$INCLUDEPATH $$QT_BUILD_TREE/src/corelib/base $$QT_BUILD_TREE/src/corelib/tools $$QT_BUILD_TREE/src/corelib/io + +# Input +SOURCES += \ + main.cpp \ + cesdkhandler.cpp + +HEADERS += \ + cesdkhandler.h + +# Bootstrapped Input +SOURCES += \ + $$QT_SOURCE_TREE/src/corelib/kernel/qmetatype.cpp \ + $$QT_SOURCE_TREE/src/corelib/kernel/qvariant.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qstring.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qbuffer.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qurl.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qdatetime.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qlocale.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qvector.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qlistdata.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \ + $$QT_SOURCE_TREE/src/corelib/global/qglobal.cpp \ + $$QT_SOURCE_TREE/src/corelib/global/qmalloc.cpp \ + $$QT_SOURCE_TREE/src/corelib/global/qnumeric.cpp \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.cpp \ + $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qregexp.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qmap.cpp \ + $$QT_SOURCE_TREE/src/corelib/tools/qbitarray.cpp \ + $$QT_BUILD_TREE/src/corelib/global/qconfig.cpp diff --git a/tools/checksdk/main.cpp b/tools/checksdk/main.cpp new file mode 100644 index 0000000..1d4b616 --- /dev/null +++ b/tools/checksdk/main.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "cesdkhandler.h" +#include <QtCore/QStringList> +#include <QtCore/QFile> +#include <QtCore/QDir> +#include <QtCore/QDebug> + +void usage() +{ + qDebug() << "SDK Scanner - Convenience Tool to setup your environment"; + qDebug() << " for crosscompilation to Windows CE"; + qDebug() << "Options:"; + qDebug() << "-help This output"; + qDebug() << "-list List all available SDKs"; + qDebug() << "-sdk <name> Select specified SDK."; + qDebug() << " Note: SDK names with spaces need to be"; + qDebug() << " specified in parenthesis"; + qDebug() << " default: Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"; + qDebug() << "-script <file> Create a script file which can be launched"; + qDebug() << " to setup your environment for specified SDK"; +} + +int main(int argc, char **argv) +{ + if (argc == 1) { + usage(); + return 0; + } + QString sdkName; + bool operationList = false; + QString scriptFile; + + QStringList arguments; + for (int i=0; i < argc; ++i) + arguments.append(QLatin1String(argv[i])); + for (int i=1; i < arguments.size(); ++i) { + if (arguments[i].toLower() == QLatin1String("-help")) { + usage(); + return 0; + } else if (arguments[i].toLower() == QLatin1String("-list")) { + operationList = true; + } else if (arguments[i].toLower() == QLatin1String("-sdk")) { + if (i+1 >= arguments.size()) { + qWarning("No SDK specified."); + return -1; + } + sdkName = arguments[++i]; + } else if (arguments[i].toLower() == QLatin1String("-script")) { + if (i+1 >= arguments.size()) { + qWarning("No scriptfile specified."); + return -1; + } + scriptFile = arguments[++i]; + } else { + qWarning("Unknown option:%s", qPrintable(arguments[i])); + usage(); + return -1; + } + } + + // Check for SDK Name, otherwise use Windows Mobile as default + if (sdkName.isEmpty()) { + qWarning("No SDK specified: Defaulting to Windows Mobile 5.0 Pocket PC SDK"); + sdkName = QString::fromLatin1("Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"); + } + + CeSdkHandler handler; + if (!handler.parse()) { + qWarning("Could not find any installed SDK, aborting!"); + return -1; + } + + QList<CeSdkInfo> list = handler.listAll(); + + if (operationList) { + qDebug() << "Available SDKs:"; + for (QList<CeSdkInfo>::iterator it = list.begin(); it != list.end(); ++it) + qDebug() << "SDK Name:" << it->name(); + return 0; + } + + // finally find the given SDK and prompt out the environment to be set + for (QList<CeSdkInfo>::iterator it = list.begin(); it != list.end(); ++it ) { + if (sdkName == it->name()) { + if (!it->isValid()) { + qWarning("Selected SDK is not valid!"); + return -1; + } else if (!it->isSupported()) { + qWarning("Selected SDK is not officially supported and might not work"); + } + QString binPath, includePath, libPath; + binPath = QString::fromLatin1("PATH=") + it->binPath(); + includePath = QString::fromLatin1("INCLUDE=") + it->includePath(); + libPath = QString::fromLatin1("LIB=") + it->libPath(); + if (scriptFile.isEmpty()) { + qDebug() << "Please set up your environment with the following paths:"; + qDebug() << qPrintable(binPath); + qDebug() << qPrintable(includePath); + qDebug() << qPrintable(libPath); + return 0; + } else { + QFile file(scriptFile); + if (!file.open(QIODevice::WriteOnly)) { + qWarning("Could not open target script file"); + return -1; + } + QString content; + content += QLatin1String("@echo off\n"); + content += QLatin1String("echo Environment Selection:") + sdkName + QLatin1String("\n"); + content += QLatin1String("set ") + binPath + QLatin1String("\n"); + content += QLatin1String("set ") + includePath + QLatin1String("\n"); + content += QLatin1String("set ") + libPath + QLatin1String("\n"); + file.write(content.toLatin1()); + return 0; + } + } + } + qWarning("Could not find specified SDK: %s" , qPrintable(sdkName)); + return 0; +}
\ No newline at end of file |