mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-20 14:10:27 -06:00
cmMakefile: decouple FinalAction from cmCommand
This commit is contained in:
committed by
Regina Pfeifer
parent
d26e6cb1c2
commit
a74dad3bd3
@@ -355,6 +355,20 @@ private:
|
||||
cmMakefile* Makefile;
|
||||
};
|
||||
|
||||
class cmFinalPassAction
|
||||
{
|
||||
public:
|
||||
cmFinalPassAction(std::unique_ptr<cmCommand> command)
|
||||
: Command(std::move(command))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(cmMakefile&) { this->Command->FinalPass(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<cmCommand> Command;
|
||||
};
|
||||
|
||||
bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
@@ -417,7 +431,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||
}
|
||||
} else if (pcmd->HasFinalPass()) {
|
||||
// use the command
|
||||
this->FinalPassCommands.push_back(std::move(pcmd));
|
||||
this->AddFinalAction(cmFinalPassAction(std::move(pcmd)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -768,6 +782,11 @@ struct file_not_persistent
|
||||
};
|
||||
}
|
||||
|
||||
void cmMakefile::AddFinalAction(FinalAction action)
|
||||
{
|
||||
this->FinalActions.push_back(std::move(action));
|
||||
}
|
||||
|
||||
void cmMakefile::FinalPass()
|
||||
{
|
||||
// do all the variable expansions here
|
||||
@@ -775,8 +794,8 @@ void cmMakefile::FinalPass()
|
||||
|
||||
// give all the commands a chance to do something
|
||||
// after the file has been parsed before generation
|
||||
for (auto& command : this->FinalPassCommands) {
|
||||
command->FinalPass();
|
||||
for (FinalAction& action : this->FinalActions) {
|
||||
action(*this);
|
||||
}
|
||||
|
||||
// go through all configured files and see which ones still exist.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
@@ -30,7 +31,6 @@
|
||||
# include "cmSourceGroup.h"
|
||||
#endif
|
||||
|
||||
class cmCommand;
|
||||
class cmCompiledGeneratorExpression;
|
||||
class cmCustomCommandLines;
|
||||
class cmExecutionStatus;
|
||||
@@ -125,6 +125,13 @@ public:
|
||||
bool EnforceUniqueName(std::string const& name, std::string& msg,
|
||||
bool isCustom = false) const;
|
||||
|
||||
using FinalAction = std::function<void(cmMakefile&)>;
|
||||
|
||||
/**
|
||||
* Register an action that is executed during FinalPass
|
||||
*/
|
||||
void AddFinalAction(FinalAction action);
|
||||
|
||||
/**
|
||||
* Perform FinalPass, Library dependency analysis etc before output of the
|
||||
* makefile.
|
||||
@@ -132,7 +139,7 @@ public:
|
||||
void ConfigureFinalPass();
|
||||
|
||||
/**
|
||||
* run the final pass on all commands.
|
||||
* run all FinalActions.
|
||||
*/
|
||||
void FinalPass();
|
||||
|
||||
@@ -937,7 +944,7 @@ protected:
|
||||
size_t ObjectLibrariesSourceGroupIndex;
|
||||
#endif
|
||||
|
||||
std::vector<std::unique_ptr<cmCommand>> FinalPassCommands;
|
||||
std::vector<FinalAction> FinalActions;
|
||||
cmGlobalGenerator* GlobalGenerator;
|
||||
bool IsFunctionBlocked(const cmListFileFunction& lff,
|
||||
cmExecutionStatus& status);
|
||||
|
||||
Reference in New Issue
Block a user