aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-06-08 14:17:46 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-06-09 12:16:46 +0000
commit3b92dff5cc8eb57dc1cfd13aa81c9be763d646ef (patch)
tree056c689054fdfa13f77bb41c038da247a3dbde9f /src/lib/corelib
parent7343f24c774af89e7ddf9cf24c3932c703b5937c (diff)
Use stored profile contents when re-resolving implicitly
As per our policy to take as much data as possible from an existing build graph. We can now do incremental builds on a project whose original profile is no longer available. This will enable us to import projects built on the command line into Qt Creator, for instance. Change-Id: I0498628c0c6d9a2f049f4769152685d392640bcf Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/buildgraph/buildgraphloader.cpp25
-rw-r--r--src/lib/corelib/language/loader.cpp6
-rw-r--r--src/lib/corelib/language/loader.h2
-rwxr-xr-xsrc/lib/corelib/language/moduleloader.cpp11
-rw-r--r--src/lib/corelib/language/moduleloader.h2
-rw-r--r--src/lib/corelib/tools/preferences.cpp15
-rw-r--r--src/lib/corelib/tools/preferences.h2
7 files changed, 43 insertions, 20 deletions
diff --git a/src/lib/corelib/buildgraph/buildgraphloader.cpp b/src/lib/corelib/buildgraph/buildgraphloader.cpp
index 7bce03ba0..1120cea98 100644
--- a/src/lib/corelib/buildgraph/buildgraphloader.cpp
+++ b/src/lib/corelib/buildgraph/buildgraphloader.cpp
@@ -274,6 +274,8 @@ void BuildGraphLoader::trackProjectChanges()
for (const auto &restoredProduct : qAsConst(allRestoredProducts))
restoredProbes.insert(restoredProduct->uniqueName(), restoredProduct->probes);
ldr.setOldProductProbes(restoredProbes);
+ if (!m_parameters.overrideBuildGraphData())
+ ldr.setStoredProfiles(restoredProject->profileConfigs);
m_result.newlyResolvedProject = ldr.loadProject(m_parameters);
QMap<QString, ResolvedProductPtr> freshProductsByName;
@@ -915,29 +917,18 @@ bool BuildGraphLoader::checkConfigCompatibility()
m_parameters.setTopLevelProfile(restoredProject->profile());
m_parameters.expandBuildConfiguration();
}
- if (m_parameters.finalBuildConfigurationTree() != restoredProject->buildConfiguration()) {
- if (m_parameters.overrideBuildGraphData())
- return false;
- throw ErrorInfo(Tr::tr("The current set of properties for configuration '%1' differs "
- "from the one used in the last build. Use the 'resolve' "
- "command if you really want to rebuild with the new properties.")
- .arg(m_parameters.configurationName()));
- }
+ if (!m_parameters.overrideBuildGraphData())
+ return true;
+ if (m_parameters.finalBuildConfigurationTree() != restoredProject->buildConfiguration())
+ return false;
for (QVariantMap::ConstIterator it = restoredProject->profileConfigs.constBegin();
it != restoredProject->profileConfigs.constEnd(); ++it) {
const QVariantMap buildConfig = SetupProjectParameters::expandedBuildConfiguration(
m_parameters.settingsDirectory(), it.key(), m_parameters.configurationName());
const QVariantMap newConfig = SetupProjectParameters::finalBuildConfigurationTree(
buildConfig, m_parameters.overriddenValues());
- if (newConfig != it.value()) {
- if (m_parameters.overrideBuildGraphData())
- return false;
- throw ErrorInfo(Tr::tr("The current set of properties for configuration '%1' differs "
- "in profile '%2' from the one used for the last build. "
- "Use the 'resolve' command if you really want to rebuild "
- "with the new properties.")
- .arg(m_parameters.configurationName(), it.key()));
- }
+ if (newConfig != it.value())
+ return false;
}
return true;
}
diff --git a/src/lib/corelib/language/loader.cpp b/src/lib/corelib/language/loader.cpp
index efd4d2081..821def454 100644
--- a/src/lib/corelib/language/loader.cpp
+++ b/src/lib/corelib/language/loader.cpp
@@ -98,6 +98,11 @@ void Loader::setOldProductProbes(const QHash<QString, QList<ProbeConstPtr>> &old
m_oldProductProbes = oldProbes;
}
+void Loader::setStoredProfiles(const QVariantMap &profiles)
+{
+ m_storedProfiles = profiles;
+}
+
TopLevelProjectPtr Loader::loadProject(const SetupProjectParameters &_parameters)
{
QBS_CHECK(QFileInfo(_parameters.projectFilePath()).isAbsolute());
@@ -147,6 +152,7 @@ TopLevelProjectPtr Loader::loadProject(const SetupProjectParameters &_parameters
moduleLoader.setSearchPaths(m_searchPaths);
moduleLoader.setOldProjectProbes(m_oldProjectProbes);
moduleLoader.setOldProductProbes(m_oldProductProbes);
+ moduleLoader.setStoredProfiles(m_storedProfiles);
const ModuleLoaderResult loadResult = moduleLoader.load(parameters);
ProjectResolver resolver(&evaluator, loadResult, parameters, m_logger);
resolver.setProgressObserver(m_progressObserver);
diff --git a/src/lib/corelib/language/loader.h b/src/lib/corelib/language/loader.h
index 82183c453..f923f1700 100644
--- a/src/lib/corelib/language/loader.h
+++ b/src/lib/corelib/language/loader.h
@@ -61,6 +61,7 @@ public:
void setSearchPaths(const QStringList &searchPaths);
void setOldProjectProbes(const QList<ProbeConstPtr> &oldProbes);
void setOldProductProbes(const QHash<QString, QList<ProbeConstPtr>> &oldProbes);
+ void setStoredProfiles(const QVariantMap &profiles);
TopLevelProjectPtr loadProject(const SetupProjectParameters &parameters);
private:
@@ -70,6 +71,7 @@ private:
QStringList m_searchPaths;
QList<ProbeConstPtr> m_oldProjectProbes;
QHash<QString, QList<ProbeConstPtr>> m_oldProductProbes;
+ QVariantMap m_storedProfiles;
};
} // namespace Internal
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index c14d9cebb..40417bad6 100755
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -304,6 +304,11 @@ void ModuleLoader::setOldProductProbes(const QHash<QString, QList<ProbeConstPtr>
m_oldProductProbes = oldProbes;
}
+void ModuleLoader::setStoredProfiles(const QVariantMap &profiles)
+{
+ m_storedProfiles = profiles;
+}
+
ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters &parameters)
{
TimedActivityLogger moduleLoaderTimer(m_logger, Tr::tr("ModuleLoader"),
@@ -342,6 +347,7 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters &parameters)
}
ModuleLoaderResult result;
+ result.profileConfigs = m_storedProfiles;
m_pool = result.itemPool.get();
m_reader->setPool(m_pool);
@@ -977,8 +983,9 @@ void ModuleLoader::setupProductDependencies(ProductContext *productContext)
QStringList extraSearchPaths = readExtraSearchPaths(item);
Settings settings(m_parameters.settingsDirectory());
- const QStringList prefsSearchPaths
- = Preferences(&settings, productContext->profileName).searchPaths();
+ const QVariantMap profileContents = productContext->project->result->profileConfigs
+ .value(productContext->profileName).toMap();
+ const QStringList prefsSearchPaths = Preferences(&settings, profileContents).searchPaths();
for (const QString &p : prefsSearchPaths) {
if (!m_moduleSearchPaths.contains(p) && FileInfo(p).exists())
extraSearchPaths << p;
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 90551818b..0e9445f1c 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -123,6 +123,7 @@ public:
void setSearchPaths(const QStringList &searchPaths);
void setOldProjectProbes(const QList<ProbeConstPtr> &oldProbes);
void setOldProductProbes(const QHash<QString, QList<ProbeConstPtr>> &oldProbes);
+ void setStoredProfiles(const QVariantMap &profiles);
Evaluator *evaluator() const { return m_evaluator; }
ModuleLoaderResult load(const SetupProjectParameters &parameters);
@@ -339,6 +340,7 @@ private:
QHash<QString, QList<ProbeConstPtr>> m_oldProjectProbes;
QHash<QString, QList<ProbeConstPtr>> m_oldProductProbes;
QHash<CodeLocation, QList<ProbeConstPtr>> m_currentProbes;
+ QVariantMap m_storedProfiles;
std::multimap<QString, const ProductContext *> m_productsByName;
SetupProjectParameters m_parameters;
Version m_qbsVersion;
diff --git a/src/lib/corelib/tools/preferences.cpp b/src/lib/corelib/tools/preferences.cpp
index a21dbdaf4..2516cd960 100644
--- a/src/lib/corelib/tools/preferences.cpp
+++ b/src/lib/corelib/tools/preferences.cpp
@@ -56,6 +56,11 @@ Preferences::Preferences(Settings *settings, const QString &profileName)
{
}
+Preferences::Preferences(Settings *settings, const QVariantMap &profileContents)
+ : m_settings(settings), m_profileContents(profileContents)
+{
+}
+
/*!
* \brief Returns true <=> colored output should be used for printing messages.
@@ -120,7 +125,8 @@ QStringList Preferences::pluginPaths(const QString &baseDir) const
QVariant Preferences::getPreference(const QString &key, const QVariant &defaultValue) const
{
- const QString fullKey = QLatin1String("preferences.") + key;
+ static const QString keyPrefix = QLatin1String("preferences");
+ const QString fullKey = keyPrefix + QLatin1Char('.') + key;
if (!m_profile.isEmpty()) {
QVariant value = Profile(m_profile, m_settings).value(fullKey);
if (value.isValid()) {
@@ -130,6 +136,13 @@ QVariant Preferences::getPreference(const QString &key, const QVariant &defaultV
}
}
+ QVariant value = m_profileContents.value(keyPrefix).toMap().value(key);
+ if (value.isValid()) {
+ if (key == QLatin1String("qbsSearchPaths")) // Merge with top-level value
+ value = value.toStringList() + m_settings->value(fullKey).toStringList();
+ return value;
+ }
+
return m_settings->value(fullKey, defaultValue);
}
diff --git a/src/lib/corelib/tools/preferences.h b/src/lib/corelib/tools/preferences.h
index 042a15a9e..98468b78c 100644
--- a/src/lib/corelib/tools/preferences.h
+++ b/src/lib/corelib/tools/preferences.h
@@ -53,6 +53,7 @@ class QBS_EXPORT Preferences
{
public:
explicit Preferences(Settings *settings, const QString &profileName = QString());
+ Preferences(Settings *settings, const QVariantMap &profileContents);
bool useColoredOutput() const;
int jobs() const;
@@ -68,6 +69,7 @@ private:
Settings *m_settings;
QString m_profile;
+ QVariantMap m_profileContents;
};
} // namespace qbs