NAME
File::Maker - mimics a make by loading a database and calling targets methods
SYNOPSIS
#####
# Subroutine interface
#
use File::Maker qw(load_db);
\%data = load_db($pm);
######
# Object interface
#
require File::Maker;
$maker = $maker->load_db($pm);
$maker->make_targets(\%targets, @targets, \%options );
$maker->make_targets(\%targets, \%options );
$maker = new File::Maker(@options);
Generally, if a subroutine will process a list of options, @options
, that subroutine will also process an array reference, \@options
, [@options]
, or hash reference, \%options
, {@options}
. If a subroutine will process an array reference, \@options
, [@options]
, that subroutine will also process a hash reference, \%options
, {@options}
. See the description for a subroutine for details and exceptions.
DESCRIPTION
When porting low level C code from one architecture to another, makefiles do provide some level of automation and save some time. However, once Perl or another high-level language is up and running, the high-level language usually allows much more efficient use of programmers time; otherwise, whats point of the high-level language. Thus, makes great economically sense to switch from makefiles to high-level language.
The File::Maker
program module provides a "make" style interface as shown in the herein above. The @targets
contains a list of targets that mimics the targets of a makefile
. The targets are subroutines written in Perl in a separate program module from the File::Maker
. The separate target program module inherits the methods in the File::Maker
program module as follows:
use File::Maker;
use vars qw( @ISA );
@ISA = qw(File::Maker);
The File::Maker
methods will then find the target subroutines in the separate target program module.
The File::Maker
provides for the loading of a hash from a program module to provide for the capabilities of defines
in a makefile
. The option pm =
$file> tells File::Maker
to load a database from the __DATA__ section of a program module that is in the Tie::Form format. The Tie::Form
format is a very flexible lenient format that is about as close to a natural language form and still have the precision of being machine readable. This provides a more flexible alternative to the defines in a makefile
. The define hash is in a separate, very flexible form program module. This arrangement allows one target program module that inherits the File::Maker
program module to produce as many different outputs as there are Tie::Form program modules.
METHODS
load_db
\%data = load_db($pm);
$maker = $maker->load_db($pm);
The load_db
subroutine loads the __DATA__
of $pm
using Tie::Form
progrma module. The results are return as a hash. If called as a object, the objec $maker
have hash data. The return keys are as follows:
key description
--------------------------------------------------------------
FormDB_File the absoute file of $pm
FormDB_PM $pm
FormDB_Record __DATA__ section of $pm
FormDB ordered name,value pairs of __DATA__ section
make_targets
$maker->make_targets(\%targets, @targets);
$maker->make_targets(\%targets, @targets, \%options);
$maker->make_targets(\%targets);
$maker->make_targets(\%targets, \%options);
The make_targets
subroutine executes the @targets
in order after substituing an expanded list $target[$targets[$i]}
list if it exists, as follows:
$result = $self->$target[$i]( @args )
The @args
do not exists unless the $taget[$i]
is itself an array reference in which case the make_targets
subroutine assumes the array referenced is
[$target, @args]
The return $result
may be a reference to an object, usually the same class as the original $result, or a $success
flag of 1 or undef. If $result
is a reference, the make_targets
subroutine will set <$self> to the new object $result
. Thus, by returning an reference, a target may pass data to the next targe or even change the class of $self
.
new
$maker = new File::Maker(@options);
$maker = new File::Maker(\@options);
$maker = new File::Maker(\%options);
The new
subroutine returns an object whose object data is a hash reference of @options
.
REQUIREMENTS
Some day.
DEMONSTRATION
#########
# perl Maker.d
###
~~~~~~ Demonstration overview ~~~~~
The results from executing the Perl Code follow on the next lines as comments. For example,
2 + 2
# 4
~~~~~~ The demonstration follows ~~~~~
use File::Package;
my $fp = 'File::Package';
my $loaded = '';
use File::SmartNL;
my $snl = 'File::SmartNL';
use File::Spec;
my @inc = @INC;
##################
# Load UUT
#
my $errors = $fp->load_package( '_Maker_::MakerDB' )
$errors
# ''
#
$snl->fin(File::Spec->catfile('_Maker_','MakerDB.pm'))
# '#!perl
# package _Maker_::MakerDB;
# use strict;
# use warnings;
# use warnings::register;
# use vars qw($VERSION $DATE $FILE );
# $VERSION = '0.01';
# $DATE = '2004/05/10';
# $FILE = __FILE__;
# use File::Maker;
# use vars qw( @ISA );
# @ISA = qw(File::Maker);
# ######
# # Hash of targets
# #
# my %targets = (
# all => [ qw(target1 target2) ],
# target3 => [ qw(target1 target3) ],
# target4 => [ qw(target1 target2 target4) ],
# __no_target__ => [ qw(target3 target4 target5) ],
# );
# my $data = '';
# sub make
# {
# my $self = shift @_;
# $self->make_targets( \%targets, @_ );
# my $result = $data;
# $data = '';
# $result
# }
# sub target1
# {
# $data .= ' target1 ';
# 1
# }
# sub target2
# {
# $data .= ' target2 ';
# 1
# }
# sub target3
# {
# $data .= ' target3 ';
# 1
# }
# sub target4
# {
# $data .= ' target4 ';
# 1
# }
# sub target5
# {
# $data .= ' target5 ';
# 1
# }
# 1
#__DATA__
#Revision: -^
#End_User: General Public^
#Author: http://www.SoftwareDiamonds.com support@SoftwareDiamonds.com^
#Version: ^
#Classification: None^
#~-~
#'
#
##################
# No target
#
my $maker = new _Maker_::MakerDB( pm => '_Maker_::MakerDB' )
$maker->make( )
# ' target1 target2 '
#
##################
# FormDB_File
#
$maker->{FormDB_File}
# 'E:\User\SoftwareDiamonds\installation\t\File\_Maker_\MakerDB.pm'
#
##################
# FormDB_PM
#
$maker->{FormDB_PM}
# '_Maker_::MakerDB'
#
##################
# FormDB_Record
#
$maker->{FormDB_Record}
# '
#Revision: -^
#End_User: General Public^
#Author: http://www.SoftwareDiamonds.com support@SoftwareDiamonds.com^
#Version: ^
#Classification: None^
#~-~
#'
#
##################
# FormDB
#
$maker->{FormDB}
# [
# 'Revision',
# '-',
# 'End_User',
# 'General Public',
# 'Author',
# 'http://www.SoftwareDiamonds.com support@SoftwareDiamonds.com',
# 'Version',
# '',
# 'Classification',
# 'None'
# ]
#
##################
# Target all
#
$maker->make( 'all' )
# ' target1 target2 '
#
##################
# Unsupport target
#
$maker->make( 'xyz' )
# ' target3 target4 target5 '
#
##################
# target3
#
$maker->make( 'target3' )
# ' target1 target3 '
#
##################
# target3 target4
#
$maker->make( qw(target3 target4) )
# ' target1 target3 target1 target2 target4 '
#
##################
# Include stayed same
#
[@INC]
# [
# 'E:\User\SoftwareDiamonds\installation\t\File\lib',
# 'E:/User/SoftwareDiamonds/installation/t/File',
# 'E:\User\SoftwareDiamonds\installation\lib',
# 'D:/Perl/lib',
# 'D:/Perl/site/lib',
# '.'
# ]
#
QUALITY ASSURANCE
Running the test script Maker.t
verifies the requirements for this module. The tmake.pl
cover script for Test::STDmaker automatically generated the Maker.t
test script, Maker.d
demo script, and t::File::Maker
STD program module POD, from the t::File::Maker
program module contents. The tmake.pl
cover script automatically ran the Maker.d
demo script and inserted the results into the 'DEMONSTRATION' section above. The t::File::Maker
program module is in the distribution file File-Maker-$VERSION.tar.gz.
NOTES
Author
The holder of the copyright and maintainer is
<support@SoftwareDiamonds.com>
Copyright Notice
Copyrighted (c) 2002 Software Diamonds
All Rights Reserved
Binding Requirements Notice
Binding requirements are indexed with the pharse 'shall[dd]' where dd is an unique number for each header section. This conforms to standard federal government practices, STD490A 3.2.3.6. In accordance with the License, Software Diamonds is not liable for any requirement, binding or otherwise.
License
Software Diamonds permits the redistribution and use in source and binary forms, with or without modification, provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Commercial installation of the binary or source must visually present to the installer the above copyright notice, this list of conditions intact, that the original source is available at http://softwarediamonds.com and provide means for the installer to actively accept the list of conditions; otherwise, a license fee must be paid to Softwareware Diamonds.
SOFTWARE DIAMONDS, http://www.softwarediamonds.com, PROVIDES THIS SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.