1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
41 #include "cesdkhandler.h"
42 #include <QtCore/QStringList>
43 #include <QtCore/QFile>
44 #include <QtCore/QDir>
45 #include <QtCore/QDebug>
49 printf("SDK Scanner - Convenience Tool to setup your environment\n");
50 printf(" for crosscompilation to Windows CE\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");
62 int main(int argc
, char **argv
)
69 bool operationList
= false;
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")) {
79 } else if (arguments
[i
].toLower() == QLatin1String("-list")) {
81 } else if (arguments
[i
].toLower() == QLatin1String("-sdk")) {
82 if (i
+1 >= arguments
.size()) {
83 qWarning("No SDK specified.");
86 sdkName
= arguments
[++i
];
87 } else if (arguments
[i
].toLower() == QLatin1String("-script")) {
88 if (i
+1 >= arguments
.size()) {
89 qWarning("No scriptfile specified.");
92 scriptFile
= arguments
[++i
];
94 qWarning("Unknown option:%s", qPrintable(arguments
[i
]));
100 CeSdkHandler handler
;
101 if (!handler
.parse()) {
102 qWarning("Could not find any installed SDK, aborting!");
106 QList
<CeSdkInfo
> list
= handler
.listAll();
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()));
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)");
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!");
130 } else if (!it
->isSupported()) {
131 qWarning("Selected SDK is not officially supported and might not work");
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
));
141 printf(qPrintable(includePath
));
143 printf(qPrintable(libPath
));
147 QFile
file(scriptFile
);
148 if (!file
.open(QIODevice::WriteOnly
)) {
149 qWarning("Could not open target script file");
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());
163 qWarning("Could not find specified SDK: %s" , qPrintable(sdkName
));