2009-03-20 14:57:12 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
#include "toolchain.h"
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "project.h"
|
2009-02-10 15:34:25 +01:00
|
|
|
#include "cesdkhandler.h"
|
2009-09-25 11:35:44 +02:00
|
|
|
#include "projectexplorersettings.h"
|
2009-03-20 14:57:12 +01:00
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QProcess>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QTemporaryFile>
|
|
|
|
|
#include <QtCore/QString>
|
2009-06-18 15:16:18 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
2009-02-10 15:34:25 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2009-05-20 12:59:19 +02:00
|
|
|
#ifdef Q_OS_WIN64
|
|
|
|
|
static const char * MSVC_RegKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7";
|
|
|
|
|
#else
|
2009-07-02 16:44:51 +02:00
|
|
|
static const char * MSVC_RegKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7";
|
2009-05-20 12:59:19 +02:00
|
|
|
#endif
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
bool ToolChain::equals(ToolChain *a, ToolChain *b)
|
|
|
|
|
{
|
|
|
|
|
if (a == b)
|
|
|
|
|
return true;
|
|
|
|
|
if (a == 0 || b == 0)
|
|
|
|
|
return false;
|
|
|
|
|
if (a->type() == b->type())
|
2009-06-22 12:45:07 +02:00
|
|
|
return a->equals(b);
|
2009-02-11 13:01:38 +01:00
|
|
|
return false;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChain()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::~ToolChain()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *ToolChain::createGccToolChain(const QString &gcc)
|
|
|
|
|
{
|
|
|
|
|
return new GccToolChain(gcc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *ToolChain::createMinGWToolChain(const QString &gcc, const QString &mingwPath)
|
|
|
|
|
{
|
|
|
|
|
return new MinGWToolChain(gcc, mingwPath);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-18 10:46:12 +02:00
|
|
|
ToolChain *ToolChain::createMSVCToolChain(const QString &name, bool amd64 = false)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2009-05-18 10:46:12 +02:00
|
|
|
return new MSVCToolChain(name, amd64);
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain *ToolChain::createWinCEToolChain(const QString &name, const QString &platform)
|
|
|
|
|
{
|
|
|
|
|
return new WinCEToolChain(name, platform);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ToolChain::availableMSVCVersions()
|
|
|
|
|
{
|
2009-05-20 12:59:19 +02:00
|
|
|
QSettings registry(MSVC_RegKey, QSettings::NativeFormat);
|
2009-02-10 15:34:25 +01:00
|
|
|
QStringList versions = registry.allKeys();
|
2009-05-20 12:59:19 +02:00
|
|
|
// qDebug() << "AVAILABLE MSVC VERSIONS:" << versions << "at" << MSVC_RegKey;
|
2009-02-10 15:34:25 +01:00
|
|
|
return versions;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-13 16:42:17 +02:00
|
|
|
QList<ToolChain::ToolChainType> ToolChain::supportedToolChains()
|
2009-03-12 13:50:43 +01:00
|
|
|
{
|
2009-08-13 16:42:17 +02:00
|
|
|
QList<ToolChain::ToolChainType> toolChains;
|
|
|
|
|
for (int i = 0; i < LAST_VALID; ++i) {
|
|
|
|
|
toolChains.append(ToolChainType(i));
|
|
|
|
|
}
|
|
|
|
|
return toolChains;
|
2009-03-12 13:50:43 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-18 15:16:18 +02:00
|
|
|
QString ToolChain::toolChainName(ToolChainType tc)
|
|
|
|
|
{
|
|
|
|
|
switch (tc) {
|
|
|
|
|
case GCC:
|
2009-08-12 14:26:04 +02:00
|
|
|
return QCoreApplication::translate("ToolChain", "GCC");
|
2009-06-18 15:16:18 +02:00
|
|
|
case LinuxICC:
|
2009-08-13 14:07:27 +02:00
|
|
|
return QCoreApplication::translate("ToolChain", "Intel C++ Compiler (Linux)");
|
2009-06-18 15:16:18 +02:00
|
|
|
case MinGW:
|
2009-08-12 14:26:04 +02:00
|
|
|
return QCoreApplication::translate("ToolChain", "MinGW");
|
2009-06-18 15:16:18 +02:00
|
|
|
case MSVC:
|
2009-08-13 14:07:27 +02:00
|
|
|
return QCoreApplication::translate("ToolChain", "Microsoft Visual C++");
|
2009-06-18 15:16:18 +02:00
|
|
|
case WINCE:
|
2009-08-12 14:26:04 +02:00
|
|
|
return QCoreApplication::translate("ToolChain", "Windows CE");
|
2009-08-13 16:42:17 +02:00
|
|
|
case WINSCW:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "WINSCW");
|
|
|
|
|
case GCCE:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "GCCE");
|
|
|
|
|
case RVCT_ARMV5:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "RVCT (ARMV5)");
|
|
|
|
|
case RVCT_ARMV6:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "RVCT (ARMV6)");
|
2009-06-18 15:16:18 +02:00
|
|
|
case OTHER:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "Other");
|
|
|
|
|
case INVALID:
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "<Invalid>");
|
|
|
|
|
case UNKNOWN:
|
|
|
|
|
break;
|
2009-08-21 15:59:17 +02:00
|
|
|
default:
|
2009-08-13 17:36:23 +02:00
|
|
|
Q_ASSERT("Missing name for Toolchaintype");
|
2009-06-18 15:16:18 +02:00
|
|
|
};
|
|
|
|
|
return QCoreApplication::translate("ToolChain", "<Unknown>");
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
GccToolChain::GccToolChain(const QString &gcc)
|
|
|
|
|
: m_gcc(gcc)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType GccToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return ToolChain::GCC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray GccToolChain::predefinedMacros()
|
|
|
|
|
{
|
|
|
|
|
if (m_predefinedMacros.isEmpty()) {
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
|
|
|
|
<< QLatin1String("-dM")
|
|
|
|
|
<< QLatin1String("-");
|
|
|
|
|
|
|
|
|
|
QProcess cpp;
|
2009-07-14 12:14:58 +02:00
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
cpp.setEnvironment(env.toStringList());
|
2009-02-10 15:34:25 +01:00
|
|
|
cpp.start(m_gcc, arguments);
|
|
|
|
|
cpp.closeWriteChannel();
|
|
|
|
|
cpp.waitForFinished();
|
|
|
|
|
m_predefinedMacros = cpp.readAllStandardOutput();
|
|
|
|
|
}
|
|
|
|
|
return m_predefinedMacros;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<HeaderPath> GccToolChain::systemHeaderPaths()
|
|
|
|
|
{
|
|
|
|
|
if (m_systemHeaderPaths.isEmpty()) {
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("-xc++")
|
|
|
|
|
<< QLatin1String("-E")
|
|
|
|
|
<< QLatin1String("-v")
|
|
|
|
|
<< QLatin1String("-");
|
|
|
|
|
|
|
|
|
|
QProcess cpp;
|
2009-07-14 12:14:58 +02:00
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2009-09-14 12:24:28 +02:00
|
|
|
env.set(QLatin1String("LC_ALL"), QLatin1String("C")); //override current locale settings
|
2009-07-14 12:14:58 +02:00
|
|
|
cpp.setEnvironment(env.toStringList());
|
2009-02-10 15:34:25 +01:00
|
|
|
cpp.setReadChannelMode(QProcess::MergedChannels);
|
|
|
|
|
cpp.start(m_gcc, arguments);
|
|
|
|
|
cpp.closeWriteChannel();
|
|
|
|
|
cpp.waitForFinished();
|
|
|
|
|
|
|
|
|
|
QByteArray line;
|
|
|
|
|
while (cpp.canReadLine()) {
|
|
|
|
|
line = cpp.readLine();
|
|
|
|
|
if (line.startsWith("#include"))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! line.isEmpty() && line.startsWith("#include")) {
|
|
|
|
|
HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
|
|
|
|
|
while (cpp.canReadLine()) {
|
|
|
|
|
line = cpp.readLine();
|
|
|
|
|
if (line.startsWith("#include")) {
|
|
|
|
|
kind = HeaderPath::GlobalHeaderPath;
|
|
|
|
|
} else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) {
|
|
|
|
|
HeaderPath::Kind thisHeaderKind = kind;
|
|
|
|
|
|
|
|
|
|
line = line.trimmed();
|
|
|
|
|
if (line.endsWith('\n'))
|
|
|
|
|
line.chop(1);
|
|
|
|
|
|
|
|
|
|
int index = line.indexOf(" (framework directory)");
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
line = line.left(index);
|
|
|
|
|
thisHeaderKind = HeaderPath::FrameworkHeaderPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
|
|
|
|
|
} else if (line.startsWith("End of search list.")) {
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "ignore line:" << line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m_systemHeaderPaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GccToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(env)
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 18:13:45 +01:00
|
|
|
QString GccToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
return "make";
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
bool GccToolChain::equals(ToolChain *other) const
|
|
|
|
|
{
|
|
|
|
|
return (m_gcc == static_cast<GccToolChain *>(other)->m_gcc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MinGWToolChain::MinGWToolChain(const QString &gcc, const QString &mingwPath)
|
|
|
|
|
: GccToolChain(gcc), m_mingwPath(mingwPath)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType MinGWToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return ToolChain::MinGW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MinGWToolChain::equals(ToolChain *other) const
|
|
|
|
|
{
|
|
|
|
|
MinGWToolChain *o = static_cast<MinGWToolChain *>(other);
|
|
|
|
|
return (m_mingwPath == o->m_mingwPath && this->GccToolChain::equals(other));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MinGWToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
|
|
|
|
{
|
2009-02-12 16:09:23 +01:00
|
|
|
//qDebug()<<"MinGWToolChain::addToEnvironment";
|
2009-07-03 19:06:00 +02:00
|
|
|
if (m_mingwPath.isEmpty())
|
|
|
|
|
return;
|
2009-02-10 15:34:25 +01:00
|
|
|
QString binDir = m_mingwPath + "/bin";
|
|
|
|
|
if (QFileInfo(binDir).exists())
|
|
|
|
|
env.prependOrSetPath(binDir);
|
2009-02-12 16:09:23 +01:00
|
|
|
// if (QFileInfo(binDir).exists())
|
|
|
|
|
// qDebug()<<"Adding "<<binDir<<" to the PATH";
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 18:13:45 +01:00
|
|
|
QString MinGWToolChain::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
return "mingw32-make.exe";
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2009-05-18 10:46:12 +02:00
|
|
|
MSVCToolChain::MSVCToolChain(const QString &name, bool amd64)
|
|
|
|
|
: m_name(name), m_valuesSet(false), m_amd64(amd64)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2009-02-12 16:09:23 +01:00
|
|
|
if (m_name.isEmpty()) { // Could be because system qt doesn't set this
|
2009-05-20 12:59:19 +02:00
|
|
|
QSettings registry(MSVC_RegKey, QSettings::NativeFormat);
|
2009-05-18 10:46:12 +02:00
|
|
|
QStringList keys = registry.allKeys();
|
|
|
|
|
if (keys.count())
|
|
|
|
|
m_name = keys.first();
|
2009-02-12 16:09:23 +01:00
|
|
|
}
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType MSVCToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return ToolChain::MSVC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MSVCToolChain::equals(ToolChain *other) const
|
|
|
|
|
{
|
|
|
|
|
MSVCToolChain *o = static_cast<MSVCToolChain *>(other);
|
|
|
|
|
return (m_name == o->m_name);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-16 17:16:29 +02:00
|
|
|
QByteArray msvcCompilationFile() {
|
|
|
|
|
static const char* macros[] = {"_ATL_VER", "_CHAR_UNSIGNED", "__CLR_VER",
|
|
|
|
|
"__cplusplus_cli", "__COUNTER__", "__cplusplus",
|
|
|
|
|
"_CPPLIB_VER", "_CPPRTTI", "_CPPUNWIND",
|
|
|
|
|
"_DEBUG", "_DLL", "__FUNCDNAME__",
|
|
|
|
|
"__FUNCSIG__","__FUNCTION__","_INTEGRAL_MAX_BITS",
|
|
|
|
|
"_M_ALPHA","_M_CEE","_M_CEE_PURE",
|
|
|
|
|
"_M_CEE_SAFE","_M_IX86","_M_IA64",
|
|
|
|
|
"_M_IX86_FP","_M_MPPC","_M_MRX000",
|
|
|
|
|
"_M_PPC","_M_X64","_MANAGED",
|
|
|
|
|
"_MFC_VER","_MSC_BUILD","_MSC_EXTENSIONS",
|
|
|
|
|
"_MSC_FULL_VER","_MSC_VER","__MSVC_RUNTIME_CHECKS",
|
|
|
|
|
"_MT", "_NATIVE_WCHAR_T_DEFINED", "_OPENMP",
|
|
|
|
|
"_VC_NODEFAULTLIB", "_WCHAR_T_DEFINED", "_WIN32",
|
|
|
|
|
"_WIN64", "_Wp64", "__DATE__", "__DATE__",
|
|
|
|
|
"__TIME__", "__TIMESTAMP__",
|
|
|
|
|
0};
|
|
|
|
|
QByteArray file = "#define __PPOUT__(x) V##x=x\n\n";
|
|
|
|
|
int i =0;
|
|
|
|
|
while (macros[i] != 0) {
|
|
|
|
|
const QByteArray macro(macros[i]);
|
|
|
|
|
file += "#if defined(" + macro + ")\n__PPOUT__("
|
|
|
|
|
+ macro + ")\n#endif\n";
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
file += "\nvoid main(){}\n\n";
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
QByteArray MSVCToolChain::predefinedMacros()
|
|
|
|
|
{
|
2009-09-16 17:16:29 +02:00
|
|
|
if (m_predefinedMacros.isEmpty()) {
|
|
|
|
|
m_predefinedMacros += "#define __MSVCRT__\n"
|
|
|
|
|
"#define __WINNT__\n"
|
|
|
|
|
"#define __WINNT\n"
|
2009-10-06 14:39:59 +02:00
|
|
|
"#define WINNT\n"
|
2009-10-14 18:06:10 +02:00
|
|
|
"#define __int64 long long\n"
|
|
|
|
|
"#define __int32 long\n"
|
|
|
|
|
"#define __int16 short\n"
|
|
|
|
|
"#define __int8 char\n"
|
|
|
|
|
"#define __ptr32\n"
|
|
|
|
|
"#define __ptr64\n";
|
2009-09-16 17:16:29 +02:00
|
|
|
|
|
|
|
|
QString tmpFilePath;
|
|
|
|
|
{
|
|
|
|
|
// QTemporaryFile is buggy and will not unlock the file for cl.exe
|
|
|
|
|
QTemporaryFile tmpFile(QDir::tempPath()+"/envtestXXXXXX.cpp");
|
|
|
|
|
tmpFile.setAutoRemove(false);
|
|
|
|
|
if (!tmpFile.open())
|
|
|
|
|
return m_predefinedMacros;
|
|
|
|
|
tmpFilePath = QFileInfo(tmpFile).canonicalFilePath();
|
|
|
|
|
tmpFile.write(msvcCompilationFile());
|
|
|
|
|
tmpFile.close();
|
|
|
|
|
}
|
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
QProcess cpp;
|
|
|
|
|
cpp.setEnvironment(env.toStringList());
|
|
|
|
|
cpp.setWorkingDirectory(QDir::tempPath());
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << "/EP" << QDir::toNativeSeparators(tmpFilePath);
|
|
|
|
|
cpp.start(QLatin1String("cl.exe"), arguments);
|
|
|
|
|
cpp.closeWriteChannel();
|
|
|
|
|
cpp.waitForFinished();
|
|
|
|
|
QList<QByteArray> output = cpp.readAllStandardOutput().split('\n');
|
|
|
|
|
foreach (const QByteArray& line, output) {
|
|
|
|
|
if (line.startsWith('V')) {
|
|
|
|
|
QList<QByteArray> split = line.split('=');
|
|
|
|
|
QByteArray key = split.at(0).mid(1);
|
|
|
|
|
QByteArray value = split.at(1);
|
|
|
|
|
if (!value.isEmpty()) {
|
2009-09-21 16:57:04 +02:00
|
|
|
value.chop(1); //remove '\n'
|
2009-09-16 17:16:29 +02:00
|
|
|
}
|
|
|
|
|
QByteArray newDefine = "#define " + key + " " + value + '\n';
|
|
|
|
|
m_predefinedMacros.append(newDefine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QFile::remove(tmpFilePath);
|
|
|
|
|
}
|
|
|
|
|
//qDebug() << m_predefinedMacros;
|
|
|
|
|
return m_predefinedMacros;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<HeaderPath> MSVCToolChain::systemHeaderPaths()
|
|
|
|
|
{
|
|
|
|
|
//TODO fix this code
|
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2009-02-12 16:09:23 +01:00
|
|
|
QList<HeaderPath> headerPaths;
|
|
|
|
|
foreach(const QString &path, env.value("INCLUDE").split(QLatin1Char(';'))) {
|
|
|
|
|
headerPaths.append(HeaderPath(path, HeaderPath::GlobalHeaderPath));
|
|
|
|
|
}
|
|
|
|
|
return headerPaths;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MSVCToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
|
|
|
|
{
|
2009-03-19 18:15:33 +01:00
|
|
|
if (!m_valuesSet || env != m_lastEnvironment) {
|
|
|
|
|
m_lastEnvironment = env;
|
2009-05-20 12:59:19 +02:00
|
|
|
QSettings registry(MSVC_RegKey, QSettings::NativeFormat);
|
2009-02-12 16:09:23 +01:00
|
|
|
if (m_name.isEmpty())
|
|
|
|
|
return;
|
2009-02-10 15:34:25 +01:00
|
|
|
QString path = registry.value(m_name).toString();
|
|
|
|
|
QString desc;
|
2009-05-18 10:46:12 +02:00
|
|
|
QString varsbat;
|
|
|
|
|
if (m_amd64)
|
2009-07-13 18:02:00 +02:00
|
|
|
varsbat = path + "bin\\amd64\\vcvarsamd64.bat";
|
2009-05-18 10:46:12 +02:00
|
|
|
else
|
2009-07-13 18:02:00 +02:00
|
|
|
varsbat = path + "bin\\vcvars32.bat";
|
2009-07-03 12:46:38 +02:00
|
|
|
// qDebug() << varsbat;
|
2009-02-10 15:34:25 +01:00
|
|
|
if (QFileInfo(varsbat).exists()) {
|
|
|
|
|
QTemporaryFile tf(QDir::tempPath() + "\\XXXXXX.bat");
|
|
|
|
|
if (!tf.open())
|
|
|
|
|
return;
|
|
|
|
|
QString filename = tf.fileName();
|
|
|
|
|
tf.write("call \"" + varsbat.toLocal8Bit()+"\"\r\n");
|
|
|
|
|
tf.write(("set > \"" + QDir::tempPath() + "\\qtcreator-msvc-environment.txt\"\r\n").toLocal8Bit());
|
|
|
|
|
tf.flush();
|
|
|
|
|
tf.waitForBytesWritten(30000);
|
|
|
|
|
|
2009-03-19 18:15:33 +01:00
|
|
|
QProcess run;
|
|
|
|
|
run.setEnvironment(env.toStringList());
|
2009-02-10 15:34:25 +01:00
|
|
|
QString cmdPath = env.searchInPath("cmd");
|
|
|
|
|
run.start(cmdPath, QStringList()<<"/c"<<filename);
|
|
|
|
|
run.waitForFinished();
|
|
|
|
|
tf.close();
|
|
|
|
|
|
|
|
|
|
QFile vars(QDir::tempPath() + "\\qtcreator-msvc-environment.txt");
|
|
|
|
|
if (vars.exists() && vars.open(QIODevice::ReadOnly)) {
|
|
|
|
|
while (!vars.atEnd()) {
|
|
|
|
|
QByteArray line = vars.readLine();
|
|
|
|
|
QString line2 = QString::fromLocal8Bit(line);
|
|
|
|
|
line2 = line2.trimmed();
|
|
|
|
|
QRegExp regexp("(\\w*)=(.*)");
|
|
|
|
|
if (regexp.exactMatch(line2)) {
|
|
|
|
|
QString variable = regexp.cap(1);
|
|
|
|
|
QString value = regexp.cap(2);
|
|
|
|
|
m_values.append(QPair<QString, QString>(variable, value));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vars.close();
|
|
|
|
|
vars.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_valuesSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList< QPair<QString, QString> >::const_iterator it, end;
|
|
|
|
|
end = m_values.constEnd();
|
|
|
|
|
for (it = m_values.constBegin(); it != end; ++it) {
|
|
|
|
|
env.set((*it).first, (*it).second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 18:13:45 +01:00
|
|
|
QString MSVCToolChain::makeCommand() const
|
|
|
|
|
{
|
2009-08-12 15:20:36 +02:00
|
|
|
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().useJom) {
|
|
|
|
|
// We want jom! Try to find it.
|
|
|
|
|
QString jom = QCoreApplication::applicationDirPath() + QLatin1String("/jom.exe");
|
|
|
|
|
if (QFileInfo(jom).exists())
|
|
|
|
|
return jom;
|
|
|
|
|
else
|
|
|
|
|
return "jom.exe";
|
|
|
|
|
}
|
2009-03-16 18:13:45 +01:00
|
|
|
return "nmake.exe";
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
WinCEToolChain::WinCEToolChain(const QString &name, const QString &platform)
|
|
|
|
|
: MSVCToolChain(name), m_platform(platform)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChain::ToolChainType WinCEToolChain::type() const
|
|
|
|
|
{
|
|
|
|
|
return ToolChain::WINCE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WinCEToolChain::equals(ToolChain *other) const
|
|
|
|
|
{
|
|
|
|
|
WinCEToolChain *o = static_cast<WinCEToolChain *>(other);
|
|
|
|
|
return (m_platform == o->m_platform && this->MSVCToolChain::equals(other));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray WinCEToolChain::predefinedMacros()
|
|
|
|
|
{
|
|
|
|
|
//TODO
|
|
|
|
|
return MSVCToolChain::predefinedMacros();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<HeaderPath> WinCEToolChain::systemHeaderPaths()
|
|
|
|
|
{
|
|
|
|
|
//TODO fix this code
|
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
|
addToEnvironment(env);
|
2009-03-30 14:54:57 +02:00
|
|
|
|
|
|
|
|
QList<HeaderPath> headerPaths;
|
|
|
|
|
|
|
|
|
|
const QStringList includes = env.value("INCLUDE").split(QLatin1Char(';'));
|
|
|
|
|
|
|
|
|
|
foreach (const QString &path, includes) {
|
|
|
|
|
const HeaderPath headerPath(path, HeaderPath::GlobalHeaderPath);
|
|
|
|
|
headerPaths.append(headerPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headerPaths;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env)
|
|
|
|
|
{
|
|
|
|
|
MSVCToolChain::addToEnvironment(env);
|
2009-05-20 12:59:19 +02:00
|
|
|
QSettings registry(MSVC_RegKey, QSettings::NativeFormat);
|
2009-02-10 15:34:25 +01:00
|
|
|
QString path = registry.value(m_name).toString();
|
2009-05-18 10:46:12 +02:00
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
// Find MSVC path
|
|
|
|
|
|
|
|
|
|
path += "/";
|
|
|
|
|
|
2009-10-06 16:07:34 +10:00
|
|
|
// qDebug()<<"MSVC path"<<path;
|
2009-02-10 15:34:25 +01:00
|
|
|
// qDebug()<<"looking for platform name in"<< path() + "/mkspecs/" + mkspec() +"/qmake.conf";
|
|
|
|
|
// Find Platform name
|
2009-10-06 16:07:34 +10:00
|
|
|
// qDebug()<<"Platform Name"<<m_platform;
|
2009-02-10 15:34:25 +01:00
|
|
|
|
|
|
|
|
CeSdkHandler cesdkhandler;
|
|
|
|
|
cesdkhandler.parse(path);
|
|
|
|
|
cesdkhandler.find(m_platform).addToEnvironment(env);
|
2009-02-12 16:09:23 +01:00
|
|
|
//qDebug()<<"WinCE Final Environment:";
|
|
|
|
|
//qDebug()<<env.toStringList();
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|