1Makefile::AST::EvaluatoUrs(e3r)Contributed Perl DocumentMaatkieofnile::AST::Evaluator(3)
2
3
4

NAME

6       Makefile::AST::Evaluator - Evaluator and runtime for Makefile::AST
7       instances
8

SYNOPSIS

10           use Makefile::AST::Evaluator;
11
12           $Makefile::AST::Evaluator::JustPrint = 0;
13           $Makefile::AST::Evaluator::Quiet = 1;
14           $Makefile::AST::Evaluator::IgnoreErrors = 1;
15           $Makefile::AST::Evaluator::AlwaysMake = 1;
16           $Makefile::AST::Evaluator::Question = 1;
17
18           # $ast is a Makefile::AST instance:
19           my $eval = Makefile::AST::Evaluator->new($ast);
20
21           Makefile::AST::Evaluator->add_trigger(
22               firing_rule => sub {
23                   my ($self, $rule, $ast_cmds) = @_;
24                   my $target = $rule->target;
25                   my $colon = $rule->colon;
26                   my @normal_prereqs = @{ $rule->normal_prereqs };
27                   # ...
28               }
29           );
30           $eval->set_required_target($user_makefile)
31           $eval->make($goal);
32

DESCRIPTION

34       This module implementes an evaluator or a runtime for makefile ASTs
35       represented by Makefile::AST instances.
36
37       It "executes" the specified GNU make AST by the GNU makefile semantics.
38       Note that, "execution" not necessarily mean building a project tree by
39       firing makefile rule commands. Actually you can defining your own
40       triggers by calling the add_trigger method. (See the "SYNOPSIS" for
41       examples.) In other words, you can do more interesting things like
42       plotting the call path tree of a Makefile using Graphviz, or
43       translating the original makefile to another form (like what the
44       makesimple script does).
45
46       It's worth mentioning that, most of the construction algorithm for
47       topological graph s (including implicit rule application) have already
48       been implemented in Makefile::AST and its child node classes.
49

CONFIGURE VARIABLES

51       This module provides several package variables (i.e. static class
52       variables) for controlling the behavior of the evaluator.
53
54       Particularly the user needs to set the $AlwaysMake variable to true and
55       $Question to true, if she wants to use the evaluator to do special
56       tasks like plotting dependency graphs and translating GNU makefiles to
57       other format.
58
59       Setting $AlwaysMake to true will force the evaluator to ignore the
60       timestamps of external files appeared in the makefiles while setting
61       $Question to true will prevent the evaluator from executing the shell
62       commands specified in the makefile rules.
63
64       Here's the detailed listing for all the config variables:
65
66       $Question
67           This variable corresponds to the command-line option "-q" or
68           <--question> in GNU make. Its purpose is to make the evaluator
69           enter the "questioning mode", i.e., a mode in which "make" will
70           never try executing rule commands unless it has to, "and" echoing
71           is suppressed at the same time.
72
73       $AlwaysMake
74           This variable corresponds to the command-line option "-B" or
75           "--always-make". It forces re-constructing all the rule's targets
76           related to the goal, ignoring the timestamp or existence of
77           targets' dependencies.
78
79       $Quiet
80           It corresponds to GNU make's command-line option "-s", "--silent",
81           or "--quiet". Its effect is to cancel the echoing of shell commands
82           being executed.
83
84       $JustPrint
85           This variable corresponds to GNU make's command line option "-n",
86           "--just-print", "--dry-run", or "--recon". Its effect is to print
87           out the shell commands requiring execution but without actually
88           executing them.
89
90       $IgnoreErrors
91           This variable corresponds to GNU make's command line option "-i" or
92           "--ignore-errors"ieXXIt's used to ignore the errors of shell
93           commands being executed during the make process. The default
94           behavior is quitting as soon as a shell command without the "-"
95           modifier fails.
96

CLASS TRIGGERS

98       The "make_by_rule" method of this class defines a trigger named
99       "firing_rule" via the Class::Trait module. Everytime the "make_by_rule"
100       method reaches the trigger point, it will invoke the user's processing
101       handler with the following three arguments: the self object, the
102       Makefile::AST::Rule object, and the corresponding
103       "Makefile::AST::Command" object in the context.
104
105       By registering his own processing handlers for the "firing_rule"
106       trigger, the user's code can reuse the evaluator to do his own cool
107       things without traversing the makefile ASTs himself.
108
109       See the "SYNOPSIS" for code examples.
110

SVN REPOSITORY

112       For the very latest version of this script, check out the source from
113
114       http://svn.openfoundry.org/makefileparser/branches/gmake-db
115       <http://svn.openfoundry.org/makefileparser/branches/gmake-db>.
116
117       There is anonymous access to all.
118

AUTHOR

120       Agent Zhang "<agentzh@yahoo.cn>"
121
123       Copyright (c) 2007-2008 by Agent Zhang (agentzh).
124
125       This library is free software; you can redistribute it and/or modify it
126       under the same terms as Perl itself.
127

SEE ALSO

129       Makefile::AST, Makefile::Parser::GmakeDB, pgmake-db, makesimple,
130       Makefile::DOM.
131
132
133
134perl v5.12.0                      2008-03-16       Makefile::AST::Evaluator(3)
Impressum