Commit 15471e64 authored by dt's avatar dt
Browse files

More import fixes and tweaks

Don't add -spec foo to the additional Arguments if foo is the same as
the default mkspec. This makes the common case better, while breaking if
you have QMAKESPEC set in teh environment and used -spec foo to override
it.
parent 4b26aaa3
......@@ -66,6 +66,18 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
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);
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");
}
}
// So now we have the version and the configuration for that version
......
......@@ -1106,7 +1106,7 @@ void Qt4Project::invalidateCachedTargetInformation()
// intelligent matching for -cache, but i guess people rarely
// do use that.
QStringList removeSpecFromArgumentList(const QStringList &old)
QStringList Qt4Project::removeSpecFromArgumentList(const QStringList &old)
{
if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache"))
return old;
......@@ -1128,7 +1128,7 @@ QStringList removeSpecFromArgumentList(const QStringList &old)
return newList;
}
QString extractSpecFromArgumentList(const QStringList &list)
QString Qt4Project::extractSpecFromArgumentList(const QStringList &list)
{
int index = list.indexOf("-spec");
if (index == -1)
......@@ -1157,7 +1157,7 @@ bool Qt4Project::compareBuildConfigurationToImportFrom(const QString &buildConfi
// and compare that on its own
QString actualSpec = extractSpecFromArgumentList(qmakeStep()->value(buildConfiguration, "qmakeArgs").toStringList());
if (actualSpec.isEmpty())
actualSpec = qtVersion(buildConfiguration)->mkspec();
actualSpec = version->mkspec();
QString parsedSpec = extractSpecFromArgumentList(result.second);
// Now to convert the actualSpec to a absolute path, we go through a few hops
......@@ -1180,7 +1180,6 @@ bool Qt4Project::compareBuildConfigurationToImportFrom(const QString &buildConfi
if (QFileInfo(parsedSpec).isRelative())
parsedSpec = QDir::cleanPath(workingDirectory + "/" + parsedSpec);
qDebug()<<"before:"<<qmakeStep()->value(buildConfiguration, "qmakeArgs").toStringList();
QStringList actualArgs = removeSpecFromArgumentList(qmakeStep()->value(buildConfiguration, "qmakeArgs").toStringList());
qDebug()<<"after:"<<actualArgs;
......
......@@ -198,6 +198,8 @@ public:
bool compareBuildConfigurationToImportFrom(const QString &buildConfiguration, const QString &workingDirectory);
static QStringList removeSpecFromArgumentList(const QStringList &old);
static QString extractSpecFromArgumentList(const QStringList &list);
signals:
void targetInformationChanged();
......
......@@ -231,48 +231,57 @@ void Qt4ProjectConfigWidget::shadowBuildLineEditTextChanged()
void Qt4ProjectConfigWidget::importLabelClicked()
{
if (m_ui->shadowBuildCheckBox->isChecked()) {
QString directory = m_ui->shadowBuildDirEdit->path();
if (!directory.isEmpty()) {
QString qtPath = QtVersionManager::findQtVersionFromMakefile(directory);
if (!qtPath.isEmpty()) {
QtVersionManager *vm = QtVersionManager::instance();
QtVersion *version = vm->qtVersionForDirectory(qtPath);
if (!version) {
version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath);
vm->addVersion(version);
}
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
QtVersion::QmakeBuildConfig qmakeBuildConfig = result.first;
QStringList additionalArguments = result.second;
// So we got all the information now apply it...
m_pro->setQtVersion(m_buildConfiguration, version->uniqueId());
// Combo box will be updated at the end
QMakeStep *qmakeStep = m_pro->qmakeStep();
qmakeStep->setValue(m_buildConfiguration, "qmakeArgs", additionalArguments);
MakeStep *makeStep = m_pro->makeStep();
m_pro->setValue(m_buildConfiguration, "buildConfiguration", int(qmakeBuildConfig));
// Adjust command line arguments, this is ugly as hell
// If we are switching to BuildAll we want "release" in there and no "debug"
// or "debug" in there and no "release"
// If we are switching to not BuildAl we want neither "release" nor "debug" in there
QStringList makeCmdArguments = makeStep->value(m_buildConfiguration, "makeargs").toStringList();
bool debug = qmakeBuildConfig & QtVersion::DebugBuild;
if (qmakeBuildConfig & QtVersion::BuildAll) {
makeCmdArguments.removeAll(debug ? "release" : "debug");
if (!makeCmdArguments.contains(debug ? "debug" : "release"))
makeCmdArguments.append(debug ? "debug" : "release");
} else {
makeCmdArguments.removeAll("debug");
makeCmdArguments.removeAll("release");
}
makeStep->setValue(m_buildConfiguration, "makeargs", makeCmdArguments);
QString directory = m_pro->buildDirectory(m_buildConfiguration);
if (!directory.isEmpty()) {
QString qtPath = QtVersionManager::findQtVersionFromMakefile(directory);
if (!qtPath.isEmpty()) {
QtVersionManager *vm = QtVersionManager::instance();
QtVersion *version = vm->qtVersionForDirectory(qtPath);
if (!version) {
version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath);
vm->addVersion(version);
}
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
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(m_buildConfiguration, version->uniqueId());
// Combo box will be updated at the end
QMakeStep *qmakeStep = m_pro->qmakeStep();
qmakeStep->setValue(m_buildConfiguration, "qmakeArgs", additionalArguments);
MakeStep *makeStep = m_pro->makeStep();
m_pro->setValue(m_buildConfiguration, "buildConfiguration", int(qmakeBuildConfig));
// Adjust command line arguments, this is ugly as hell
// If we are switching to BuildAll we want "release" in there and no "debug"
// or "debug" in there and no "release"
// If we are switching to not BuildAl we want neither "release" nor "debug" in there
QStringList makeCmdArguments = makeStep->value(m_buildConfiguration, "makeargs").toStringList();
bool debug = qmakeBuildConfig & QtVersion::DebugBuild;
if (qmakeBuildConfig & QtVersion::BuildAll) {
makeCmdArguments.removeAll(debug ? "release" : "debug");
if (!makeCmdArguments.contains(debug ? "debug" : "release"))
makeCmdArguments.append(debug ? "debug" : "release");
} else {
makeCmdArguments.removeAll("debug");
makeCmdArguments.removeAll("release");
}
makeStep->setValue(m_buildConfiguration, "makeargs", makeCmdArguments);
}
}
setupQtVersionsComboBox();
......
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