Makefile::Parser 0.11 review

Download
by rbytes.net on

Makefile::Parser is a Simple Parser for Makefiles. SYNOPSIS use Makefile::Parser; $parser = Makefile::Parser->new;

License: Perl Artistic License
File size: 18K
Developer: Agent Zhang
0 stars award from rbytes.net

Makefile::Parser is a Simple Parser for Makefiles.

SYNOPSIS

use Makefile::Parser;

$parser = Makefile::Parser->new;

# Equivalent to ->parse('Makefile');
$parser->parse or
die Makefile::Parser->error;

# Get last value assigned to the specified variable 'CC':
print $parser->var('CC');

# Get all the variable names defined in the Makefile:
@vars = $parser->vars;
print join(' ', sort @vars);

@roots = $parser->roots; # Get all the "root targets"
print $roots[0]->name;

@tars = $parser->targets; # Get all the targets
$tar = join("n", $tars[0]->commands);

# Get the default target, say, the first target defined in Makefile:
$tar = $parser->target;

$tar = $parser->target('install');
# Get the name of the target, say, 'install' here:
print $tar->name;

# Get the dependencies for the target 'install':
@depends = $tar->depends;

# Access the shell command used to build the current target.
@cmds = $tar->commands;

# Parse another file using the same Parser object:
$parser->parse('Makefile.old') or
die Makefile::Parser->error;

# Get the target who is specified by variable EXE_FILE
$tar = $parser->target($parser->var('EXE_FILE'));

This is a parser for Makefiles. At this very early stage, the parser only supports a limited set of features, so it may not recognize some advanced features provided by certain make tools like GNU make. Its initial purpose is to provide basic support for another module named Makefile::GraphViz, which is aimed to render the building process specified by a Makefile using the amazing GraphViz library. The Make module is not satisfactory for this purpose, so I decided to build one of my own.

Requirements:
Perl

Makefile::Parser 0.11 keywords