forked from qt-creator/qt-creator
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 <tobias.hunger@qt.io>
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user