Browse Source

cmLocalGenerator: Factor out helper to expand custom command output paths

Brad King 5 years ago
parent
commit
947ba01bf9
3 changed files with 15 additions and 5 deletions
  1. 1 5
      Source/cmCustomCommandGenerator.cxx
  2. 10 0
      Source/cmLocalGenerator.cxx
  3. 4 0
      Source/cmLocalGenerator.h

+ 1 - 5
Source/cmCustomCommandGenerator.cxx

@@ -53,11 +53,7 @@ std::vector<std::string> EvaluateOutputs(std::vector<std::string> const& paths,
   std::vector<std::string> outputs;
   for (std::string const& p : paths) {
     std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(p);
-    std::string const& ep = cge->Evaluate(lg, config);
-    cm::append(outputs, cmExpandedList(ep));
-  }
-  for (std::string& p : outputs) {
-    p = cmSystemTools::CollapseFullPath(p, lg->GetCurrentBinaryDirectory());
+    cm::append(outputs, lg->ExpandCustomCommandOutputPaths(*cge, config));
   }
   return outputs;
 }

+ 10 - 0
Source/cmLocalGenerator.cxx

@@ -4169,6 +4169,16 @@ cmSourceFile* cmLocalGenerator::GetSourceFileWithOutput(
   return nullptr;
 }
 
+std::vector<std::string> cmLocalGenerator::ExpandCustomCommandOutputPaths(
+  cmCompiledGeneratorExpression const& cge, std::string const& config)
+{
+  std::vector<std::string> paths = cmExpandedList(cge.Evaluate(this, config));
+  for (std::string& p : paths) {
+    p = cmSystemTools::CollapseFullPath(p, this->GetCurrentBinaryDirectory());
+  }
+  return paths;
+}
+
 void cmLocalGenerator::AddTargetByproducts(
   cmTarget* target, const std::vector<std::string>& byproducts)
 {

+ 4 - 0
Source/cmLocalGenerator.h

@@ -22,6 +22,7 @@
 #include "cmProperty.h"
 #include "cmStateSnapshot.h"
 
+class cmCompiledGeneratorExpression;
 class cmComputeLinkInformation;
 class cmCustomCommandGenerator;
 class cmCustomCommandLines;
@@ -362,6 +363,9 @@ public:
     bool command_expand_lists = false, const std::string& job_pool = "",
     bool stdPipesUTF8 = false);
 
+  std::vector<std::string> ExpandCustomCommandOutputPaths(
+    cmCompiledGeneratorExpression const& cge, std::string const& config);
+
   /**
    * Add target byproducts.
    */