Browse Source

cmSetSourceFilesPropertiesCommand: Port away from cmCommand

Ref: #19499
Regina Pfeifer 6 years ago
parent
commit
95f23ea5d5

+ 2 - 3
Source/cmCommands.cxx

@@ -241,9 +241,8 @@ void GetProjectCommands(cmState* state)
   state->AddBuiltinCommand("link_directories",
                            cm::make_unique<cmLinkDirectoriesCommand>());
   state->AddBuiltinCommand("project", cm::make_unique<cmProjectCommand>());
-  state->AddBuiltinCommand(
-    "set_source_files_properties",
-    cm::make_unique<cmSetSourceFilesPropertiesCommand>());
+  state->AddBuiltinCommand("set_source_files_properties",
+                           cmSetSourceFilesPropertiesCommand);
   state->AddBuiltinCommand("set_target_properties",
                            cm::make_unique<cmSetTargetPropertiesCommand>());
   state->AddBuiltinCommand("set_tests_properties",

+ 21 - 14
Source/cmSetSourceFilesPropertiesCommand.cxx

@@ -2,18 +2,23 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmSetSourceFilesPropertiesCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmStringAlgorithms.h"
 
-class cmExecutionStatus;
+static bool RunCommand(cmMakefile* mf,
+                       std::vector<std::string>::const_iterator filebeg,
+                       std::vector<std::string>::const_iterator fileend,
+                       std::vector<std::string>::const_iterator propbeg,
+                       std::vector<std::string>::const_iterator propend,
+                       std::string& errors);
 
-// cmSetSourceFilesPropertiesCommand
-bool cmSetSourceFilesPropertiesCommand::InitialPass(
-  std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+                                       cmExecutionStatus& status)
 {
   if (args.size() < 2) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
 
@@ -29,22 +34,24 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass(
     ++j;
   }
 
+  cmMakefile& mf = status.GetMakefile();
+
   // now call the worker function
   std::string errors;
-  bool ret = cmSetSourceFilesPropertiesCommand::RunCommand(
-    this->Makefile, args.begin(), args.begin() + numFiles,
-    args.begin() + numFiles, args.end(), errors);
+  bool ret = RunCommand(&mf, args.begin(), args.begin() + numFiles,
+                        args.begin() + numFiles, args.end(), errors);
   if (!ret) {
-    this->SetError(errors);
+    status.SetError(errors);
   }
   return ret;
 }
 
-bool cmSetSourceFilesPropertiesCommand::RunCommand(
-  cmMakefile* mf, std::vector<std::string>::const_iterator filebeg,
-  std::vector<std::string>::const_iterator fileend,
-  std::vector<std::string>::const_iterator propbeg,
-  std::vector<std::string>::const_iterator propend, std::string& errors)
+static bool RunCommand(cmMakefile* mf,
+                       std::vector<std::string>::const_iterator filebeg,
+                       std::vector<std::string>::const_iterator fileend,
+                       std::vector<std::string>::const_iterator propbeg,
+                       std::vector<std::string>::const_iterator propend,
+                       std::string& errors)
 {
   std::vector<std::string> propertyPairs;
   bool generated = false;

+ 2 - 27
Source/cmSetSourceFilesPropertiesCommand.h

@@ -8,34 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetSourceFilesPropertiesCommand : public cmCommand
-{
-public:
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmSetSourceFilesPropertiesCommand>();
-  }
-
-  /**
-   * This is called when the command is first encountered in
-   * the input file.
-   */
-  bool InitialPass(std::vector<std::string> const& args,
-                   cmExecutionStatus& status) override;
 
-  static bool RunCommand(cmMakefile* mf,
-                         std::vector<std::string>::const_iterator filebeg,
-                         std::vector<std::string>::const_iterator fileend,
-                         std::vector<std::string>::const_iterator propbeg,
-                         std::vector<std::string>::const_iterator propend,
-                         std::string& errors);
-};
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+                                       cmExecutionStatus& status);
 
 #endif