From ccc9685cc1fb61242f179a02661730140b026253 Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Wed, 11 Sep 2019 18:05:06 +0200 Subject: Genex: Move genex expansion of paths into AppendPaths utility Refactored internals of cmCustomCommandGenerator to make processing of path lists (evaluation of generator expressions and expansion into a list) available as AppendPaths utility function to be used for byproduct generator expression support. --- Source/cmCustomCommandGenerator.cxx | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'Source/cmCustomCommandGenerator.cxx') diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 2c0cbfdf2a..d5d70412e3 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -17,6 +17,26 @@ #include #include +namespace { +void AppendPaths(const std::vector& inputs, + cmGeneratorExpression& ge, cmLocalGenerator* lg, + std::string const& config, std::vector& output) +{ + for (std::string const& in : inputs) { + std::unique_ptr cge = ge.Parse(in); + std::vector result = + cmExpandedList(cge->Evaluate(lg, config)); + for (std::string& it : result) { + cmSystemTools::ConvertToUnixSlashes(it); + if (cmSystemTools::FileIsFullPath(it)) { + it = cmSystemTools::CollapseFullPath(it); + } + } + cmAppend(output, result); + } +} +} + cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg) @@ -46,25 +66,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, // lists on an empty command may have left this empty. // FIXME: Should we define behavior for removing empty commands? if (argv.empty()) { - argv.push_back(std::string()); + argv.emplace_back(); } this->CommandLines.push_back(std::move(argv)); } - std::vector depends = this->CC.GetDepends(); - for (std::string const& d : depends) { - std::unique_ptr cge = this->GE->Parse(d); - std::vector result = - cmExpandedList(cge->Evaluate(this->LG, this->Config)); - for (std::string& it : result) { - cmSystemTools::ConvertToUnixSlashes(it); - if (cmSystemTools::FileIsFullPath(it)) { - it = cmSystemTools::CollapseFullPath(it); - } - } - cmAppend(this->Depends, result); - } + AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config, + this->Depends); const std::string& workingdirectory = this->CC.GetWorkingDirectory(); if (!workingdirectory.empty()) { -- cgit v1.2.1