OSDN Git Service

qmake: Skip running qmake when using non-default tool chains
authorTobias Hunger <tobias.hunger@nokia.com>
Wed, 1 Jun 2011 15:03:44 +0000 (15:03 +0000)
committerTobias Hunger <tobias.hunger@nokia.com>
Tue, 7 Jun 2011 14:21:41 +0000 (16:21 +0200)
Do not rerun qmake when using a tool chain which requires a
non-standard mkspec to be used.

Change-Id: I6171790805743251a7867111faa46bd4d4cc890d
Reviewed-on: http://codereview.qt.nokia.com/314
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
src/plugins/qt4projectmanager/qmakestep.cpp
src/plugins/qt4projectmanager/qmakestep.h
src/plugins/qt4projectmanager/qt4buildconfiguration.cpp

index b211aa1..67ac732 100644 (file)
@@ -121,7 +121,6 @@ Qt4BuildConfiguration *QMakeStep::qt4BuildConfiguration() const
 /// user arguments
 QString QMakeStep::allArguments(bool shorted)
 {
-    QString additonalArguments = m_userArgs;
     Qt4BuildConfiguration *bc = qt4BuildConfiguration();
     QStringList arguments;
     if (bc->subNodeBuild())
@@ -131,24 +130,19 @@ QString QMakeStep::allArguments(bool shorted)
                 buildConfiguration()->target()->project()->file()->fileName()).fileName());
     else
         arguments << QDir::toNativeSeparators(buildConfiguration()->target()->project()->file()->fileName());
-    arguments << "-r";
 
-    bool haveSpec = false;
-    for (Utils::QtcProcess::ArgIterator ait(&additonalArguments); ait.next(); )
-        if (ait.value() == QLatin1String("-spec"))
-            haveSpec = true;
-
-    if (!haveSpec) {
-        const QString tcSpec = bc->toolChain() ? bc->toolChain()->mkspec() : QString();
-        if (tcSpec.isEmpty()) {
-            if (bc->qtVersion())
-                arguments << "-spec" << bc->qtVersion()->mkspec();
-        } else if (!bc->qtVersion() || bc->qtVersion()->hasMkspec(tcSpec)) {
-            arguments << "-spec" << tcSpec;
-        } else {
-            arguments << "-spec" << bc->qtVersion()->mkspec();
+    arguments << "-r";
+    bool userProvidedMkspec = false;
+    for (Utils::QtcProcess::ConstArgIterator ait(&m_userArgs); ait.next(); ) {
+        if (ait.value() == QLatin1String("-spec")) {
+            if (ait.next()) {
+                userProvidedMkspec = true;
+                break;
+            }
         }
     }
+    if (!userProvidedMkspec)
+        arguments << "-spec" << mkspec();
 
     // Find out what flags we pass on to qmake
     arguments << bc->configCommandLineArguments();
@@ -156,7 +150,7 @@ QString QMakeStep::allArguments(bool shorted)
     arguments << moreArguments();
 
     QString args = Utils::QtcProcess::joinArgs(arguments);
-    Utils::QtcProcess::addArgs(&args, additonalArguments);
+    Utils::QtcProcess::addArgs(&args, m_userArgs);
     return args;
 }
 
@@ -434,6 +428,25 @@ QString QMakeStep::userArguments()
     return m_userArgs;
 }
 
+QString QMakeStep::mkspec()
+{
+    Qt4BuildConfiguration *bc = qt4BuildConfiguration();
+    QString additionalArguments = m_userArgs;
+    for (Utils::QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) {
+        if (ait.value() == QLatin1String("-spec")) {
+            if (ait.next())
+                return ait.value();
+        }
+    }
+
+    const QString tcSpec = bc->toolChain() ? bc->toolChain()->mkspec() : QString();
+    if (!bc->qtVersion())
+        return tcSpec;
+    if (!tcSpec.isEmpty() && bc->qtVersion()->hasMkspec(tcSpec))
+        return tcSpec;
+    return bc->qtVersion()->mkspec();
+}
+
 QVariantMap QMakeStep::toMap() const
 {
     QVariantMap map(AbstractProcessStep::toMap());
index cdb0231..2dfd631 100644 (file)
@@ -103,6 +103,7 @@ public:
     QStringList moreArguments();
     QStringList parserArguments();
     QString userArguments();
+    QString mkspec();
     void setUserArguments(const QString &arguments);
     bool linkQmlDebuggingLibrary() const;
     void setLinkQmlDebuggingLibrary(bool enable);
index b73d93d..466586b 100644 (file)
@@ -46,6 +46,7 @@
 #include <projectexplorer/buildsteplist.h>
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/toolchain.h>
+#include <projectexplorer/toolchainmanager.h>
 #include <qtsupport/qtversionfactory.h>
 #include <qtsupport/baseqtversion.h>
 
@@ -475,14 +476,8 @@ bool Qt4BuildConfiguration::compareToImportFrom(const QString &makefile)
                 // we have to compare without the spec/platform cmd argument
                 // and compare that on its own
                 QString workingDirectory = QFileInfo(makefile).absolutePath();
-                QString userArgs = qs->userArguments();
-                QStringList actualArgs;
-                QString actualSpec = extractSpecFromArguments(&userArgs, workingDirectory, version, &actualArgs);
-                if (actualSpec.isEmpty()) {
-                    // Easy one: the user has chosen not to override the settings
-                    actualSpec = version->mkspec();
-                }
-                actualArgs += qs->moreArguments();
+                QStringList actualArgs = qs->moreArguments();
+                QString actualSpec = qs->mkspec();
 
                 QString qmakeArgs = result.second;
                 QStringList parsedArgs;
@@ -830,23 +825,19 @@ void Qt4BuildConfiguration::importFromBuildDirectory()
                     QtSupport::QtVersionManager::scanMakeFile(mkfile, version->defaultBuildConfig());
             QtSupport::BaseQtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first;
 
-            QString aa = result.second;
-            QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArguments(&aa, directory, version);
-            QString versionSpec = version->mkspec();
-            QString additionalArguments;
-            if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
-                // using the default spec, don't modify additional arguments
-            } else {
-                additionalArguments = "-spec " + Utils::QtcProcess::quoteArg(parsedSpec);
-            }
-            Utils::QtcProcess::addArgs(&additionalArguments, aa);
-
+            QString additionalArguments = result.second;
+            QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArguments(&additionalArguments, directory, version);
             Qt4BuildConfiguration::removeQMLInspectorFromArguments(&additionalArguments);
 
             // So we got all the information now apply it...
             setQtVersion(version);
 
-            qmakeStep()->setUserArguments(additionalArguments);
+            QMakeStep *qs = qmakeStep();
+            qs->setUserArguments(additionalArguments);
+            if (!parsedSpec.isEmpty() && parsedSpec != QLatin1String("default") && qs->mkspec() != parsedSpec) {
+                Utils::QtcProcess::addArgs(&additionalArguments, (QStringList() << "-spec" << parsedSpec));
+                qs->setUserArguments(additionalArguments);
+            }
 
             setQMakeBuildConfiguration(qmakeBuildConfig);
             // Adjust command line arguments, this is ugly as hell