cmInstallCommand: Port to cmArgumentParser

This commit is contained in:
Regina Pfeifer
2019-03-23 22:45:41 +01:00
committed by Kyle Edwards
parent 4336a29edd
commit e6b6bb0618
3 changed files with 131 additions and 136 deletions

View File

@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommand.h" #include "cmInstallCommand.h"
#include "cm_static_string_view.hxx"
#include "cmsys/Glob.hxx" #include "cmsys/Glob.hxx"
#include <set> #include <set>
#include <sstream> #include <sstream>
@@ -9,7 +10,7 @@
#include <utility> #include <utility>
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmCommandArgumentsHelper.h" #include "cmArgumentParser.h"
#include "cmExportSet.h" #include "cmExportSet.h"
#include "cmExportSetMap.h" #include "cmExportSetMap.h"
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
@@ -219,49 +220,51 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
return true; return true;
} }
/*struct InstallPart
{
InstallPart(cmCommandArgumentsHelper* helper, const char* key,
cmCommandArgumentGroup* group);
cmCAStringVector argVector;
cmInstallCommandArguments args;
};*/
bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
{ {
// This is the TARGETS mode. // This is the TARGETS mode.
std::vector<cmTarget*> targets; std::vector<cmTarget*> targets;
cmCommandArgumentsHelper argHelper; struct ArgVectors
cmCommandArgumentGroup group; {
cmCAStringVector genericArgVector(&argHelper, nullptr); std::vector<std::string> Archive;
cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group); std::vector<std::string> Library;
cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group); std::vector<std::string> Runtime;
cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group); std::vector<std::string> Object;
cmCAStringVector objectArgVector(&argHelper, "OBJECTS", &group); std::vector<std::string> Framework;
cmCAStringVector frameworkArgVector(&argHelper, "FRAMEWORK", &group); std::vector<std::string> Bundle;
cmCAStringVector bundleArgVector(&argHelper, "BUNDLE", &group); std::vector<std::string> Includes;
cmCAStringVector includesArgVector(&argHelper, "INCLUDES", &group); std::vector<std::string> PrivateHeader;
cmCAStringVector privateHeaderArgVector(&argHelper, "PRIVATE_HEADER", std::vector<std::string> PublicHeader;
&group); std::vector<std::string> Resource;
cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group); };
cmCAStringVector resourceArgVector(&argHelper, "RESOURCE", &group);
genericArgVector.Follows(nullptr);
group.Follows(&genericArgVector);
argHelper.Parse(&args, nullptr); static auto const argHelper =
cmArgumentParser<ArgVectors>{}
.Bind("ARCHIVE"_s, &ArgVectors::Archive)
.Bind("LIBRARY"_s, &ArgVectors::Library)
.Bind("RUNTIME"_s, &ArgVectors::Runtime)
.Bind("OBJECTS"_s, &ArgVectors::Object)
.Bind("FRAMEWORK"_s, &ArgVectors::Framework)
.Bind("BUNDLE"_s, &ArgVectors::Bundle)
.Bind("INCLUDES"_s, &ArgVectors::Includes)
.Bind("PRIVATE_HEADER"_s, &ArgVectors::PrivateHeader)
.Bind("PUBLIC_HEADER"_s, &ArgVectors::PublicHeader)
.Bind("RESOURCE"_s, &ArgVectors::Resource);
std::vector<std::string> genericArgVector;
ArgVectors const argVectors = argHelper.Parse(args, &genericArgVector);
// now parse the generic args (i.e. the ones not specialized on LIBRARY/ // now parse the generic args (i.e. the ones not specialized on LIBRARY/
// ARCHIVE, RUNTIME etc. (see above) // ARCHIVE, RUNTIME etc. (see above)
// These generic args also contain the targets and the export stuff // These generic args also contain the targets and the export stuff
std::vector<std::string> targetList;
std::string exports;
std::vector<std::string> unknownArgs; std::vector<std::string> unknownArgs;
cmInstallCommandArguments genericArgs(this->DefaultComponentName); cmInstallCommandArguments genericArgs(this->DefaultComponentName);
cmCAStringVector targetList(&genericArgs.Parser, "TARGETS"); genericArgs.Bind("TARGETS"_s, targetList);
cmCAString exports(&genericArgs.Parser, "EXPORT", genericArgs.Bind("EXPORT"_s, exports);
&genericArgs.ArgumentGroup); genericArgs.Parse(genericArgVector, &unknownArgs);
targetList.Follows(nullptr);
genericArgs.ArgumentGroup.Follows(&targetList);
genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs);
bool success = genericArgs.Finalize(); bool success = genericArgs.Finalize();
cmInstallCommandArguments archiveArgs(this->DefaultComponentName); cmInstallCommandArguments archiveArgs(this->DefaultComponentName);
@@ -277,16 +280,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// now parse the args for specific parts of the target (e.g. LIBRARY, // now parse the args for specific parts of the target (e.g. LIBRARY,
// RUNTIME, ARCHIVE etc. // RUNTIME, ARCHIVE etc.
archiveArgs.Parse(&archiveArgVector.GetVector(), &unknownArgs); archiveArgs.Parse(argVectors.Archive, &unknownArgs);
libraryArgs.Parse(&libraryArgVector.GetVector(), &unknownArgs); libraryArgs.Parse(argVectors.Library, &unknownArgs);
runtimeArgs.Parse(&runtimeArgVector.GetVector(), &unknownArgs); runtimeArgs.Parse(argVectors.Runtime, &unknownArgs);
objectArgs.Parse(&objectArgVector.GetVector(), &unknownArgs); objectArgs.Parse(argVectors.Object, &unknownArgs);
frameworkArgs.Parse(&frameworkArgVector.GetVector(), &unknownArgs); frameworkArgs.Parse(argVectors.Framework, &unknownArgs);
bundleArgs.Parse(&bundleArgVector.GetVector(), &unknownArgs); bundleArgs.Parse(argVectors.Bundle, &unknownArgs);
privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs); privateHeaderArgs.Parse(argVectors.PrivateHeader, &unknownArgs);
publicHeaderArgs.Parse(&publicHeaderArgVector.GetVector(), &unknownArgs); publicHeaderArgs.Parse(argVectors.PublicHeader, &unknownArgs);
resourceArgs.Parse(&resourceArgVector.GetVector(), &unknownArgs); resourceArgs.Parse(argVectors.Resource, &unknownArgs);
includesArgs.Parse(&includesArgVector.GetVector(), &unknownArgs); includesArgs.Parse(&argVectors.Includes, &unknownArgs);
if (!unknownArgs.empty()) { if (!unknownArgs.empty()) {
// Unknown argument. // Unknown argument.
@@ -382,7 +385,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
} }
// Check if there is something to do. // Check if there is something to do.
if (targetList.GetVector().empty()) { if (targetList.empty()) {
return true; return true;
} }
@@ -390,7 +393,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
bool dll_platform = bool dll_platform =
!this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
for (std::string const& tgt : targetList.GetVector()) { for (std::string const& tgt : targetList) {
if (this->Makefile->IsAlias(tgt)) { if (this->Makefile->IsAlias(tgt)) {
std::ostringstream e; std::ostringstream e;
@@ -748,7 +751,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Add this install rule to an export if one was specified and // Add this install rule to an export if one was specified and
// this is not a namelink-only rule. // this is not a namelink-only rule.
if (!exports.GetString().empty() && !namelinkOnly) { if (!exports.empty() && !namelinkOnly) {
cmTargetExport* te = new cmTargetExport; cmTargetExport* te = new cmTargetExport;
te->TargetName = target.GetName(); te->TargetName = target.GetName();
te->ArchiveGenerator = archiveGenerator; te->ArchiveGenerator = archiveGenerator;
@@ -759,7 +762,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
te->RuntimeGenerator = runtimeGenerator; te->RuntimeGenerator = runtimeGenerator;
te->ObjectsGenerator = objectGenerator; te->ObjectsGenerator = objectGenerator;
this->Makefile->GetGlobalGenerator() this->Makefile->GetGlobalGenerator()
->GetExportSets()[exports.GetString()] ->GetExportSets()[exports]
->AddTargetExport(te); ->AddTargetExport(te);
te->InterfaceIncludeDirectories = te->InterfaceIncludeDirectories =
@@ -818,11 +821,10 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// This is the FILES mode. // This is the FILES mode.
bool programs = (args[0] == "PROGRAMS"); bool programs = (args[0] == "PROGRAMS");
cmInstallCommandArguments ica(this->DefaultComponentName); cmInstallCommandArguments ica(this->DefaultComponentName);
cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES"); std::vector<std::string> files;
files.Follows(nullptr); ica.Bind(programs ? "PROGRAMS"_s : "FILES"_s, files);
ica.ArgumentGroup.Follows(&files);
std::vector<std::string> unknownArgs; std::vector<std::string> unknownArgs;
ica.Parse(&args, &unknownArgs); ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) { if (!unknownArgs.empty()) {
// Unknown argument. // Unknown argument.
@@ -840,7 +842,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
return false; return false;
} }
const std::vector<std::string>& filesVector = files.GetVector(); const std::vector<std::string>& filesVector = files;
// Check if there is something to do. // Check if there is something to do.
if (filesVector.empty()) { if (filesVector.empty()) {
@@ -1271,16 +1273,19 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
// This is the EXPORT mode. // This is the EXPORT mode.
cmInstallCommandArguments ica(this->DefaultComponentName); cmInstallCommandArguments ica(this->DefaultComponentName);
cmCAString exp(&ica.Parser, "EXPORT_ANDROID_MK");
cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES",
&ica.ArgumentGroup);
cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
exp.Follows(nullptr);
ica.ArgumentGroup.Follows(&exp); std::string exp;
std::string name_space;
bool exportOld = false;
std::string filename;
ica.Bind("EXPORT_ANDROID_MK"_s, exp);
ica.Bind("NAMESPACE"_s, name_space);
ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
ica.Bind("FILE"_s, filename);
std::vector<std::string> unknownArgs; std::vector<std::string> unknownArgs;
ica.Parse(&args, &unknownArgs); ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) { if (!unknownArgs.empty()) {
// Unknown argument. // Unknown argument.
@@ -1304,7 +1309,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
} }
// Check the file name. // Check the file name.
std::string fname = filename.GetString(); std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) { if (fname.find_first_of(":/\\") != std::string::npos) {
std::ostringstream e; std::ostringstream e;
e << args[0] << " given invalid export file name \"" << fname << "\". " e << args[0] << " given invalid export file name \"" << fname << "\". "
@@ -1325,7 +1330,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
} }
if (fname.find_first_of(":/\\") != std::string::npos) { if (fname.find_first_of(":/\\") != std::string::npos) {
std::ostringstream e; std::ostringstream e;
e << args[0] << " given export name \"" << exp.GetString() << "\". " e << args[0] << " given export name \"" << exp << "\". "
<< "This name cannot be safely converted to a file name. " << "This name cannot be safely converted to a file name. "
<< "Specify a different export name or use the FILE option to set " << "Specify a different export name or use the FILE option to set "
<< "a file name explicitly."; << "a file name explicitly.";
@@ -1338,7 +1343,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
} }
cmExportSet* exportSet = cmExportSet* exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()]; this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
cmInstallGenerator::MessageLevel message = cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(this->Makefile); cmInstallGenerator::SelectMessageLevel(this->Makefile);
@@ -1347,8 +1352,8 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetConfigurations(), ica.GetComponent().c_str(), message,
ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
exportOld.IsEnabled(), true); true);
this->Makefile->AddInstallGenerator(exportGenerator); this->Makefile->AddInstallGenerator(exportGenerator);
return true; return true;
@@ -1363,16 +1368,19 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
{ {
// This is the EXPORT mode. // This is the EXPORT mode.
cmInstallCommandArguments ica(this->DefaultComponentName); cmInstallCommandArguments ica(this->DefaultComponentName);
cmCAString exp(&ica.Parser, "EXPORT");
cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES",
&ica.ArgumentGroup);
cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
exp.Follows(nullptr);
ica.ArgumentGroup.Follows(&exp); std::string exp;
std::string name_space;
bool exportOld = false;
std::string filename;
ica.Bind("EXPORT"_s, exp);
ica.Bind("NAMESPACE"_s, name_space);
ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
ica.Bind("FILE"_s, filename);
std::vector<std::string> unknownArgs; std::vector<std::string> unknownArgs;
ica.Parse(&args, &unknownArgs); ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) { if (!unknownArgs.empty()) {
// Unknown argument. // Unknown argument.
@@ -1396,7 +1404,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
} }
// Check the file name. // Check the file name.
std::string fname = filename.GetString(); std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) { if (fname.find_first_of(":/\\") != std::string::npos) {
std::ostringstream e; std::ostringstream e;
e << args[0] << " given invalid export file name \"" << fname << "\". " e << args[0] << " given invalid export file name \"" << fname << "\". "
@@ -1418,12 +1426,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Construct the file name. // Construct the file name.
if (fname.empty()) { if (fname.empty()) {
fname = exp.GetString(); fname = exp;
fname += ".cmake"; fname += ".cmake";
if (fname.find_first_of(":/\\") != std::string::npos) { if (fname.find_first_of(":/\\") != std::string::npos) {
std::ostringstream e; std::ostringstream e;
e << args[0] << " given export name \"" << exp.GetString() << "\". " e << args[0] << " given export name \"" << exp << "\". "
<< "This name cannot be safely converted to a file name. " << "This name cannot be safely converted to a file name. "
<< "Specify a different export name or use the FILE option to set " << "Specify a different export name or use the FILE option to set "
<< "a file name explicitly."; << "a file name explicitly.";
@@ -1433,8 +1441,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
} }
cmExportSet* exportSet = cmExportSet* exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()]; this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
if (exportOld.IsEnabled()) { if (exportOld) {
for (cmTargetExport* te : *exportSet->GetTargetExports()) { for (cmTargetExport* te : *exportSet->GetTargetExports()) {
cmTarget* tgt = cmTarget* tgt =
this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName); this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
@@ -1461,8 +1469,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetConfigurations(), ica.GetComponent().c_str(), message,
ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(), ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
exportOld.IsEnabled(), false); false);
this->Makefile->AddInstallGenerator(exportGenerator); this->Makefile->AddInstallGenerator(exportGenerator);
return true; return true;

View File

@@ -4,6 +4,7 @@
#include "cmRange.h" #include "cmRange.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cm_static_string_view.hxx"
#include <utility> #include <utility>
@@ -18,20 +19,19 @@ const std::string cmInstallCommandArguments::EmptyString;
cmInstallCommandArguments::cmInstallCommandArguments( cmInstallCommandArguments::cmInstallCommandArguments(
std::string defaultComponent) std::string defaultComponent)
: Destination(&Parser, "DESTINATION", &ArgumentGroup) : DefaultComponentName(std::move(defaultComponent))
, Component(&Parser, "COMPONENT", &ArgumentGroup)
, NamelinkComponent(&Parser, "NAMELINK_COMPONENT", &ArgumentGroup)
, ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup)
, Rename(&Parser, "RENAME", &ArgumentGroup)
, Permissions(&Parser, "PERMISSIONS", &ArgumentGroup)
, Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
, Optional(&Parser, "OPTIONAL", &ArgumentGroup)
, NamelinkOnly(&Parser, "NAMELINK_ONLY", &ArgumentGroup)
, NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup)
, Type(&Parser, "TYPE", &ArgumentGroup)
, GenericArguments(nullptr)
, DefaultComponentName(std::move(defaultComponent))
{ {
this->Bind("DESTINATION"_s, this->Destination);
this->Bind("COMPONENT"_s, this->Component);
this->Bind("NAMELINK_COMPONENT"_s, this->NamelinkComponent);
this->Bind("EXCLUDE_FROM_ALL"_s, this->ExcludeFromAll);
this->Bind("RENAME"_s, this->Rename);
this->Bind("PERMISSIONS"_s, this->Permissions);
this->Bind("CONFIGURATIONS"_s, this->Configurations);
this->Bind("OPTIONAL"_s, this->Optional);
this->Bind("NAMELINK_ONLY"_s, this->NamelinkOnly);
this->Bind("NAMELINK_SKIP"_s, this->NamelinkSkip);
this->Bind("TYPE"_s, this->Type);
} }
const std::string& cmInstallCommandArguments::GetDestination() const const std::string& cmInstallCommandArguments::GetDestination() const
@@ -47,8 +47,8 @@ const std::string& cmInstallCommandArguments::GetDestination() const
const std::string& cmInstallCommandArguments::GetComponent() const const std::string& cmInstallCommandArguments::GetComponent() const
{ {
if (!this->Component.GetString().empty()) { if (!this->Component.empty()) {
return this->Component.GetString(); return this->Component;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetComponent(); return this->GenericArguments->GetComponent();
@@ -62,16 +62,16 @@ const std::string& cmInstallCommandArguments::GetComponent() const
const std::string& cmInstallCommandArguments::GetNamelinkComponent() const const std::string& cmInstallCommandArguments::GetNamelinkComponent() const
{ {
if (!this->NamelinkComponent.GetString().empty()) { if (!this->NamelinkComponent.empty()) {
return this->NamelinkComponent.GetString(); return this->NamelinkComponent;
} }
return this->GetComponent(); return this->GetComponent();
} }
const std::string& cmInstallCommandArguments::GetRename() const const std::string& cmInstallCommandArguments::GetRename() const
{ {
if (!this->Rename.GetString().empty()) { if (!this->Rename.empty()) {
return this->Rename.GetString(); return this->Rename;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetRename(); return this->GenericArguments->GetRename();
@@ -92,7 +92,7 @@ const std::string& cmInstallCommandArguments::GetPermissions() const
bool cmInstallCommandArguments::GetOptional() const bool cmInstallCommandArguments::GetOptional() const
{ {
if (this->Optional.IsEnabled()) { if (this->Optional) {
return true; return true;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
@@ -103,7 +103,7 @@ bool cmInstallCommandArguments::GetOptional() const
bool cmInstallCommandArguments::GetExcludeFromAll() const bool cmInstallCommandArguments::GetExcludeFromAll() const
{ {
if (this->ExcludeFromAll.IsEnabled()) { if (this->ExcludeFromAll) {
return true; return true;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
@@ -114,7 +114,7 @@ bool cmInstallCommandArguments::GetExcludeFromAll() const
bool cmInstallCommandArguments::GetNamelinkOnly() const bool cmInstallCommandArguments::GetNamelinkOnly() const
{ {
if (this->NamelinkOnly.IsEnabled()) { if (this->NamelinkOnly) {
return true; return true;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
@@ -125,7 +125,7 @@ bool cmInstallCommandArguments::GetNamelinkOnly() const
bool cmInstallCommandArguments::GetNamelinkSkip() const bool cmInstallCommandArguments::GetNamelinkSkip() const
{ {
if (this->NamelinkSkip.IsEnabled()) { if (this->NamelinkSkip) {
return true; return true;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
@@ -136,7 +136,7 @@ bool cmInstallCommandArguments::GetNamelinkSkip() const
bool cmInstallCommandArguments::HasNamelinkComponent() const bool cmInstallCommandArguments::HasNamelinkComponent() const
{ {
if (!this->NamelinkComponent.GetString().empty()) { if (!this->NamelinkComponent.empty()) {
return true; return true;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
@@ -147,19 +147,19 @@ bool cmInstallCommandArguments::HasNamelinkComponent() const
const std::string& cmInstallCommandArguments::GetType() const const std::string& cmInstallCommandArguments::GetType() const
{ {
return this->Type.GetString(); return this->Type;
} }
const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations() const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations()
const const
{ {
if (!this->Configurations.GetVector().empty()) { if (!this->Configurations.empty()) {
return this->Configurations.GetVector(); return this->Configurations;
} }
if (this->GenericArguments != nullptr) { if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetConfigurations(); return this->GenericArguments->GetConfigurations();
} }
return this->Configurations.GetVector(); return this->Configurations;
} }
bool cmInstallCommandArguments::Finalize() bool cmInstallCommandArguments::Finalize()
@@ -167,21 +167,15 @@ bool cmInstallCommandArguments::Finalize()
if (!this->CheckPermissions()) { if (!this->CheckPermissions()) {
return false; return false;
} }
this->DestinationString = this->Destination.GetString(); this->DestinationString = this->Destination;
cmSystemTools::ConvertToUnixSlashes(this->DestinationString); cmSystemTools::ConvertToUnixSlashes(this->DestinationString);
return true; return true;
} }
void cmInstallCommandArguments::Parse(const std::vector<std::string>* args,
std::vector<std::string>* unconsumedArgs)
{
this->Parser.Parse(args, unconsumedArgs);
}
bool cmInstallCommandArguments::CheckPermissions() bool cmInstallCommandArguments::CheckPermissions()
{ {
this->PermissionsString.clear(); this->PermissionsString.clear();
for (std::string const& perm : this->Permissions.GetVector()) { for (std::string const& perm : this->Permissions) {
if (!cmInstallCommandArguments::CheckPermissions( if (!cmInstallCommandArguments::CheckPermissions(
perm, this->PermissionsString)) { perm, this->PermissionsString)) {
return false; return false;

View File

@@ -8,9 +8,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "cmCommandArgumentsHelper.h" #include "cmArgumentParser.h"
class cmInstallCommandArguments class cmInstallCommandArguments : public cmArgumentParser<void>
{ {
public: public:
cmInstallCommandArguments(std::string defaultComponent); cmInstallCommandArguments(std::string defaultComponent);
@@ -18,8 +18,6 @@ public:
{ {
this->GenericArguments = args; this->GenericArguments = args;
} }
void Parse(const std::vector<std::string>* args,
std::vector<std::string>* unconsumedArgs);
// Compute destination path.and check permissions // Compute destination path.and check permissions
bool Finalize(); bool Finalize();
@@ -37,30 +35,25 @@ public:
bool HasNamelinkComponent() const; bool HasNamelinkComponent() const;
const std::string& GetType() const; const std::string& GetType() const;
// once HandleDirectoryMode() is also switched to using
// cmInstallCommandArguments then these two functions can become non-static
// private member functions without arguments
static bool CheckPermissions(const std::string& onePerm, std::string& perm); static bool CheckPermissions(const std::string& onePerm, std::string& perm);
cmCommandArgumentsHelper Parser;
cmCommandArgumentGroup ArgumentGroup;
private: private:
cmCAString Destination; std::string Destination;
cmCAString Component; std::string Component;
cmCAString NamelinkComponent; std::string NamelinkComponent;
cmCAEnabler ExcludeFromAll; bool ExcludeFromAll = false;
cmCAString Rename; std::string Rename;
cmCAStringVector Permissions; std::vector<std::string> Permissions;
cmCAStringVector Configurations; std::vector<std::string> Configurations;
cmCAEnabler Optional; bool Optional = false;
cmCAEnabler NamelinkOnly; bool NamelinkOnly = false;
cmCAEnabler NamelinkSkip; bool NamelinkSkip = false;
cmCAString Type; std::string Type;
std::string DestinationString; std::string DestinationString;
std::string PermissionsString; std::string PermissionsString;
cmInstallCommandArguments* GenericArguments; cmInstallCommandArguments* GenericArguments = nullptr;
static const char* PermissionsTable[]; static const char* PermissionsTable[];
static const std::string EmptyString; static const std::string EmptyString;
std::string DefaultComponentName; std::string DefaultComponentName;