Commit cfc7040e authored by dt's avatar dt

The qtversions's toolchain now depends on the actual compiler not mkspec

That is we actually parse the mkspec and evaluate QMAKE_CXX (and a few
other variables) to figure out the correct mkspec. This makes using
custom mkspecs easier and is also cleaner. I also changed mkspec() and
mkspecPath() to behave a little diffrent, essentialy mkspec() will
return only the name (the actual dir name) of the mkspec. That is in
general not sufficient for passing on to qmake. mkspecPath() only
returns the correct path to mkspecs/default.
Hopefully I haven't broken WinCE/Maemo/MinGW.
parent fd0fbdde
......@@ -394,7 +394,7 @@ QString CMakeProject::buildParser(BuildConfiguration *configuration) const
if (!m_toolChain)
return QString::null;
if (m_toolChain->type() == ProjectExplorer::ToolChain::GCC
|| m_toolChain->type() == ProjectExplorer::ToolChain::LinuxICC
//|| m_toolChain->type() == ProjectExplorer::ToolChain::LinuxICC
|| m_toolChain->type() == ProjectExplorer::ToolChain::MinGW) {
return ProjectExplorer::Constants::BUILD_PARSER_GCC;
} else if (m_toolChain->type() == ProjectExplorer::ToolChain::MSVC
......
......@@ -844,7 +844,7 @@ static IDebuggerEngine *debuggerEngineForToolChain(ProjectExplorer::ToolChain::T
{
IDebuggerEngine *rc = 0;
switch (tc) {
case ProjectExplorer::ToolChain::LinuxICC:
//case ProjectExplorer::ToolChain::LinuxICC:
case ProjectExplorer::ToolChain::MinGW:
case ProjectExplorer::ToolChain::GCC:
rc = gdbEngine;
......@@ -1713,7 +1713,7 @@ bool DebuggerManager::checkDebugConfiguration(int toolChain,
bool success = true;
switch(toolChain) {
case ProjectExplorer::ToolChain::GCC:
case ProjectExplorer::ToolChain::LinuxICC:
//case ProjectExplorer::ToolChain::LinuxICC:
case ProjectExplorer::ToolChain::MinGW:
case ProjectExplorer::ToolChain::WINCE: // S60
case ProjectExplorer::ToolChain::WINSCW:
......
......@@ -413,7 +413,7 @@ QString GenericProject::buildParser(BuildConfiguration *configuration) const
if (m_toolChain) {
switch (m_toolChain->type()) {
case ProjectExplorer::ToolChain::GCC:
case ProjectExplorer::ToolChain::LinuxICC:
//case ProjectExplorer::ToolChain::LinuxICC:
case ProjectExplorer::ToolChain::MinGW:
return QLatin1String(ProjectExplorer::Constants::BUILD_PARSER_GCC);
......
......@@ -56,53 +56,6 @@ CeSdkHandler::CeSdkHandler()
{
}
static void readMkSpec(const QString &qtpath, QString *ceSdk, QString *ceArch)
{
QFile f(qtpath);
if (f.exists() && f.open(QIODevice::ReadOnly)) {
while (!f.atEnd()) {
QByteArray line = f.readLine();
if (line.startsWith("CE_SDK")) {
int index = line.indexOf('=');
if (index >= 0) {
*ceSdk = line.mid(index + 1).trimmed();
}
} else if (line.startsWith("CE_ARCH")) {
int index = line.indexOf('=');
if (index >= 0) {
*ceArch = line.mid(index + 1).trimmed();
}
} else if (line.startsWith("include(")) {
int startIndex = line.indexOf('(');
int endIndex = line.indexOf(')');
if (startIndex >= 0 && endIndex >= 0) {
QString path = line.mid(startIndex + 1, endIndex - startIndex - 1).trimmed();
int index = qtpath.lastIndexOf('/');
if (index >= 0)
readMkSpec(qtpath.left(index + 1) + path, ceSdk, ceArch);
else
readMkSpec(path, ceSdk, ceArch);
}
}
}
}
}
QString CeSdkHandler::platformName(const QString &qtpath)
{
QString platformName;
QString CE_SDK;
QString CE_ARCH;
readMkSpec(qtpath, &CE_SDK, &CE_ARCH);
if (!CE_SDK.isEmpty() && !CE_ARCH.isEmpty())
platformName = CE_SDK + " (" + CE_ARCH + ")";
return platformName;
}
bool CeSdkHandler::parse(const QString &vsdir)
{
// look at the file at %VCInstallDir%/vcpackages/WCE.VCPlatform.config
......
......@@ -111,8 +111,8 @@ QString ToolChain::toolChainName(ToolChainType tc)
switch (tc) {
case GCC:
return QCoreApplication::translate("ToolChain", "GCC");
case LinuxICC:
return QCoreApplication::translate("ToolChain", "Intel C++ Compiler (Linux)");
// case LinuxICC:
// return QCoreApplication::translate("ToolChain", "Intel C++ Compiler (Linux)");
case MinGW:
return QCoreApplication::translate("ToolChain", "MinGW");
case MSVC:
......
......@@ -75,7 +75,7 @@ public:
enum ToolChainType
{
GCC = 0,
LinuxICC = 1,
// LINUX_ICC = 1,
MinGW = 2,
MSVC = 3,
WINCE = 4,
......
......@@ -65,24 +65,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
m_importBuildConfig = result.first;
m_additionalArguments = result.second;
QString versionSpec = m_importVersion->sourcePath() + "/mkspecs/" + m_importVersion->mkspec();
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(m_additionalArguments);
// Compare mkspecs and add to additional arguments
if (parsedSpec.isEmpty()) {
// using the default spec, don't modify additional arguments
} else {
QString parsedSpecOrginal = parsedSpec;
if (QFileInfo(parsedSpec).isRelative())
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
m_additionalArguments = Qt4Project::removeSpecFromArgumentList(m_additionalArguments);
if (parsedSpec != versionSpec) {
m_additionalArguments.prepend(parsedSpecOrginal);
m_additionalArguments.prepend("-spec");
}
}
m_additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
}
// So now we have the version and the configuration for that version
......
......@@ -62,10 +62,6 @@ QStringList QMakeStep::arguments(const QString &buildConfiguration)
ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfiguration);
QStringList arguments;
arguments << project()->file()->fileName();
if (!additonalArguments.contains("-spec")) {
arguments << "-spec" << m_pro->qtVersion(bc)->mkspec();
}
arguments << "-r";
#ifdef Q_OS_WIN
......
......@@ -308,8 +308,7 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)),
m_fileInfo(new Qt4ProjectFile(this, fileName, this)),
m_isApplication(true),
m_projectFiles(new Qt4ProjectFiles),
m_toolChain(0)
m_projectFiles(new Qt4ProjectFiles)
{
m_manager->registerProject(this);
......@@ -322,7 +321,6 @@ Qt4Project::~Qt4Project()
{
m_manager->unregisterProject(this);
delete m_projectFiles;
delete m_toolChain;
}
void Qt4Project::defaultQtVersionChanged()
......@@ -496,17 +494,11 @@ void Qt4Project::scheduleUpdateCodeModel(Qt4ProjectManager::Internal::Qt4ProFile
ProjectExplorer::ToolChain *Qt4Project::toolChain(BuildConfiguration *configuration) const
{
ProjectExplorer::ToolChain *tempToolChain;
tempToolChain = qtVersion(configuration)->createToolChain(toolChainType(configuration));
if (!ProjectExplorer::ToolChain::equals(m_toolChain, tempToolChain)) {
if (m_toolChain)
delete m_toolChain;
m_toolChain = tempToolChain;
} else {
delete tempToolChain;
}
return m_toolChain;
ToolChain::ToolChainType tct = toolChainType(configuration);
foreach(ToolChain *tc, qtVersion(configuration)->toolChains())
if (tc->type() == tct)
return tc;
return 0;
}
QString Qt4Project::makeCommand(BuildConfiguration *configuration) const
......@@ -1009,9 +1001,8 @@ void Qt4Project::updateActiveRunConfiguration()
ProjectExplorer::ToolChain::ToolChainType Qt4Project::toolChainType(BuildConfiguration *configuration) const
{
const ProjectExplorer::ToolChain::ToolChainType originalType =
(ProjectExplorer::ToolChain::ToolChainType)configuration->value("ToolChain").toInt();
ProjectExplorer::ToolChain::ToolChainType type = originalType;
ToolChain::ToolChainType originalType = ToolChain::ToolChainType(configuration->value("ToolChain").toInt());
ToolChain::ToolChainType type = originalType;
const QtVersion *version = qtVersion(configuration);
if (!version->possibleToolChainTypes().contains(type)) // use default tool chain
type = version->defaultToolchainType();
......@@ -1233,19 +1224,6 @@ QStringList Qt4Project::removeSpecFromArgumentList(const QStringList &old)
return newList;
}
QString Qt4Project::extractSpecFromArgumentList(const QStringList &list)
{
int index = list.indexOf("-spec");
if (index == -1)
index = list.indexOf("-platform");
if (index == -1)
return QString();
if (index + 1 < list.length())
return list.at(index +1);
else
return QString();
}
// returns true if both are equal
bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *configuration, const QString &workingDirectory)
{
......@@ -1262,51 +1240,15 @@ bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *confi
// now compare arguments lists
// we have to compare without the spec/platform cmd argument
// and compare that on its own
QString actualSpec = extractSpecFromArgumentList(qs->value(configuration->name(), "qmakeArgs").toStringList());
if (actualSpec.isEmpty())
actualSpec = version->mkspec();
// Now to convert the actualSpec to a absolute path, we go through a few hops
if (QFileInfo(actualSpec).isRelative()) {
QString path = version->sourcePath() + "/mkspecs/" + actualSpec;
if (QFileInfo(path).exists()) {
actualSpec = QDir::cleanPath(path);
} else {
path = version->versionInfo().value("QMAKE_MKSPECS") + "/" + actualSpec;
if (QFileInfo(path).exists()) {
actualSpec = QDir::cleanPath(path);
} else {
path = workingDirectory + "/" + actualSpec;
if (QFileInfo(path).exists())
actualSpec = QDir::cleanPath(path);
}
}
}
QString parsedSpec = extractSpecFromArgumentList(result.second);
// if the MakeFile did not contain a mkspec, then it is the default for that qmake
if (parsedSpec.isEmpty())
parsedSpec = version->sourcePath() + "/mkspecs/" + version->mkspec();
if (QFileInfo(parsedSpec).isRelative())
parsedSpec = QDir::cleanPath(workingDirectory + "/" + parsedSpec);
QStringList actualArgs = removeSpecFromArgumentList(qs->value(configuration->name(), "qmakeArgs").toStringList());
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
#ifdef Q_OS_WIN
actualSpec = actualSpec.toLower();
parsedSpec = parsedSpec.toLower();
#endif
if (debug) {
qDebug()<<"Actual args:"<<actualArgs;
qDebug()<<"Parsed args:"<<parsedArgs;
qDebug()<<"Actual spec:"<<actualSpec;
qDebug()<<"Parsed spec:"<<parsedSpec;
}
if (actualArgs == parsedArgs && actualSpec == parsedSpec)
if (actualArgs == parsedArgs)
return true;
}
}
......
......@@ -198,6 +198,7 @@ public:
//returns the name of the qt version, might be QString::Null, which means default qt version
// qtVersion is in general the better method to use
QString qtVersionName(ProjectExplorer::BuildConfiguration *configuration) const;
ProjectExplorer::ToolChain *toolChain(ProjectExplorer::BuildConfiguration *configuration) const;
void setToolChainType(ProjectExplorer::BuildConfiguration *configuration, ProjectExplorer::ToolChain::ToolChainType type);
ProjectExplorer::ToolChain::ToolChainType toolChainType(ProjectExplorer::BuildConfiguration *configuration) const;
......@@ -234,7 +235,6 @@ public:
bool compareBuildConfigurationToImportFrom(ProjectExplorer::BuildConfiguration *configuration, const QString &workingDirectory);
static QStringList removeSpecFromArgumentList(const QStringList &old);
static QString extractSpecFromArgumentList(const QStringList &list);
signals:
void targetInformationChanged();
......@@ -293,8 +293,6 @@ private:
QList<Qt4ProjectManager::Internal::Qt4ProFileNode *> m_proFilesForCodeModelUpdate;
QMap<QString, Internal::CodeModelInfo> m_codeModelInfo;
mutable ProjectExplorer::ToolChain *m_toolChain;
friend class Qt4ProjectFile;
};
......
......@@ -288,17 +288,6 @@ void Qt4ProjectConfigWidget::importLabelClicked()
QtVersion::QmakeBuildConfig qmakeBuildConfig = result.first;
QStringList additionalArguments = result.second;
QString versionSpec = version->sourcePath() + "/mkspecs/" + version->mkspec();
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(additionalArguments);
QString parsedSpecOrginal = parsedSpec;
if (QFileInfo(parsedSpec).isRelative())
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
additionalArguments = Qt4Project::removeSpecFromArgumentList(additionalArguments);
if (parsedSpec != versionSpec) {
additionalArguments.prepend(parsedSpecOrginal);
additionalArguments.prepend("-spec");
}
// So we got all the information now apply it...
m_pro->setQtVersion(bc, version->uniqueId());
// Combo box will be updated at the end
......
......@@ -36,6 +36,10 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QHash>
namespace ProjectExplorer {
class ToolChain;
}
namespace Qt4ProjectManager {
namespace Internal {
......@@ -65,16 +69,21 @@ public:
QString name() const;
QString sourcePath() const;
QString mkspecPath() const;
QString qmakeCommand() const;
QString uicCommand() const;
QString designerCommand() const;
QString linguistCommand() const;
QList<ProjectExplorer::ToolChain::ToolChainType> possibleToolChainTypes() const;
QString mkspec() const;
ProjectExplorer::ToolChain::ToolChainType defaultToolchainType() const;
ProjectExplorer::ToolChain *createToolChain(ProjectExplorer::ToolChain::ToolChainType type) const;
QList<ProjectExplorer::ToolChain *> toolChains() const;
/// @returns the name of the mkspec, which is generally not enough
/// to pass to qmake.
QString mkspec() const;
/// @returns the full path to the default directory
/// specifally not the directory the symlink/ORIGINAL_QMAKESPEC points to
QString mkspecPath() const;
void setName(const QString &name);
void setQMakeCommand(const QString &path);
......@@ -90,7 +99,6 @@ public:
QString mingwDirectory() const;
void setMingwDirectory(const QString &directory);
QString msvcVersion() const;
QString wincePlatform() const;
void setMsvcVersion(const QString &version);
void addToEnvironment(ProjectExplorer::Environment &env) const;
......@@ -128,9 +136,8 @@ private:
void updateSourcePath();
void updateMkSpec() const;
void updateVersionInfo() const;
void updateQMakeCXX() const;
QString qmakeCXX() const;
QString findQtBinary(const QStringList &possibleName) const;
void updateToolChain() const;
QString m_name;
QString m_sourcePath;
QString m_mingwDirectory;
......@@ -147,6 +154,9 @@ private:
mutable QString m_mkspec; // updated lazily
mutable QString m_mkspecFullPath;
mutable bool m_toolChainUpToDate;
mutable QList<ProjectExplorer::ToolChain *> m_toolChains;
mutable bool m_versionInfoUpToDate;
mutable QHash<QString,QString> m_versionInfo; // updated lazily
mutable bool m_notInstalled;
......@@ -161,9 +171,6 @@ private:
mutable QString m_uicCommand;
mutable QString m_designerCommand;
mutable QString m_linguistCommand;
mutable bool m_qmakeCXXUpToDate;
mutable QString m_qmakeCXX;
};
struct QMakeAssignment
......
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