diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-01-21 16:00:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-01-21 16:09:35 (GMT) |
commit | 5e54b0cf2f9706c731d9c188274ac2493587e86f (patch) | |
tree | 8f37f4b8df1271ae952b5ac0ad10773d07023f6f | |
parent | 7a89e3c36cf919bf7c608456bcfd5d12978dc037 (diff) | |
download | CMake-5e54b0cf2f9706c731d9c188274ac2493587e86f.zip CMake-5e54b0cf2f9706c731d9c188274ac2493587e86f.tar.gz CMake-5e54b0cf2f9706c731d9c188274ac2493587e86f.tar.bz2 |
cmInstallGenerator: std::string params
Several construction parameters converted to std::string
Also made a few class members const
-rw-r--r-- | Source/cmInstallCommand.cxx | 16 | ||||
-rw-r--r-- | Source/cmInstallDirectoryGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallDirectoryGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallFilesGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmInstallGenerator.h | 14 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmInstallSubdirectoryGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmScriptGenerator.h | 2 |
13 files changed, 44 insertions, 42 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 5088379..c67358f 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -196,14 +196,14 @@ bool HandleScriptMode(std::vector<std::string> const& args, return false; } helper.Makefile->AddInstallGenerator( - cm::make_unique<cmInstallScriptGenerator>( - script, false, component.c_str(), exclude_from_all)); + cm::make_unique<cmInstallScriptGenerator>(script, false, component, + exclude_from_all)); } else if (doing_code) { doing_code = false; std::string const& code = arg; helper.Makefile->AddInstallGenerator( - cm::make_unique<cmInstallScriptGenerator>( - code, true, component.c_str(), exclude_from_all)); + cm::make_unique<cmInstallScriptGenerator>(code, true, component, + exclude_from_all)); } } @@ -942,7 +942,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args, bool exclude_from_all = false; bool message_never = false; std::vector<std::string> dirs; - const char* destination = nullptr; + const std::string* destination = nullptr; std::string permissions_file; std::string permissions_dir; std::vector<std::string> configurations; @@ -1101,7 +1101,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args, } else if (doing == DoingConfigurations) { configurations.push_back(args[i]); } else if (doing == DoingDestination) { - destination = args[i].c_str(); + destination = &args[i]; doing = DoingNone; } else if (doing == DoingType) { if (allowedTypes.count(args[i]) == 0) { @@ -1187,7 +1187,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args, return false; } destinationStr = helper.GetDestinationForType(nullptr, type); - destination = destinationStr.c_str(); + destination = &destinationStr; } else if (!type.empty()) { status.SetError(cmStrCat(args[0], " given both TYPE and DESTINATION " @@ -1201,7 +1201,7 @@ bool HandleDirectoryMode(std::vector<std::string> const& args, // Create the directory install generator. helper.Makefile->AddInstallGenerator( cm::make_unique<cmInstallDirectoryGenerator>( - dirs, destination, permissions_file, permissions_dir, configurations, + dirs, *destination, permissions_file, permissions_dir, configurations, component, message, exclude_from_all, literal_args, optional)); // Tell the global generator about any installation component names diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 7e3148a..175e7cf 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -12,12 +12,12 @@ #include "cmSystemTools.h" cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( - std::vector<std::string> const& dirs, const char* dest, + std::vector<std::string> const& dirs, std::string const& dest, std::string file_permissions, std::string dir_permissions, std::vector<std::string> const& configurations, std::string const& component, MessageLevel message, bool exclude_from_all, std::string literal_args, bool optional) - : cmInstallGenerator(dest, configurations, component.c_str(), message, + : cmInstallGenerator(dest, configurations, component, message, exclude_from_all) , LocalGenerator(nullptr) , Directories(dirs) diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index e53e81c..bec89df 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -21,7 +21,8 @@ class cmInstallDirectoryGenerator : public cmInstallGenerator { public: cmInstallDirectoryGenerator(std::vector<std::string> const& dirs, - const char* dest, std::string file_permissions, + std::string const& dest, + std::string file_permissions, std::string dir_permissions, std::vector<std::string> const& configurations, std::string const& component, diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index ff32ef1..2c53a28 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -22,8 +22,8 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::string file_permissions, std::vector<std::string> const& configurations, std::string const& component, MessageLevel message, bool exclude_from_all, std::string filename, std::string name_space, bool exportOld, bool android) - : cmInstallGenerator(destination.c_str(), configurations, component.c_str(), - message, exclude_from_all) + : cmInstallGenerator(destination, configurations, component, message, + exclude_from_all) , ExportSet(exportSet) , FilePermissions(std::move(file_permissions)) , FileName(std::move(filename)) diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index e470ff8..ad2f84e 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -16,8 +16,8 @@ cmInstallFilesGenerator::cmInstallFilesGenerator( std::vector<std::string> const& configurations, std::string const& component, MessageLevel message, bool exclude_from_all, std::string rename, bool optional) - : cmInstallGenerator(dest.c_str(), configurations, component.c_str(), - message, exclude_from_all) + : cmInstallGenerator(dest, configurations, component, message, + exclude_from_all) , LocalGenerator(nullptr) , Files(files) , FilePermissions(std::move(file_permissions)) diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index ec17361..0665895 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -3,16 +3,17 @@ #include "cmInstallGenerator.h" #include <ostream> +#include <utility> #include "cmMakefile.h" #include "cmSystemTools.h" cmInstallGenerator::cmInstallGenerator( - const char* destination, std::vector<std::string> const& configurations, - const char* component, MessageLevel message, bool exclude_from_all) + std::string destination, std::vector<std::string> const& configurations, + std::string component, MessageLevel message, bool exclude_from_all) : cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations) - , Destination(destination ? destination : "") - , Component(component ? component : "") + , Destination(std::move(destination)) + , Component(std::move(component)) , Message(message) , ExcludeFromAll(exclude_from_all) { @@ -139,8 +140,8 @@ void cmInstallGenerator::AddInstallRule( os << ")\n"; } -std::string cmInstallGenerator::CreateComponentTest(const char* component, - bool exclude_from_all) +std::string cmInstallGenerator::CreateComponentTest( + const std::string& component, bool exclude_from_all) { std::string result = R"("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "x)"; result += component; @@ -158,7 +159,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = - this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll); + this->CreateComponentTest(this->Component, this->ExcludeFromAll); os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index 024027d..d786d24 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -30,9 +30,9 @@ public: MessageNever }; - cmInstallGenerator(const char* destination, + cmInstallGenerator(std::string destination, std::vector<std::string> const& configurations, - const char* component, MessageLevel message, + std::string component, MessageLevel message, bool exclude_from_all); ~cmInstallGenerator() override; @@ -65,14 +65,14 @@ public: protected: void GenerateScript(std::ostream& os) override; - std::string CreateComponentTest(const char* component, + std::string CreateComponentTest(const std::string& component, bool exclude_from_all); // Information shared by most generator types. - std::string Destination; - std::string Component; - MessageLevel Message; - bool ExcludeFromAll; + std::string const Destination; + std::string const Component; + MessageLevel const Message; + bool const ExcludeFromAll; }; #endif diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 77680d2..7cdf3b4 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -12,11 +12,10 @@ #include "cmPolicies.h" #include "cmScriptGenerator.h" -cmInstallScriptGenerator::cmInstallScriptGenerator(std::string script, - bool code, - const char* component, - bool exclude_from_all) - : cmInstallGenerator(nullptr, std::vector<std::string>(), component, +cmInstallScriptGenerator::cmInstallScriptGenerator( + std::string script, bool code, std::string const& component, + bool exclude_from_all) + : cmInstallGenerator("", std::vector<std::string>(), component, MessageDefault, exclude_from_all) , Script(std::move(script)) , Code(code) diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index d22c6ec..0a9c4ba 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -20,7 +20,8 @@ class cmInstallScriptGenerator : public cmInstallGenerator { public: cmInstallScriptGenerator(std::string script, bool code, - const char* component, bool exclude_from_all); + std::string const& component, + bool exclude_from_all); ~cmInstallScriptGenerator() override; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx index 8b45972..12bc92b 100644 --- a/Source/cmInstallSubdirectoryGenerator.cxx +++ b/Source/cmInstallSubdirectoryGenerator.cxx @@ -15,8 +15,8 @@ cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator( cmMakefile* makefile, std::string binaryDirectory, bool excludeFromAll) - : cmInstallGenerator(nullptr, std::vector<std::string>(), nullptr, - MessageDefault, excludeFromAll) + : cmInstallGenerator("", std::vector<std::string>(), "", MessageDefault, + excludeFromAll) , Makefile(makefile) , BinaryDirectory(std::move(binaryDirectory)) { diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index d2fc2ea..e05daa8 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -29,8 +29,8 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( std::string file_permissions, std::vector<std::string> const& configurations, std::string const& component, MessageLevel message, bool exclude_from_all, bool optional, cmListFileBacktrace backtrace) - : cmInstallGenerator(dest.c_str(), configurations, component.c_str(), - message, exclude_from_all) + : cmInstallGenerator(dest, configurations, component, message, + exclude_from_all) , TargetName(std::move(targetName)) , Target(nullptr) , FilePermissions(std::move(file_permissions)) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 02dedc1..d1a3454 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3028,7 +3028,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( // Include the user-specified pre-install script for this target. if (const char* preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall, false, nullptr, false); + cmInstallScriptGenerator g(preinstall, false, "", false); g.Generate(os, config, configurationTypes); } @@ -3081,7 +3081,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( // Include the user-specified post-install script for this target. if (const char* postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall, false, nullptr, false); + cmInstallScriptGenerator g(postinstall, false, "", false); g.Generate(os, config, configurationTypes); } } diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index c8bb1ab..7d676c9 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -71,7 +71,7 @@ protected: std::string CreateConfigTest(const std::string& config); std::string CreateConfigTest(std::vector<std::string> const& configs); - std::string CreateComponentTest(const char* component); + std::string CreateComponentTest(const std::string& component); // Information shared by most generator types. std::string RuntimeConfigVariable; |