cmCommand refactor: cmLoadCommandCommand
This commit is contained in:
parent
9d6fc3f5ed
commit
7533e47ccc
@ -314,8 +314,7 @@ void GetProjectCommands(cmState* state)
|
|||||||
"The export_library_dependencies command should not be called; "
|
"The export_library_dependencies command should not be called; "
|
||||||
"see CMP0033.");
|
"see CMP0033.");
|
||||||
state->AddDisallowedCommand(
|
state->AddDisallowedCommand(
|
||||||
"load_command", cm::make_unique<cmLoadCommandCommand>(),
|
"load_command", cmLoadCommandCommand, cmPolicies::CMP0031,
|
||||||
cmPolicies::CMP0031,
|
|
||||||
"The load_command command should not be called; see CMP0031.");
|
"The load_command command should not be called; see CMP0031.");
|
||||||
state->AddDisallowedCommand(
|
state->AddDisallowedCommand(
|
||||||
"output_required_files", cm::make_unique<cmOutputRequiredFilesCommand>(),
|
"output_required_files", cm::make_unique<cmOutputRequiredFilesCommand>(),
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
#include "cmCPluginAPI.cxx"
|
#include "cmCPluginAPI.cxx"
|
||||||
#include "cmCPluginAPI.h"
|
#include "cmCPluginAPI.h"
|
||||||
|
#include "cmCommand.h"
|
||||||
#include "cmDynamicLoader.h"
|
#include "cmDynamicLoader.h"
|
||||||
|
#include "cmExecutionStatus.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
class cmExecutionStatus;
|
|
||||||
|
|
||||||
#ifdef __QNX__
|
#ifdef __QNX__
|
||||||
# include <malloc.h> /* for malloc/free on QNX */
|
# include <malloc.h> /* for malloc/free on QNX */
|
||||||
#endif
|
#endif
|
||||||
@ -175,8 +175,8 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// cmLoadCommandCommand
|
// cmLoadCommandCommand
|
||||||
bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
|
bool cmLoadCommandCommand(std::vector<std::string> const& args,
|
||||||
cmExecutionStatus&)
|
cmExecutionStatus& status)
|
||||||
{
|
{
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
return true;
|
return true;
|
||||||
@ -185,13 +185,13 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
// Construct a variable to report what file was loaded, if any.
|
// Construct a variable to report what file was loaded, if any.
|
||||||
// Start by removing the definition in case of failure.
|
// Start by removing the definition in case of failure.
|
||||||
std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]);
|
std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]);
|
||||||
this->Makefile->RemoveDefinition(reportVar);
|
status.GetMakefile().RemoveDefinition(reportVar);
|
||||||
|
|
||||||
// the file must exist
|
// the file must exist
|
||||||
std::string moduleName = cmStrCat(
|
std::string moduleName = cmStrCat(
|
||||||
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"), "cm",
|
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"),
|
||||||
args[0],
|
"cm", args[0],
|
||||||
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
|
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
|
||||||
|
|
||||||
// search for the file
|
// search for the file
|
||||||
std::vector<std::string> path;
|
std::vector<std::string> path;
|
||||||
@ -209,7 +209,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
if (fullPath.empty()) {
|
if (fullPath.empty()) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "Attempt to load command failed from file \"" << moduleName << "\"";
|
e << "Attempt to load command failed from file \"" << moduleName << "\"";
|
||||||
this->SetError(e.str());
|
status.SetError(e.str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,12 +224,12 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
err += " Additional error info is:\n";
|
err += " Additional error info is:\n";
|
||||||
err += error;
|
err += error;
|
||||||
}
|
}
|
||||||
this->SetError(err);
|
status.SetError(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report what file was loaded for this command.
|
// Report what file was loaded for this command.
|
||||||
this->Makefile->AddDefinition(reportVar, fullPath);
|
status.GetMakefile().AddDefinition(reportVar, fullPath);
|
||||||
|
|
||||||
// find the init function
|
// find the init function
|
||||||
std::string initFuncName = args[0] + "Init";
|
std::string initFuncName = args[0] + "Init";
|
||||||
@ -243,12 +243,12 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
// if the symbol is found call it to set the name on the
|
// if the symbol is found call it to set the name on the
|
||||||
// function blocker
|
// function blocker
|
||||||
if (initFunction) {
|
if (initFunction) {
|
||||||
this->Makefile->GetState()->AddScriptedCommand(
|
status.GetMakefile().GetState()->AddScriptedCommand(
|
||||||
args[0],
|
args[0],
|
||||||
cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction)));
|
cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this->SetError("Attempt to load command failed. "
|
status.SetError("Attempt to load command failed. "
|
||||||
"No init function found.");
|
"No init function found.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,21 +8,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cm_memory.hxx"
|
|
||||||
|
|
||||||
#include "cmCommand.h"
|
|
||||||
|
|
||||||
class cmExecutionStatus;
|
class cmExecutionStatus;
|
||||||
|
|
||||||
class cmLoadCommandCommand : public cmCommand
|
bool cmLoadCommandCommand(std::vector<std::string> const& args,
|
||||||
{
|
cmExecutionStatus& status);
|
||||||
public:
|
|
||||||
std::unique_ptr<cmCommand> Clone() override
|
|
||||||
{
|
|
||||||
return cm::make_unique<cmLoadCommandCommand>();
|
|
||||||
}
|
|
||||||
bool InitialPass(std::vector<std::string> const& args,
|
|
||||||
cmExecutionStatus& status) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user