Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41#include "cesdkhandler.h"
42#include <QtCore/QFile>
43#include <QtCore/QDebug>
44#include <QtCore/QXmlStreamReader>
45
46CeSdkInfo::CeSdkInfo() : m_major(0) , m_minor(0)
47{
48}
49
50QStringList CeSdkInfo::environment()
51{
52 QStringList result;
53 QString argument = QLatin1String("PATH=");
54 argument += m_bin;
55 result.append(argument);
56 argument = QLatin1String("INCLUDE=");
57 argument += m_include;
58 result.append(argument);
59 argument = QLatin1String("LIB=");
60 argument += m_lib;
61 result.append(argument);
62 return result;
63}
64
65CeSdkHandler::CeSdkHandler()
66{
67}
68
69bool CeSdkHandler::parse()
70{
71 // look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config
72 // and scan through all installed sdks...
73 m_list.clear();
74 VCInstallDir = QString::fromLatin1(qgetenv("VCInstallDir"));
75 VCInstallDir += QLatin1String("\\");
76 VSInstallDir = QString::fromLatin1(qgetenv("VSInstallDir"));
77 VSInstallDir += QLatin1String("\\");
78 if (VCInstallDir.isEmpty() || VSInstallDir.isEmpty())
79 return false;
80
81 QDir vStudioDir(VCInstallDir);
82 if (!vStudioDir.cd(QLatin1String("vcpackages")))
83 return false;
84
85 QFile configFile(vStudioDir.absoluteFilePath(QLatin1String("WCE.VCPlatform.config")));
86 if (!configFile.exists() || !configFile.open(QIODevice::ReadOnly))
87 return false;
88
89 QString currentElement;
90 CeSdkInfo currentItem;
91 QXmlStreamReader xml(&configFile);
92 while (!xml.atEnd()) {
93 xml.readNext();
94 if (xml.isStartElement()) {
95 currentElement = xml.name().toString();
96 if (currentElement == QLatin1String("Platform"))
97 currentItem = CeSdkInfo();
98 else if (currentElement == QLatin1String("Directories")) {
99 QXmlStreamAttributes attr = xml.attributes();
100 currentItem.m_include = fixPaths(attr.value(QLatin1String("Include")).toString());
101 currentItem.m_lib = fixPaths(attr.value(QLatin1String("Library")).toString());
102 currentItem.m_bin = fixPaths(attr.value(QLatin1String("Path")).toString());
103 }
104 } else if (xml.isEndElement()) {
105 if (xml.name().toString() == QLatin1String("Platform"))
106 m_list.append(currentItem);
107 } else if (xml.isCharacters() && !xml.isWhitespace()) {
108 if (currentElement == QLatin1String("PlatformName"))
109 currentItem.m_name = xml.text().toString();
110 else if (currentElement == QLatin1String("OSMajorVersion"))
111 currentItem.m_major = xml.text().toString().toInt();
112 else if (currentElement == QLatin1String("OSMinorVersion"))
113 currentItem.m_minor = xml.text().toString().toInt();
114 }
115 }
116
117 if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
118 qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
119 return false;
120 }
121
122 return m_list.size() > 0 ? true : false;
123}
124
125CeSdkInfo CeSdkHandler::find(const QString &name)
126{
127 for (QList<CeSdkInfo>::iterator it = m_list.begin(); it != m_list.end(); ++it) {
128 if (it->name() == name)
129 return *it;
130 }
131 return CeSdkInfo();
132}
133

Warning: That file was not part of the compilation database. It may have many parsing errors.