1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "cesdkhandler.h"
35 #include <utils/environment.h>
37 #include <QtCore/QFile>
38 #include <QtCore/QDebug>
39 #include <QtCore/QXmlStreamReader>
41 using namespace ProjectExplorer;
42 using namespace ProjectExplorer::Internal;
43 using Utils::Environment;
45 CeSdkInfo::CeSdkInfo()
46 : m_major(0), m_minor(0)
50 void CeSdkInfo::addToEnvironment(Environment &env)
52 qDebug() << "adding " << name() << "to Environment";
53 env.set("INCLUDE", m_include);
54 env.set("LIB", m_lib);
55 env.prependOrSetPath(m_bin);
58 CeSdkHandler::CeSdkHandler()
62 bool CeSdkHandler::parse(const QString &vsdir)
64 // look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config
65 // and scan through all installed sdks...
70 QDir vStudioDir(VCInstallDir);
71 if (!vStudioDir.cd("vcpackages"))
74 QFile configFile(vStudioDir.absoluteFilePath(QLatin1String("WCE.VCPlatform.config")));
76 if (!configFile.exists() || !configFile.open(QIODevice::ReadOnly))
81 QString currentElement;
82 CeSdkInfo currentItem;
83 QXmlStreamReader xml(&configFile);
84 while (!xml.atEnd()) {
86 if (xml.isStartElement()) {
87 currentElement = xml.name().toString();
88 if (currentElement == QLatin1String("Platform"))
89 currentItem = CeSdkInfo();
90 else if (currentElement == QLatin1String("Directories")) {
91 QXmlStreamAttributes attr = xml.attributes();
92 currentItem.m_include = fixPaths(attr.value(QLatin1String("Include")).toString());
93 currentItem.m_lib = fixPaths(attr.value(QLatin1String("Library")).toString());
94 currentItem.m_bin = fixPaths(attr.value(QLatin1String("Path")).toString());
96 } else if (xml.isEndElement()) {
97 if (xml.name().toString() == QLatin1String("Platform"))
98 m_list.append(currentItem);
99 } else if (xml.isCharacters() && !xml.isWhitespace()) {
100 if (currentElement == QLatin1String("PlatformName"))
101 currentItem.m_name = xml.text().toString();
102 else if (currentElement == QLatin1String("OSMajorVersion"))
103 currentItem.m_major = xml.text().toString().toInt();
104 else if (currentElement == QLatin1String("OSMinorVersion"))
105 currentItem.m_minor = xml.text().toString().toInt();
109 if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
110 qWarning("CeSdkHandler::parse(): XML ERROR: %d : %s", int(xml.lineNumber()), qPrintable(xml.errorString()));
113 return m_list.size() > 0 ? true : false;
116 CeSdkInfo CeSdkHandler::find(const QString &name)
118 qDebug() << "looking for platform " << name;
119 for (QList<CeSdkInfo>::iterator it = m_list.begin(); it != m_list.end(); ++it) {
120 qDebug() << "...." << it->name();
121 if (it->name() == name)