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/QStringList> |
43 | #include <QtCore/QFile> |
44 | #include <QtCore/QDir> |
45 | #include <QtCore/QDebug> |
46 | |
47 | void usage() |
48 | { |
49 | printf("SDK Scanner - Convenience Tool to setup your environment\n"); |
50 | printf(" for crosscompilation to Windows CE\n"); |
51 | printf("Options:\n"); |
52 | printf("-help This output\n"); |
53 | printf("-list List all available SDKs\n"); |
54 | printf("-sdk <name> Select specified SDK.\n"); |
55 | printf(" Note: SDK names with spaces need to be\n"); |
56 | printf(" specified in parenthesis\n"); |
57 | printf(" default: Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\n"); |
58 | printf("-script <file> Create a script file which can be launched\n"); |
59 | printf(" to setup your environment for specified SDK\n"); |
60 | } |
61 | |
62 | int main(int argc, char **argv) |
63 | { |
64 | if (argc == 1) { |
65 | usage(); |
66 | return 0; |
67 | } |
68 | QString sdkName; |
69 | bool operationList = false; |
70 | QString scriptFile; |
71 | |
72 | QStringList arguments; |
73 | for (int i=0; i < argc; ++i) |
74 | arguments.append(QLatin1String(argv[i])); |
75 | for (int i=1; i < arguments.size(); ++i) { |
76 | if (arguments[i].toLower() == QLatin1String("-help")) { |
77 | usage(); |
78 | return 0; |
79 | } else if (arguments[i].toLower() == QLatin1String("-list")) { |
80 | operationList = true; |
81 | } else if (arguments[i].toLower() == QLatin1String("-sdk")) { |
82 | if (i+1 >= arguments.size()) { |
83 | qWarning("No SDK specified."); |
84 | return -1; |
85 | } |
86 | sdkName = arguments[++i]; |
87 | } else if (arguments[i].toLower() == QLatin1String("-script")) { |
88 | if (i+1 >= arguments.size()) { |
89 | qWarning("No scriptfile specified."); |
90 | return -1; |
91 | } |
92 | scriptFile = arguments[++i]; |
93 | } else { |
94 | qWarning("Unknown option:%s", qPrintable(arguments[i])); |
95 | usage(); |
96 | return -1; |
97 | } |
98 | } |
99 | |
100 | CeSdkHandler handler; |
101 | if (!handler.parse()) { |
102 | qWarning("Could not find any installed SDK, aborting!"); |
103 | return -1; |
104 | } |
105 | |
106 | QList<CeSdkInfo> list = handler.listAll(); |
107 | |
108 | if (operationList) { |
109 | printf("Available SDKs:\n"); |
110 | for (QList<CeSdkInfo>::iterator it = list.begin(); it != list.end(); ++it) { |
111 | printf("SDK Name: "); |
112 | printf(qPrintable(it->name())); |
113 | printf("\n"); |
114 | } |
115 | return 0; |
116 | } |
117 | |
118 | // Check for SDK Name, otherwise use Windows Mobile as default |
119 | if (sdkName.isEmpty()) { |
120 | qWarning("No SDK specified: Defaulting to Windows Mobile 5.0 Pocket PC SDK"); |
121 | sdkName = QString::fromLatin1("Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"); |
122 | } |
123 | |
124 | // finally find the given SDK and prompt out the environment to be set |
125 | for (QList<CeSdkInfo>::iterator it = list.begin(); it != list.end(); ++it ) { |
126 | if (sdkName == it->name()) { |
127 | if (!it->isValid()) { |
128 | qWarning("Selected SDK is not valid!"); |
129 | return -1; |
130 | } else if (!it->isSupported()) { |
131 | qWarning("Selected SDK is not officially supported and might not work"); |
132 | } |
133 | QString binPath, includePath, libPath; |
134 | binPath = QString::fromLatin1("PATH=") + it->binPath(); |
135 | includePath = QString::fromLatin1("INCLUDE=") + it->includePath(); |
136 | libPath = QString::fromLatin1("LIB=") + it->libPath(); |
137 | if (scriptFile.isEmpty()) { |
138 | printf("Please set up your environment with the following paths:\n"); |
139 | printf(qPrintable(binPath)); |
140 | printf("\n"); |
141 | printf(qPrintable(includePath)); |
142 | printf("\n"); |
143 | printf(qPrintable(libPath)); |
144 | printf("\n"); |
145 | return 0; |
146 | } else { |
147 | QFile file(scriptFile); |
148 | if (!file.open(QIODevice::WriteOnly)) { |
149 | qWarning("Could not open target script file"); |
150 | return -1; |
151 | } |
152 | QString content; |
153 | content += QLatin1String("@echo off\n"); |
154 | content += QLatin1String("echo Environment Selection:") + sdkName + QLatin1String( "\n"); |
155 | content += QLatin1String("set ") + binPath + QLatin1String( "\n"); |
156 | content += QLatin1String("set ") + includePath + QLatin1String( "\n"); |
157 | content += QLatin1String("set ") + libPath + QLatin1String( "\n"); |
158 | file.write(content.toLatin1()); |
159 | return 0; |
160 | } |
161 | } |
162 | } |
163 | qWarning("Could not find specified SDK: %s", qPrintable(sdkName)); |
164 | return -1; |
165 | } |
166 |
Warning: That file was not part of the compilation database. It may have many parsing errors.