forked from qt-creator/qt-creator
Qbs: Move environment cache from runconfiguration to project
Change-Id: I2a987e55cde133931bb4578506bb26666eece601 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -469,6 +469,7 @@ void QbsProject::updateAfterParse()
|
||||
updateCppCodeModel();
|
||||
updateQmlJsCodeModel();
|
||||
emit fileListChanged();
|
||||
m_envCache.clear();
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
@@ -652,6 +653,7 @@ void QbsProject::updateAfterBuild()
|
||||
m_extraCompilersPending = false;
|
||||
updateCppCodeModel();
|
||||
}
|
||||
m_envCache.clear();
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
@@ -1115,6 +1117,16 @@ void QbsProject::updateApplicationTargets()
|
||||
bti.runEnvModifier = [targetFile, productData, this](Utils::Environment &env, bool usingLibraryPaths) {
|
||||
if (!qbsProject().isValid())
|
||||
return;
|
||||
|
||||
const QString key = env.toStringList().join(QChar())
|
||||
+ QbsProject::uniqueProductName(productData)
|
||||
+ QString::number(usingLibraryPaths);
|
||||
const auto it = m_envCache.constFind(key);
|
||||
if (it != m_envCache.constEnd()) {
|
||||
env = it.value();
|
||||
return;
|
||||
}
|
||||
|
||||
QProcessEnvironment procEnv = env.toProcessEnvironment();
|
||||
procEnv.insert(QLatin1String("QBS_RUN_FILE_PATH"), targetFile);
|
||||
QStringList setupRunEnvConfig;
|
||||
@@ -1133,6 +1145,8 @@ void QbsProject::updateApplicationTargets()
|
||||
foreach (const QString &key, procEnv.keys())
|
||||
env.set(key, procEnv.value(key));
|
||||
}
|
||||
|
||||
m_envCache.insert(key, env);
|
||||
};
|
||||
|
||||
applications.append(bti);
|
||||
|
||||
@@ -164,6 +164,8 @@ private:
|
||||
QTimer m_parsingDelay;
|
||||
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
|
||||
bool m_extraCompilersPending = false;
|
||||
|
||||
QHash<QString, Utils::Environment> m_envCache;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -59,21 +59,9 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
|
||||
envAspect->addModifier([this](Environment &env) {
|
||||
bool usingLibraryPaths = aspect<UseLibraryPathsAspect>()->value();
|
||||
|
||||
const auto key = qMakePair(env.toStringList(), usingLibraryPaths);
|
||||
const auto it = m_envCache.constFind(key);
|
||||
if (it != m_envCache.constEnd()) {
|
||||
env = it.value();
|
||||
return;
|
||||
}
|
||||
BuildTargetInfo bti = buildTargetInfo();
|
||||
if (bti.runEnvModifier) {
|
||||
if (project()->isParsing() || BuildManager::isBuilding(this->target())) {
|
||||
qCDebug(qbsPmLog) << "qbs project in flux, cannot modify environment";
|
||||
return; // Intentionally skips the cache update below.
|
||||
}
|
||||
if (bti.runEnvModifier)
|
||||
bti.runEnvModifier(env, usingLibraryPaths);
|
||||
}
|
||||
m_envCache.insert(key, env);
|
||||
});
|
||||
|
||||
addAspect<ExecutableAspect>();
|
||||
@@ -108,7 +96,6 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id)
|
||||
this, &QbsRunConfiguration::updateTargetInformation);
|
||||
|
||||
auto qbsProject = static_cast<QbsProject *>(target->project());
|
||||
connect(qbsProject, &QbsProject::dataChanged, this, [this] { m_envCache.clear(); });
|
||||
connect(qbsProject, &Project::parsingFinished,
|
||||
this, &QbsRunConfiguration::updateTargetInformation);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ private:
|
||||
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &rci) final;
|
||||
|
||||
void updateTargetInformation();
|
||||
|
||||
using EnvCache = QHash<QPair<QStringList, bool>, Utils::Environment>;
|
||||
mutable EnvCache m_envCache;
|
||||
};
|
||||
|
||||
class QbsRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
||||
|
||||
Reference in New Issue
Block a user