From a94dcda7f00b10cb22b5f2138b1c29bcfbe7de37 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Mar 2015 08:53:06 +0200 Subject: Make meta-operations control build loop; add disfigure skeleton --- build/operation | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'build/operation') diff --git a/build/operation b/build/operation index 3469f21..c759d59 100644 --- a/build/operation +++ b/build/operation @@ -7,13 +7,19 @@ #include #include +#include #include #include // reference_wrapper +#include #include namespace build { + struct location; + class scope; + struct target_key; + // While we are using uint8_t for the meta/operation ids, we assume // that each is limited to 4 bits (max 128 entries) so that we can // store the combined action id in uint8_t as well. This makes our @@ -104,17 +110,76 @@ namespace build // enum class execution_mode {first, last}; - // Meta/operation info. + // Meta-operation info. + // + + // Normally a list of resolved and matched targets to execute. But + // can be something else, depending on the meta-operation. // + typedef std::vector action_targets; + struct meta_operation_info { const std::string name; + + void (*meta_operation_pre) (); // Start of meta-operation batch. + operation_id (*operation_pre) (operation_id); // Start of operation batch. + + // Meta-operation-specific logic to load the buildfile, resolve and match + // the targets, and execute the action on the targets. + // + void (*load) (const path& buildfile, + scope& root, + const path& out_base, + const path& src_base, + const location&); + + void (*match) (action, + const target_key&, + const location&, + action_targets&); + + void (*execute) (action, const action_targets&); + + void (*operation_post) (operation_id); // End of operation batch. + void (*meta_operation_post) (); // End of meta-operation batch. }; // Built-in meta-operations. // + + // perform + // + + // Load the buildfile. This is the default implementation that first + // calls root_pre(), then creates the scope for out_base, and, finally, + // loads the buildfile unless it has already been loaded for the root + // scope. + // + void + load (const path& buildfile, + scope& root, + const path& out_base, + const path& src_base, + const location&); + + // Resolve and match the target. This is the default implementation + // that does just that and adds a pointer to the target to the list. + // + void + match (action, const target_key&, const location&, action_targets&); + + // Execute the action on the list of targets. This is the default + // implementation that does just that while issuing appropriate + // diagnostics. + // + void + execute (action, const action_targets&); + extern meta_operation_info perform; + // Operation info. + // struct operation_info { const std::string name; -- cgit v1.1