cmFileCommand: port to cmExecutionStatus

This commit is contained in:
Daniel Pfeifer
2017-01-08 23:47:29 +01:00
committed by Regina Pfeifer
parent 53fc083d37
commit 64f987c174
6 changed files with 408 additions and 359 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -37,43 +37,69 @@ public:
cmExecutionStatus& status) override; cmExecutionStatus& status) override;
protected: protected:
bool HandleRename(std::vector<std::string> const& args); bool HandleRename(std::vector<std::string> const& args,
bool HandleRemove(std::vector<std::string> const& args, bool recurse); cmExecutionStatus& status);
bool HandleWriteCommand(std::vector<std::string> const& args, bool append); bool HandleRemove(std::vector<std::string> const& args, bool recurse,
bool HandleReadCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleHashCommand(std::vector<std::string> const& args); bool HandleWriteCommand(std::vector<std::string> const& args, bool append,
bool HandleStringsCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse); bool HandleReadCommand(std::vector<std::string> const& args,
bool HandleTouchCommand(std::vector<std::string> const& args, bool create); cmExecutionStatus& status);
bool HandleMakeDirectoryCommand(std::vector<std::string> const& args); bool HandleHashCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleStringsCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse,
cmExecutionStatus& status);
bool HandleTouchCommand(std::vector<std::string> const& args, bool create,
cmExecutionStatus& status);
bool HandleMakeDirectoryCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleRelativePathCommand(std::vector<std::string> const& args); bool HandleRelativePathCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleCMakePathCommand(std::vector<std::string> const& args, bool HandleCMakePathCommand(std::vector<std::string> const& args,
bool nativePath); bool nativePath, cmExecutionStatus& status);
bool HandleReadElfCommand(std::vector<std::string> const& args); bool HandleReadElfCommand(std::vector<std::string> const& args,
bool HandleRPathChangeCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleRPathCheckCommand(std::vector<std::string> const& args); bool HandleRPathChangeCommand(std::vector<std::string> const& args,
bool HandleRPathRemoveCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleDifferentCommand(std::vector<std::string> const& args); bool HandleRPathCheckCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleDifferentCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleCopyCommand(std::vector<std::string> const& args); bool HandleCopyCommand(std::vector<std::string> const& args,
bool HandleInstallCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleDownloadCommand(std::vector<std::string> const& args); bool HandleInstallCommand(std::vector<std::string> const& args,
bool HandleUploadCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleDownloadCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleUploadCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleTimestampCommand(std::vector<std::string> const& args); bool HandleTimestampCommand(std::vector<std::string> const& args,
bool HandleGenerateCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleLockCommand(std::vector<std::string> const& args); bool HandleGenerateCommand(std::vector<std::string> const& args,
bool HandleSizeCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleReadSymlinkCommand(std::vector<std::string> const& args); bool HandleLockCommand(std::vector<std::string> const& args,
bool HandleCreateLinkCommand(std::vector<std::string> const& args); cmExecutionStatus& status);
bool HandleSizeCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleCreateLinkCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
bool HandleGetRuntimeDependenciesCommand( bool HandleGetRuntimeDependenciesCommand(
std::vector<std::string> const& args); std::vector<std::string> const& args, cmExecutionStatus& status);
private: private:
void AddEvaluationFile(const std::string& inputName, void AddEvaluationFile(const std::string& inputName,
const std::string& outputExpr, const std::string& outputExpr,
const std::string& condition, bool inputIsContent); const std::string& condition, bool inputIsContent,
cmExecutionStatus& status);
}; };
#endif #endif

View File

@@ -3,8 +3,8 @@
#include "cmFileCopier.h" #include "cmFileCopier.h"
#include "cmExecutionStatus.h"
#include "cmFSPermissions.h" #include "cmFSPermissions.h"
#include "cmFileCommand.h"
#include "cmFileTimes.h" #include "cmFileTimes.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@@ -20,9 +20,9 @@
using namespace cmFSPermissions; using namespace cmFSPermissions;
cmFileCopier::cmFileCopier(cmFileCommand* command, const char* name) cmFileCopier::cmFileCopier(cmExecutionStatus& status, const char* name)
: FileCommand(command) : Status(status)
, Makefile(command->GetMakefile()) , Makefile(&status.GetMakefile())
, Name(name) , Name(name)
, Always(false) , Always(false)
, MatchlessFiles(true) , MatchlessFiles(true)
@@ -91,7 +91,7 @@ bool cmFileCopier::SetPermissions(const std::string& toFile,
if (!cmSystemTools::SetPermissions(toFile, permissions)) { if (!cmSystemTools::SetPermissions(toFile, permissions)) {
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot set permissions on \"" << toFile << "\""; e << this->Name << " cannot set permissions on \"" << toFile << "\"";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
} }
@@ -105,7 +105,7 @@ bool cmFileCopier::CheckPermissions(std::string const& arg,
if (!cmFSPermissions::stringToModeT(arg, permissions)) { if (!cmFSPermissions::stringToModeT(arg, permissions)) {
std::ostringstream e; std::ostringstream e;
e << this->Name << " given invalid permission \"" << arg << "\"."; e << this->Name << " given invalid permission \"" << arg << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
return true; return true;
@@ -121,7 +121,7 @@ bool cmFileCopier::ReportMissing(const std::string& fromFile)
// The input file does not exist and installation is not optional. // The input file does not exist and installation is not optional.
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot find \"" << fromFile << "\"."; e << this->Name << " cannot find \"" << fromFile << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -129,7 +129,7 @@ void cmFileCopier::NotBeforeMatch(std::string const& arg)
{ {
std::ostringstream e; std::ostringstream e;
e << "option " << arg << " may not appear before PATTERN or REGEX."; e << "option " << arg << " may not appear before PATTERN or REGEX.";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
this->Doing = DoingError; this->Doing = DoingError;
} }
@@ -137,7 +137,7 @@ void cmFileCopier::NotAfterMatch(std::string const& arg)
{ {
std::ostringstream e; std::ostringstream e;
e << "option " << arg << " may not appear after PATTERN or REGEX."; e << "option " << arg << " may not appear after PATTERN or REGEX.";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
this->Doing = DoingError; this->Doing = DoingError;
} }
@@ -174,7 +174,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode)
cmSystemTools::ExpandListArgument(default_dir_install_permissions, items); cmSystemTools::ExpandListArgument(default_dir_install_permissions, items);
for (const auto& arg : items) { for (const auto& arg : items) {
if (!this->CheckPermissions(arg, **mode)) { if (!this->CheckPermissions(arg, **mode)) {
this->FileCommand->SetError( this->Status.SetError(
" Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable."); " Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable.");
return false; return false;
} }
@@ -194,7 +194,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) { if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
std::ostringstream e; std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\"."; e << "called with unknown argument \"" << args[i] << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -208,7 +208,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
if (this->Destination.empty()) { if (this->Destination.empty()) {
std::ostringstream e; std::ostringstream e;
e << this->Name << " given no DESTINATION"; e << this->Name << " given no DESTINATION";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -341,7 +341,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
} else { } else {
std::ostringstream e; std::ostringstream e;
e << "could not compile PATTERN \"" << arg << "\"."; e << "could not compile PATTERN \"" << arg << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
this->Doing = DoingError; this->Doing = DoingError;
} }
} break; } break;
@@ -353,7 +353,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
} else { } else {
std::ostringstream e; std::ostringstream e;
e << "could not compile REGEX \"" << arg << "\"."; e << "could not compile REGEX \"" << arg << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
this->Doing = DoingError; this->Doing = DoingError;
} }
break; break;
@@ -396,8 +396,8 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
file += "/"; file += "/";
file += f; file += f;
} else if (!this->FilesFromDir.empty()) { } else if (!this->FilesFromDir.empty()) {
this->FileCommand->SetError("option FILES_FROM_DIR requires all files " this->Status.SetError("option FILES_FROM_DIR requires all files "
"to be specified as relative paths."); "to be specified as relative paths.");
return false; return false;
} else { } else {
file = f; file = f;
@@ -446,7 +446,7 @@ bool cmFileCopier::Install(const std::string& fromFile,
if (fromFile.empty()) { if (fromFile.empty()) {
std::ostringstream e; std::ostringstream e;
e << "INSTALL encountered an empty string input file name."; e << "INSTALL encountered an empty string input file name.";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -514,7 +514,7 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile,
if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) { if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot create symlink \"" << toFile << "\"."; e << this->Name << " cannot create symlink \"" << toFile << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
} }
@@ -535,7 +535,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot read symlink \"" << fromFile e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\"."; << "\" to duplicate at \"" << toFile << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -566,7 +566,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot duplicate symlink \"" << fromFile e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\"."; << "\" at \"" << toFile << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
} }
@@ -595,7 +595,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile,
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot copy file \"" << fromFile << "\" to \"" e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
<< toFile << "\"."; << toFile << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
@@ -611,7 +611,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile,
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot set modification time on \"" << toFile e << this->Name << " cannot set modification time on \"" << toFile
<< "\""; << "\"";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
} }
@@ -648,7 +648,7 @@ bool cmFileCopier::InstallDirectory(const std::string& source,
std::ostringstream e; std::ostringstream e;
e << this->Name << " cannot make directory \"" << destination e << this->Name << " cannot make directory \"" << destination
<< "\": " << cmSystemTools::GetLastSystemError(); << "\": " << cmSystemTools::GetLastSystemError();
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }

View File

@@ -12,19 +12,19 @@
#include <string> #include <string>
#include <vector> #include <vector>
class cmFileCommand; class cmExecutionStatus;
class cmMakefile; class cmMakefile;
// File installation helper class. // File installation helper class.
struct cmFileCopier struct cmFileCopier
{ {
cmFileCopier(cmFileCommand* command, const char* name = "COPY"); cmFileCopier(cmExecutionStatus& status, const char* name = "COPY");
virtual ~cmFileCopier(); virtual ~cmFileCopier();
bool Run(std::vector<std::string> const& args); bool Run(std::vector<std::string> const& args);
protected: protected:
cmFileCommand* FileCommand; cmExecutionStatus& Status;
cmMakefile* Makefile; cmMakefile* Makefile;
const char* Name; const char* Name;
bool Always; bool Always;

View File

@@ -3,8 +3,8 @@
#include "cmFileInstaller.h" #include "cmFileInstaller.h"
#include "cmExecutionStatus.h"
#include "cmFSPermissions.h" #include "cmFSPermissions.h"
#include "cmFileCommand.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@@ -14,8 +14,8 @@
using namespace cmFSPermissions; using namespace cmFSPermissions;
cmFileInstaller::cmFileInstaller(cmFileCommand* command) cmFileInstaller::cmFileInstaller(cmExecutionStatus& status)
: cmFileCopier(command, "INSTALL") : cmFileCopier(status, "INSTALL")
, InstallType(cmInstallType_FILES) , InstallType(cmInstallType_FILES)
, Optional(false) , Optional(false)
, MessageAlways(false) , MessageAlways(false)
@@ -111,19 +111,19 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args)
if (!this->Rename.empty()) { if (!this->Rename.empty()) {
if (!this->FilesFromDir.empty()) { if (!this->FilesFromDir.empty()) {
this->FileCommand->SetError("INSTALL option RENAME may not be " this->Status.SetError("INSTALL option RENAME may not be "
"combined with FILES_FROM_DIR."); "combined with FILES_FROM_DIR.");
return false; return false;
} }
if (this->InstallType != cmInstallType_FILES && if (this->InstallType != cmInstallType_FILES &&
this->InstallType != cmInstallType_PROGRAMS) { this->InstallType != cmInstallType_PROGRAMS) {
this->FileCommand->SetError("INSTALL option RENAME may be used " this->Status.SetError("INSTALL option RENAME may be used "
"only with FILES or PROGRAMS."); "only with FILES or PROGRAMS.");
return false; return false;
} }
if (this->Files.size() > 1) { if (this->Files.size() > 1) {
this->FileCommand->SetError("INSTALL option RENAME may be used " this->Status.SetError("INSTALL option RENAME may be used "
"only with one file."); "only with one file.");
return false; return false;
} }
} }
@@ -134,9 +134,9 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args)
if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) + if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) +
(this->MessageNever ? 1 : 0)) > 1) { (this->MessageNever ? 1 : 0)) > 1) {
this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, " this->Status.SetError("INSTALL options MESSAGE_ALWAYS, "
"MESSAGE_LAZY, and MESSAGE_NEVER " "MESSAGE_LAZY, and MESSAGE_NEVER "
"are mutually exclusive."); "are mutually exclusive.");
return false; return false;
} }
@@ -213,7 +213,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
e << "INSTALL called with old-style " << arg << " argument. " e << "INSTALL called with old-style " << arg << " argument. "
<< "This script was generated with an older version of CMake. " << "This script was generated with an older version of CMake. "
<< "Re-run this cmake version on your build tree."; << "Re-run this cmake version on your build tree.";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
this->Doing = DoingError; this->Doing = DoingError;
} else { } else {
return this->cmFileCopier::CheckKeyword(arg); return this->cmFileCopier::CheckKeyword(arg);
@@ -257,7 +257,7 @@ bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype)
} else { } else {
std::ostringstream e; std::ostringstream e;
e << "Option TYPE given unknown value \"" << stype << "\"."; e << "Option TYPE given unknown value \"" << stype << "\".";
this->FileCommand->SetError(e.str()); this->Status.SetError(e.str());
return false; return false;
} }
return true; return true;
@@ -269,8 +269,8 @@ bool cmFileInstaller::HandleInstallDestination()
// allow for / to be a valid destination // allow for / to be a valid destination
if (destination.size() < 2 && destination != "/") { if (destination.size() < 2 && destination != "/") {
this->FileCommand->SetError("called with inappropriate arguments. " this->Status.SetError("called with inappropriate arguments. "
"No DESTINATION provided or ."); "No DESTINATION provided or .");
return false; return false;
} }
@@ -300,7 +300,7 @@ bool cmFileInstaller::HandleInstallDestination()
if (relative) { if (relative) {
// This is relative path on unix or windows. Since we are doing // This is relative path on unix or windows. Since we are doing
// destdir, this case does not make sense. // destdir, this case does not make sense.
this->FileCommand->SetError( this->Status.SetError(
"called with relative DESTINATION. This " "called with relative DESTINATION. This "
"does not make sense when using DESTDIR. Specify " "does not make sense when using DESTDIR. Specify "
"absolute path or remove DESTDIR environment variable."); "absolute path or remove DESTDIR environment variable.");
@@ -315,7 +315,7 @@ bool cmFileInstaller::HandleInstallDestination()
"absolute path or remove DESTDIR environment variable." "absolute path or remove DESTDIR environment variable."
"\nDESTINATION=\n"; "\nDESTINATION=\n";
message += destination; message += destination;
this->FileCommand->SetError(message); this->Status.SetError(message);
return false; return false;
} }
} }
@@ -335,14 +335,14 @@ bool cmFileInstaller::HandleInstallDestination()
if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) { if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
std::string errstring = "cannot create directory: " + destination + std::string errstring = "cannot create directory: " + destination +
". Maybe need administrative privileges."; ". Maybe need administrative privileges.";
this->FileCommand->SetError(errstring); this->Status.SetError(errstring);
return false; return false;
} }
} }
if (!cmSystemTools::FileIsDirectory(destination)) { if (!cmSystemTools::FileIsDirectory(destination)) {
std::string errstring = std::string errstring =
"INSTALL destination: " + destination + " is not a directory."; "INSTALL destination: " + destination + " is not a directory.";
this->FileCommand->SetError(errstring); this->Status.SetError(errstring);
return false; return false;
} }
} }

View File

@@ -12,11 +12,11 @@
#include <string> #include <string>
#include <vector> #include <vector>
class cmFileCommand; class cmExecutionStatus;
struct cmFileInstaller : public cmFileCopier struct cmFileInstaller : public cmFileCopier
{ {
cmFileInstaller(cmFileCommand* command); cmFileInstaller(cmExecutionStatus& status);
~cmFileInstaller() override; ~cmFileInstaller() override;
protected: protected: