mirror of
https://github.com/openharmony/third_party_cmake.git
synced 2026-07-21 00:05:24 -04:00
cmCommand refactor: cmSiteNameCommand
This commit is contained in:
@@ -159,7 +159,7 @@ void GetScriptingCommands(cmState* state)
|
||||
cm::make_unique<cmSetDirectoryPropertiesCommand>());
|
||||
state->AddBuiltinCommand("set_property",
|
||||
cm::make_unique<cmSetPropertyCommand>());
|
||||
state->AddBuiltinCommand("site_name", cm::make_unique<cmSiteNameCommand>());
|
||||
state->AddBuiltinCommand("site_name", cmSiteNameCommand);
|
||||
state->AddBuiltinCommand("string", cm::make_unique<cmStringCommand>());
|
||||
state->AddBuiltinCommand("unset", cm::make_unique<cmUnsetCommand>());
|
||||
state->AddBuiltinCommand("while", cmWhileCommand);
|
||||
|
||||
@@ -4,19 +4,18 @@
|
||||
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
// cmSiteNameCommand
|
||||
bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus&)
|
||||
bool cmSiteNameCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.size() != 1) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> paths;
|
||||
@@ -27,12 +26,12 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
|
||||
paths.emplace_back("/sbin");
|
||||
paths.emplace_back("/usr/local/bin");
|
||||
|
||||
const char* cacheValue = this->Makefile->GetDefinition(args[0]);
|
||||
const char* cacheValue = status.GetMakefile().GetDefinition(args[0]);
|
||||
if (cacheValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* temp = this->Makefile->GetDefinition("HOSTNAME");
|
||||
const char* temp = status.GetMakefile().GetDefinition("HOSTNAME");
|
||||
std::string hostname_cmd;
|
||||
if (temp) {
|
||||
hostname_cmd = temp;
|
||||
@@ -72,7 +71,7 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
this->Makefile->AddCacheDefinition(
|
||||
status.GetMakefile().AddCacheDefinition(
|
||||
args[0], siteName.c_str(),
|
||||
"Name of the computer/site where compile is being run",
|
||||
cmStateEnums::STRING);
|
||||
|
||||
@@ -8,34 +8,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
/** \class cmSiteNameCommand
|
||||
/**
|
||||
* \brief site_name command
|
||||
*
|
||||
* cmSiteNameCommand implements the site_name CMake command
|
||||
*/
|
||||
class cmSiteNameCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
std::unique_ptr<cmCommand> Clone() override
|
||||
{
|
||||
return cm::make_unique<cmSiteNameCommand>();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when the command is first encountered in
|
||||
* the CMakeLists.txt file.
|
||||
*/
|
||||
bool InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status) override;
|
||||
};
|
||||
bool cmSiteNameCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user