Commit 15905605 authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Add support for AMD64 compilers for MSVC.

At this point, compiling projects and debugger helpers works.
The speciality with this is that Qt does not provide distinct
mkspecs, because MSVC draws the line between 32 and 64 bit
solely by the environment.
parent 1d4802a5
......@@ -308,7 +308,7 @@ void GenericProject::setToolChainId(const QString &toolChainId)
} else if (toolChainId == QLatin1String("msvc")) {
const QString msvcVersion; // ### FIXME
m_toolChain = ToolChain::createMSVCToolChain(msvcVersion);
m_toolChain = ToolChain::createMSVCToolChain(msvcVersion, false);
} else if (toolChainId == QLatin1String("wince")) {
const QString msvcVersion, wincePlatform; // ### FIXME
......
......@@ -70,9 +70,9 @@ ToolChain *ToolChain::createMinGWToolChain(const QString &gcc, const QString &mi
return new MinGWToolChain(gcc, mingwPath);
}
ToolChain *ToolChain::createMSVCToolChain(const QString &name)
ToolChain *ToolChain::createMSVCToolChain(const QString &name, bool amd64 = false)
{
return new MSVCToolChain(name);
return new MSVCToolChain(name, amd64);
}
ToolChain *ToolChain::createWinCEToolChain(const QString &name, const QString &platform)
......@@ -85,6 +85,7 @@ QStringList ToolChain::availableMSVCVersions()
QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7",
QSettings::NativeFormat);
QStringList versions = registry.allKeys();
// qDebug() << "AVAILABLE MSVC VERSIONS:" << versions;
return versions;
}
......@@ -226,14 +227,15 @@ QString MinGWToolChain::makeCommand() const
}
MSVCToolChain::MSVCToolChain(const QString &name)
: m_name(name), m_valuesSet(false)
MSVCToolChain::MSVCToolChain(const QString &name, bool amd64)
: m_name(name), m_valuesSet(false), m_amd64(amd64)
{
if (m_name.isEmpty()) { // Could be because system qt doesn't set this
QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7",
QSettings::NativeFormat);
if (registry.allKeys().count())
m_name = registry.allKeys().first();
QStringList keys = registry.allKeys();
if (keys.count())
m_name = keys.first();
}
}
......@@ -283,7 +285,12 @@ void MSVCToolChain::addToEnvironment(ProjectExplorer::Environment &env)
return;
QString path = registry.value(m_name).toString();
QString desc;
QString varsbat = path + "Common7\\Tools\\vsvars32.bat";
QString varsbat;
if (m_amd64)
varsbat = path + "VC\\bin\\amd64\\vcvarsamd64.bat";
else
varsbat = path + "Common7\\Tools\\vsvars32.bat";
// qDebug() << varsbat;
if (QFileInfo(varsbat).exists()) {
QTemporaryFile tf(QDir::tempPath() + "\\XXXXXX.bat");
if (!tf.open())
......@@ -378,8 +385,9 @@ void WinCEToolChain::addToEnvironment(ProjectExplorer::Environment &env)
{
MSVCToolChain::addToEnvironment(env);
QSettings registry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7",
QSettings::NativeFormat);
QSettings::NativeFormat);
QString path = registry.value(m_name).toString();
// Find MSVC path
path += "/";
......
......@@ -90,7 +90,7 @@ public:
// Factory methods
static ToolChain *createGccToolChain(const QString &gcc);
static ToolChain *createMinGWToolChain(const QString &gcc, const QString &mingwPath);
static ToolChain *createMSVCToolChain(const QString &name);
static ToolChain *createMSVCToolChain(const QString &name, bool amd64);
static ToolChain *createWinCEToolChain(const QString &name, const QString &platform);
static QStringList availableMSVCVersions();
static QStringList supportedToolChains();
......@@ -136,7 +136,7 @@ private:
class MSVCToolChain : public ToolChain
{
public:
MSVCToolChain(const QString &name);
MSVCToolChain(const QString &name, bool amd64 = false);
virtual QByteArray predefinedMacros();
virtual QList<HeaderPath> systemHeaderPaths();
virtual void addToEnvironment(ProjectExplorer::Environment &env);
......@@ -149,6 +149,7 @@ private:
mutable QList<QPair<QString, QString> > m_values;
mutable bool m_valuesSet;
mutable ProjectExplorer::Environment m_lastEnvironment;
bool m_amd64;
};
// TODO some stuff needs to be moved into here
......
......@@ -400,7 +400,7 @@ ProjectExplorer::ToolChain *Qt4Project::toolChain(const QString &buildConfigurat
m_test = ToolChain::createMinGWToolChain(qmake_cxx, version->mingwDirectory());
//qDebug()<<"Mingw ToolChain";
} else if(t == ToolChain::MSVC) {
m_test = ToolChain::createMSVCToolChain(version->msvcVersion());
m_test = ToolChain::createMSVCToolChain(version->msvcVersion(), version->isMSVC64Bit());
//qDebug()<<"MSVC ToolChain ("<<version->msvcVersion()<<")";
} else if(t == ToolChain::WINCE) {
m_test = ToolChain::createWinCEToolChain(version->msvcVersion(), version->wincePlatform());
......
......@@ -45,6 +45,10 @@
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
#ifdef Q_OS_WIN32
#include <windows.h>
#endif
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
......@@ -873,6 +877,21 @@ QString QtVersion::debuggingHelperLibrary() const
}
bool QtVersion::isMSVC64Bit() const
{
const QString make = qmakeCommand();
qDebug() << make;
bool isAmd64 = false;
#ifdef Q_OS_WIN32
DWORD binaryType = 0;
bool success = GetBinaryTypeW(make.utf16(), &binaryType) != 0;
if (success && binaryType == SCS_64BIT_BINARY)
isAmd64=true;
// qDebug() << "isAmd64:" << isAmd64 << binaryType;
return isAmd64;
#endif
}
QString QtVersion::buildDebuggingHelperLibrary()
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
......@@ -888,7 +907,7 @@ QString QtVersion::buildDebuggingHelperLibrary()
if (t == ProjectExplorer::ToolChain::MinGW)
toolChain = ProjectExplorer::ToolChain::createMinGWToolChain("g++", mingwDirectory());
else if(t == ProjectExplorer::ToolChain::MSVC)
toolChain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion());
toolChain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isMSVC64Bit());
if (toolChain) {
toolChain->addToEnvironment(env);
delete toolChain;
......
......@@ -85,6 +85,7 @@ public:
QString buildDebuggingHelperLibrary();
int uniqueId() const;
bool isMSVC64Bit() const;
enum QmakeBuildConfig
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment