From c79d290ca2722758617b76c3f6c66c7464e6d49c Mon Sep 17 00:00:00 2001 From: Andreas Pakulat Date: Tue, 20 Dec 2016 16:42:01 +0100 Subject: [PATCH] Expand macros in generic projects configuration files This adds the ability to use macro's provided by various parts of QtCreator inside the .includes or .files file. In particular the build directory of the current build configuration or Qt variables of the current kit (accessible through the active target's macro expander) can be useful but I suspect its possible to find other use-cases as well. Fall back to the project's own macro expander if there's no active build target to allow this to happen some day, even if that expander does not have many useful variables. Change-Id: Ic3b7b744b5d0ae24247ad929b73d7c72abfb8bb3 Reviewed-by: Tobias Hunger --- src/plugins/genericprojectmanager/genericproject.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index 06fa9813a0a..b0e12679bfc 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -301,8 +301,16 @@ QStringList GenericProject::processEntries(const QStringList &paths, { const BuildConfiguration *const buildConfig = activeTarget() ? activeTarget()->activeBuildConfiguration() : nullptr; + const Utils::Environment buildEnv = buildConfig ? buildConfig->environment() : Utils::Environment::systemEnvironment(); + + const Utils::MacroExpander *expander = macroExpander(); + if (buildConfig) + expander = buildConfig->macroExpander(); + else if (activeTarget()) + expander = activeTarget()->macroExpander(); + const QDir projectDir(projectDirectory().toString()); QFileInfo fileInfo; @@ -313,6 +321,7 @@ QStringList GenericProject::processEntries(const QStringList &paths, continue; trimmedPath = buildEnv.expandVariables(trimmedPath); + trimmedPath = expander->expand(trimmedPath); trimmedPath = Utils::FileName::fromUserInput(trimmedPath).toString();