diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2021-11-14 01:19:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-11-18 17:02:37 (GMT) |
commit | 90e1206f253c0acbef37668403133585a31b2a92 (patch) | |
tree | 16a2265d0bf1032f9720adc350e865655efffa5d /Source | |
parent | 9b31a977481ea07c979549246ee46946e9978e08 (diff) | |
download | CMake-90e1206f253c0acbef37668403133585a31b2a92.zip CMake-90e1206f253c0acbef37668403133585a31b2a92.tar.gz CMake-90e1206f253c0acbef37668403133585a31b2a92.tar.bz2 |
cmMakefile: Introduce GeneratorAction as the class.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 10 | ||||
-rw-r--r-- | Source/cmMakefile.h | 27 |
2 files changed, 32 insertions, 5 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e376323..e84e474 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -891,12 +891,18 @@ struct file_not_persistent }; } -void cmMakefile::AddGeneratorAction(GeneratorAction action) +void cmMakefile::AddGeneratorAction(GeneratorAction&& action) { assert(!this->GeneratorActionsInvoked); this->GeneratorActions.emplace_back(std::move(action), this->Backtrace); } +void cmMakefile::GeneratorAction::operator()(cmLocalGenerator& lg, + const cmListFileBacktrace& lfbt) +{ + Action(lg, lfbt); +} + void cmMakefile::DoGenerate(cmLocalGenerator& lg) { // do all the variable expansions here @@ -904,7 +910,7 @@ void cmMakefile::DoGenerate(cmLocalGenerator& lg) // give all the commands a chance to do something // after the file has been parsed before generation - for (const BT<GeneratorAction>& action : this->GeneratorActions) { + for (auto& action : this->GeneratorActions) { action.Value(lg, action.Backtrace); } this->GeneratorActionsInvoked = true; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c29fb00..75412d7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -140,13 +140,34 @@ public: bool EnforceUniqueName(std::string const& name, std::string& msg, bool isCustom = false) const; - using GeneratorAction = - std::function<void(cmLocalGenerator&, const cmListFileBacktrace&)>; + class GeneratorAction + { + using ActionT = + std::function<void(cmLocalGenerator&, const cmListFileBacktrace&)>; + + public: + GeneratorAction(ActionT&& action) + : Action(std::move(action)) + { + } + + void operator()(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt); + + private: + ActionT Action; + }; /** * Register an action that is executed during Generate */ - void AddGeneratorAction(GeneratorAction action); + void AddGeneratorAction(GeneratorAction&& action); + + /// Helper to insert the constructor GeneratorAction(args...) + template <class... Args> + void AddGeneratorAction(Args&&... args) + { + AddGeneratorAction(GeneratorAction(std::move(args)...)); + } /** * Perform generate actions, Library dependency analysis etc before output of |