diff options
author | Gabor Bencze <b.gabor98@gmail.com> | 2019-08-21 17:53:29 (GMT) |
---|---|---|
committer | Gabor Bencze <b.gabor98@gmail.com> | 2019-08-25 12:29:25 (GMT) |
commit | 524d72151449acf5d76e55172174552b83a74f61 (patch) | |
tree | 2e0eb4cdb54690fe731451b5d3715443bc3eb841 | |
parent | 2a1be178de5f12d55ec486609f4512e6b2b9d168 (diff) | |
download | CMake-524d72151449acf5d76e55172174552b83a74f61.zip CMake-524d72151449acf5d76e55172174552b83a74f61.tar.gz CMake-524d72151449acf5d76e55172174552b83a74f61.tar.bz2 |
cmCommand refactor: cmUseMangledMesaCommand
-rw-r--r-- | Source/cmCommands.cxx | 3 | ||||
-rw-r--r-- | Source/cmUseMangledMesaCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmUseMangledMesaCommand.h | 20 |
3 files changed, 17 insertions, 28 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index ead16d2..6cb7d80 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -208,8 +208,7 @@ void GetScriptingCommands(cmState* state) "build_name", cmBuildNameCommand, cmPolicies::CMP0036, "The build_name command should not be called; see CMP0036."); state->AddDisallowedCommand( - "use_mangled_mesa", cm::make_unique<cmUseMangledMesaCommand>(), - cmPolicies::CMP0030, + "use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030, "The use_mangled_mesa command should not be called; see CMP0030."); #endif diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 3d83760..cfc00e8 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -5,26 +5,30 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" +#include "cmExecutionStatus.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; +namespace { +void CopyAndFullPathMesaHeader(const std::string& source, + const std::string& outdir); +} -bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmUseMangledMesaCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) { // expected two arguments: // argument one: the full path to gl_mangle.h // argument two : directory for output of edited headers if (args.size() != 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } const std::string& inputDir = args[0]; std::string glh = cmStrCat(inputDir, "/gl.h"); if (!cmSystemTools::FileExists(glh)) { std::string e = cmStrCat("Bad path to Mesa, could not find: ", glh, ' '); - this->SetError(e); + status.SetError(e); return false; } const std::string& destDir = args[1]; @@ -37,14 +41,15 @@ bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args, cmSystemTools::MakeDirectory(destDir); for (std::string const& f : files) { std::string path = cmStrCat(inputDir, '/', f); - this->CopyAndFullPathMesaHeader(path, destDir); + CopyAndFullPathMesaHeader(path, destDir); } return true; } -void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader( - const std::string& source, const std::string& outdir) +namespace { +void CopyAndFullPathMesaHeader(const std::string& source, + const std::string& outdir) { std::string dir; std::string file; @@ -96,3 +101,4 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader( cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile); cmSystemTools::RemoveFile(tempOutputFile); } +} diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index 1c01596..215e4a3 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -8,25 +8,9 @@ #include <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmUseMangledMesaCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmUseMangledMesaCommand>(); - } - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - -protected: - void CopyAndFullPathMesaHeader(const std::string& source, - const std::string& outdir); -}; +bool cmUseMangledMesaCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif |