aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-08-26 14:04:19 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-09-02 10:43:29 +0200
commitdbf0300991118a834c80571a8b998dcd113084e9 (patch)
tree649d50e6c6bbcf1d4a9e61aefeda3ac498317b51 /src/lib/corelib/language
parent5576026286baac2d9032ccaa7a1a326bacc89fdc (diff)
Evaluate Project.minimumQbsVersion earlier.
Currently, this property is evaluated after checking the module properties and item types, so it cannot fulfill its purpose at all. Change-Id: I6b84d9af69e1c0147f87eb0fead4409dbb036d5c Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/corelib/language')
-rw-r--r--src/lib/corelib/language/moduleloader.cpp32
-rw-r--r--src/lib/corelib/language/moduleloader.h4
-rw-r--r--src/lib/corelib/language/projectresolver.cpp32
-rw-r--r--src/lib/corelib/language/projectresolver.h3
-rw-r--r--src/lib/corelib/language/testdata/erroneous/oldQbsVersion.qbs3
-rw-r--r--src/lib/corelib/language/tst_language.cpp2
6 files changed, 40 insertions, 36 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 52f1978d3..8aa1bd7b4 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -233,6 +233,23 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, Item *item,
projectContext.scope->setFile(item->file());
projectContext.scope->setProperty(QLatin1String("project"), itemValue);
+ const QString minVersionStr
+ = m_evaluator->stringValue(item, QLatin1String("minimumQbsVersion"),
+ QLatin1String("1.3.0"));
+ bool ok;
+ const Version minVersion = qbsVersionFromString(minVersionStr, &ok);
+ if (!ok) {
+ throw ErrorInfo(Tr::tr("The value '%1' of Project.minimumQbsVersion "
+ "is not a valid version string.").arg(minVersionStr), item->location());
+ }
+ if (!m_qbsVersion.isValid())
+ m_qbsVersion = qbsVersionFromString(QLatin1String(QBS_VERSION));
+ if (m_qbsVersion < minVersion) {
+ throw ErrorInfo(Tr::tr("The project requires at least qbs version %1, but "
+ "this is qbs version %2.").arg(minVersion.toString(),
+ m_qbsVersion.toString()));
+ }
+
foreach (Item *child, item->children()) {
child->setScope(projectContext.scope);
if (child->typeName() == QLatin1String("Product")) {
@@ -1227,6 +1244,21 @@ QString ModuleLoader::fullModuleName(const QStringList &moduleName)
#endif
}
+Version ModuleLoader::qbsVersionFromString(const QString &str, bool *ok)
+{
+ if (ok)
+ *ok = true;
+ QRegExp rex(QLatin1String("(\\d+)\\.(\\d+)(?:\\.(\\d+))?"));
+ if (rex.exactMatch(str)) {
+ const QString cap3 = rex.cap(3);
+ return Version(rex.cap(1).toInt(), rex.cap(2).toInt(),
+ cap3.isEmpty() ? 0 : cap3.toInt());
+ }
+ if (ok)
+ *ok = false;
+ return Version();
+}
+
void ModuleLoader::overrideItemProperties(Item *item, const QString &buildConfigKey,
const QVariantMap &buildConfig)
{
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 07e0ab24f..f2e500b56 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -34,6 +34,7 @@
#include "itempool.h"
#include <logging/logger.h>
#include <tools/setupprojectparameters.h>
+#include <tools/version.h>
#include <QMap>
#include <QSet>
@@ -202,6 +203,8 @@ private:
static void overrideItemProperties(Item *item, const QString &buildConfigKey,
const QVariantMap &buildConfig);
+ static Version qbsVersionFromString(const QString &str, bool *ok = 0);
+
ScriptEngine *m_engine;
ItemPool *m_pool;
Logger m_logger;
@@ -214,6 +217,7 @@ private:
QHash<Item *, QSet<QString> > m_validItemPropertyNamesPerItem;
QSet<Item *> m_disabledItems;
SetupProjectParameters m_parameters;
+ Version m_qbsVersion;
};
} // namespace Internal
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index c96847e26..f95eb9075 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -219,23 +219,6 @@ void ProjectResolver::resolveProject(Item *item, ProjectContext *projectContext)
return;
}
- const QString minVersionStr
- = m_evaluator->stringValue(item, QLatin1String("minimumQbsVersion"),
- QLatin1String("1.3.0"));
- bool ok;
- const Version minVersion = qbsVersionFromString(minVersionStr, &ok);
- if (!ok) {
- throw ErrorInfo(Tr::tr("The value of Project.minimumQbsVersion "
- "is not a valid version string."));
- }
- if (!m_qbsVersion.isValid())
- m_qbsVersion = qbsVersionFromString(QLatin1String(QBS_VERSION));
- if (m_qbsVersion < minVersion) {
- throw ErrorInfo(Tr::tr("The project requires at least qbs version %1, but "
- "this is qbs version %2.").arg(minVersion.toString(),
- m_qbsVersion.toString()));
- }
-
projectContext->dummyModule = ResolvedModule::create();
for (Item::PropertyDeclarationMap::const_iterator it
@@ -1140,20 +1123,5 @@ ProjectResolver::ProjectContext ProjectResolver::createProjectContext(ProjectCon
return subProjectContext;
}
-Version ProjectResolver::qbsVersionFromString(const QString &str, bool *ok)
-{
- if (ok)
- *ok = true;
- QRegExp rex(QLatin1String("(\\d+)\\.(\\d+)(?:\\.(\\d+))?"));
- if (rex.exactMatch(str)) {
- const QString cap3 = rex.cap(3);
- return Version(rex.cap(1).toInt(), rex.cap(2).toInt(),
- cap3.isEmpty() ? 0 : cap3.toInt());
- }
- if (ok)
- *ok = false;
- return Version();
-}
-
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/language/projectresolver.h b/src/lib/corelib/language/projectresolver.h
index 5bb711b15..2370288c4 100644
--- a/src/lib/corelib/language/projectresolver.h
+++ b/src/lib/corelib/language/projectresolver.h
@@ -35,7 +35,6 @@
#include "language.h"
#include <logging/logger.h>
#include <tools/setupprojectparameters.h>
-#include <tools/version.h>
#include <QMap>
#include <QSet>
@@ -127,14 +126,12 @@ private:
QString convertPathProperty(const QString &path, const QString &dirPath) const;
QStringList convertPathListProperty(const QStringList &paths, const QString &dirPath) const;
ProjectContext createProjectContext(ProjectContext *parentProjectContext) const;
- static Version qbsVersionFromString(const QString &str, bool *ok = 0);
Evaluator *m_evaluator;
const BuiltinDeclarations *m_builtins;
Logger m_logger;
ScriptEngine *m_engine;
ProgressObserver *m_progressObserver;
- Version m_qbsVersion;
ProductContext *m_productContext;
ModuleContext *m_moduleContext;
QMap<QString, ResolvedProductPtr> m_productsByName;
diff --git a/src/lib/corelib/language/testdata/erroneous/oldQbsVersion.qbs b/src/lib/corelib/language/testdata/erroneous/oldQbsVersion.qbs
index 9217c9410..fb0915d83 100644
--- a/src/lib/corelib/language/testdata/erroneous/oldQbsVersion.qbs
+++ b/src/lib/corelib/language/testdata/erroneous/oldQbsVersion.qbs
@@ -2,4 +2,7 @@ import qbs
Project {
minimumQbsVersion: "999.5.4"
+ Product {
+ qbs.enableSound: true
+ }
}
diff --git a/src/lib/corelib/language/tst_language.cpp b/src/lib/corelib/language/tst_language.cpp
index 7f32a1de8..d76006df4 100644
--- a/src/lib/corelib/language/tst_language.cpp
+++ b/src/lib/corelib/language/tst_language.cpp
@@ -379,7 +379,7 @@ void TestLanguage::erroneousFiles_data()
<< "The project requires at least qbs version \\d+\\.\\d+.\\d+, "
"but this is qbs version " QBS_VERSION ".";
QTest::newRow("wrongQbsVersionFormat")
- << "The value of Project.minimumQbsVersion is not a valid version string.";
+ << "The value '.*' of Project.minimumQbsVersion is not a valid version string.";
}
void TestLanguage::erroneousFiles()