View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Daniel Pfeiffer > makepp > Mpp::Rule



Annotate this POD


View/Report Bugs


Rule -- Stores information about a build rule


  my $rule = new Mpp::Rule "targets", "dependencies",
    "command"[, $makefile, $makefile_line];


A rule object contains all the information necessary to make a specific file.

$makefile is a pointer to the structure returned by load_makefile. $makefile_line is an ASCII string that is used if an error message occurs while expanding variables in this rule.

This does not actually place the rule into the Mpp::File hierarchy.


   $real_tag = $rule->get_tagname($tag)

Returns a unique tag name for $tag. See "load_scaninfo".

Since a rule can have multiple commands with the same include tag, the requested tag might not match the actual tag that gets returned.


   $rule->add_include_dir($real_tag, $dirname);

Add an include directory for scanner caching. See "load_scaninfo".

$dirname is a name relative to build_cwd.


   $rule->add_include_suffix($real_tag, $suffix);

Add an include suffix list for scanner caching. See "load_scaninfo".


   $rule->add_meta_dependency($real_tag, $src, $name, $finfo);

Add an include file for scanner caching. Return value is TRUE iff the meta dependency failed to build. See "load_scaninfo".

$name is the requested name relative to the directory named by $src (relative to the build directory). If $real_tag is undef, then it is treated as a path including only ".". $src is ignored if $name is an absolute path or none of the directories in the include path are undefined. If $src is undef, then the build directory is used.

The return value is zero on success (including if the file could not be found), nonzero on build failure.


   $rule->add_implicit_dependency($real_tag, $src, $name, $finfo);

Add a dependency file for scanner caching. See "load_scaninfo".

This works just like add_meta_dependency, except that the rule doesn't have to be re-scanned by virtue of an implicit dependency being out of date.



Add a target file for scanner caching. See "load_scaninfo".



Add an environmental dependency for scanner caching. See "load_scaninfo".


   $rule->set_signature_class($name, $implicit, $method)

Look up and cache the signature method. If $implicit don't replace a previously set one (when reading meta data). If $method is given, skip look up.



Prohibit the rule from caching its scanner information. This is useful when the information gathered by one of the scanners that gets involved doesn't fit into the caching scheme, and that could cause build inaccuracies.



Set build_info_string's for scanner caching for each of @targets. See "load_scaninfo".

Once transferred to the build_info cache, the information is deleted from $rule, in order to save memory.


   $rule->load_scaninfo($tinfo, $command_string, $explicit_dependencies);

Attempt to get all the scanned information about $rule from $tinfo's build info file. If this fails for whatever reason, including the scaninfo possibly being out of date, then the reason is returned, and $rule is left in its original state. This typically means that it must be re-scanned from scratch. Otherwise, 0 is returned.

$rule->execute($command_string, $all_targets, $all_dependencies)

   $handle = $rule->execute($command_string, $all_targets, $all_dependencies);

Executes the given command string, and returns a handle for the executing process (which may not have finished by the time we return). The command string may contain several shell commands separated by newlines.

This is part of the Rule class so the default execute routine can be overridden. You can replace the execute routine with any complicated operation you want, provided it returns the appropriate kind of handles.


Print out a command instead of executing it. This is used only when we are running with -n (dry run mode).


Add the targets and commands from another rule to this rule. This is used only when grokking double colon rules like this:

       $(RM) *.o

   # Later in the makefile:


Sets up the environment for the rule's makefile.



Gets the build check method for this particular rule.



Sets the build check method to be the given method.


  my $sig_method = $rule->signature_method;

Returns the signature method to use to calculate signatures for files.

The default method is the file time + file size (see Mpp/ for details).



Returns the rule lexer object, creating it if it doesn't already exist.


  $source_string = $rule->source;

Returns a description of where this rule was encountered, suitable for error messages.

syntax highlighting: