Commit 75e23cc5 authored by dt's avatar dt

Fix -spec handling

parent 4769ceb0
......@@ -132,7 +132,7 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmake
const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), &errorMessage);
if (directory.isEmpty())
return errorMessage;
return buildDebuggingHelperLibrary(directory, make, qmakePath, env);
return buildDebuggingHelperLibrary(directory, make, qmakePath, QString::null, env);
}
// Copy helper source files to a target directory, replacing older files.
......@@ -188,7 +188,7 @@ QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInst
return QString();
}
QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const Environment &env)
QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env)
{
QString output;
const QChar newline = QLatin1Char('\n');
......@@ -218,7 +218,7 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &direc
output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Running %1 ...\n").arg(qmakeCommand);
QStringList makeArgs;
makeArgs << QLatin1String("-spec")<< QString(QLatin1String("default")) << QLatin1String("gdbmacros.pro");
makeArgs << QLatin1String("-spec")<< (mkspec.isEmpty() ? QString(QLatin1String("default")) : mkspec) << QLatin1String("gdbmacros.pro");
proc.start(qmakeCommand, makeArgs);
proc.waitForFinished();
......
......@@ -53,7 +53,7 @@ public:
// Build the helpers and return the output log/errormessage.
static QString buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env);
static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const Environment &env);
static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env);
// Copy the source files to a target location and return the chosen target location.
static QString copyDebuggingHelperLibrary(const QString &qtInstallData, QString *errorMessage);
......
......@@ -67,6 +67,17 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
m_importBuildConfig = result.first;
m_additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, m_importVersion);
QString versionSpec = m_importVersion->mkspec();
// Compare mkspecs and add to additional arguments
if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
// using the default spec, don't modify additional arguments
} else {
m_additionalArguments.prepend(parsedSpec);
m_additionalArguments.prepend("-spec");
}
}
// So now we have the version and the configuration for that version
......
......@@ -65,7 +65,7 @@ QStringList QMakeStep::arguments(const QString &buildConfiguration)
arguments << "-r";
if (!additonalArguments.contains("-spec"))
arguments << "-spec" << "default";
arguments << "-spec" << m_pro->qtVersion(bc)->mkspec();
#ifdef Q_OS_WIN
ToolChain::ToolChainType type = m_pro->toolChainType(bc);
......
......@@ -1001,6 +1001,58 @@ ProjectExplorer::ToolChain::ToolChainType Qt4Project::toolChainType(BuildConfigu
return type;
}
QString Qt4Project::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version)
{
int index = list.indexOf("-spec");
if (index == -1)
index = list.indexOf("-platform");
if (index == -1)
return QString();
++index;
if (index >= list.length())
return QString();
QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS");
if (baseMkspecDir.isEmpty())
baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
QString parsedSpec = QDir::cleanPath(list.at(index));
// if the path is relative it can be
// relative to the working directory (as found in the Makefiles)
// or relatively to the mkspec directory
// if it is the former we need to get the canonical form
// for the other one we don't need to do anything
if (QFileInfo(parsedSpec).isRelative()) {
if(QFileInfo(directory + "/" + parsedSpec).exists()) {
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
} else {
parsedSpec = baseMkspecDir + "/" + parsedSpec;
}
}
QFileInfo f2(parsedSpec);
while (f2.isSymLink()) {
parsedSpec = f2.symLinkTarget();
f2.setFile(parsedSpec);
}
if (parsedSpec.startsWith(baseMkspecDir)) {
parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1);
} else {
QString sourceMkSpecPath = version->sourcePath() + "/mkspecs";
if (parsedSpec.startsWith(sourceMkSpecPath)) {
parsedSpec = sourceMkSpecPath.mid(sourceMkSpecPath.length() + 1);
}
}
#ifdef Q_OS_WIN
parsedSpec = parsedSpec.toLower();
#endif
return parsedSpec;
}
BuildConfigWidget *Qt4Project::createConfigWidget()
{
return new Qt4ProjectConfigWidget(this);
......@@ -1235,16 +1287,31 @@ 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(), workingDirectory, version);
if (actualSpec.isEmpty()) {
// Easy one the user has choosen not to override the settings
actualSpec = version->mkspec();
}
QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version);
QStringList actualArgs = removeSpecFromArgumentList(qs->value(configuration->name(), "qmakeArgs").toStringList());
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
if (debug) {
// if (debug) {
qDebug()<<"Actual args:"<<actualArgs;
qDebug()<<"Parsed args:"<<parsedArgs;
qDebug()<<"Actual spec:"<<actualSpec;
qDebug()<<"Parsed spec:"<<parsedSpec;
// }
if (actualArgs == parsedArgs) {
// Specs match exactly
if (actualSpec == parsedSpec)
return true;
// Actual spec is the default one
if (actualSpec == version->mkspec() && (parsedSpec == "default" || parsedSpec.isEmpty()))
return true;
}
if (actualArgs == parsedArgs)
return true;
}
}
}
......
......@@ -236,6 +236,7 @@ public:
bool compareBuildConfigurationToImportFrom(ProjectExplorer::BuildConfiguration *configuration, const QString &workingDirectory);
static QStringList removeSpecFromArgumentList(const QStringList &old);
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
signals:
void targetInformationChanged();
void qtVersionChanged(ProjectExplorer::BuildConfiguration *);
......
......@@ -223,6 +223,8 @@ void Qt4ProjectConfigWidget::shadowBuildCheckBoxClicked(bool checked)
else
bc->setValue("buildDirectory", QVariant(QString::null));
updateDetails();
m_pro->invalidateCachedTargetInformation();
updateImportLabel();
}
void Qt4ProjectConfigWidget::updateImportLabel()
......@@ -286,7 +288,15 @@ void Qt4ProjectConfigWidget::importLabelClicked()
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
QtVersion::QmakeBuildConfig qmakeBuildConfig = result.first;
QStringList additionalArguments = result.second;
QStringList additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, version);
QString versionSpec = version->mkspecPath();
if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
// using the default spec, don't modify additional arguments
} else {
additionalArguments.prepend(parsedSpec);
additionalArguments.prepend("-spec");
}
// So we got all the information now apply it...
m_pro->setQtVersion(bc, version->uniqueId());
......
......@@ -142,10 +142,9 @@ private:
static int getUniqueId();
// Also used by QtOptionsPageWidget
void updateSourcePath();
void updateMkSpec() const;
void updateVersionInfo() const;
QString findQtBinary(const QStringList &possibleName) const;
void updateToolChain() const;
void updateToolChainAndMkspec() const;
QString m_name;
QString m_sourcePath;
QString m_mingwDirectory;
......@@ -160,11 +159,9 @@ private:
QString m_gcceDirectory;
#endif
mutable bool m_mkspecUpToDate;
mutable bool m_toolChainUpToDate;
mutable QString m_mkspec; // updated lazily
mutable QString m_mkspecFullPath;
mutable bool m_toolChainUpToDate;
mutable QList<QSharedPointer<ProjectExplorer::ToolChain> > m_toolChains;
mutable bool m_versionInfoUpToDate;
......
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