RE: Make vs. Perl
by Fastolfe (Vicar) on Nov 15, 2000 at 21:44 UTC
|
If you're looking for generic dependency-handling code (there are Perl implementations of 'make' I believe; don't re-invent the wheel), something recursive like this might work for you:
my %dependencies = (
item1 => [ 'item2' ],
item2 => [ qw' item3 item4 ' ],
);
my %done;
sub act_on {
my $item = shift;
$done{$item} = undef; # mark it early to avoid circular dependen
+cies
if (exists $dependencies{$item}) {
foreach my $dep (@{$dependencies{$item}}) {
warn "Circular dependency $item => $dep"
if exists $done{$dep} and !$done{$dep};
&act_on($dep) unless exists $done{$dep};
}
}
# Dependencies satisfied, do whatever on $item
print "Doing $item...\n";
$done{$item} = 1; # really done
}
act_on "item1";
Doing item3...
Doing item4...
Doing item2...
Doing item1...
Change the function name around if you like to make it more idiomatic if that's what you're looking for... | [reply] [d/l] |
RE: Make vs. Perl
by knight (Friar) on Nov 15, 2000 at 22:23 UTC
|
Nick Ing-Simmons wrote pmake,
a Perl implementation of make.
I don't know where to find it;
a manual CPAN search
didn't turn up anything,
and there's another same-named "pmake" out there
that's a parallel-implementation of make
which returns more Google hits.
Update:It uses the Make.pm module,
which is available on CPAN.
Cons
is a more "purely Perl" make substitute.
The configuration files are Perl scripts
that call an API to establish targets and dependencies.
Dependency analysis and builds are all carried out by
a single top-level executable,
not through recursive invocation of the tool.
makepp
(a.k.a. make++)
is a Perl re-implementation of make
that preserves Makefile syntax,
but uses the Cons build-engine model
of a single top-level process.
Lastly,
Rich Miller created a utility named
"perlmake" for IDX Systems Corp.,
but I don't think it's been publicly released.
| [reply] |
|
What about a module that gives me a make interface I can
use from a script that does other things. I guess I could
just do a system("make $foo") or "cons $foo" or whatever,
but I was hoping for a module with a real API to set up
dependancies and then fullfill them. I suppose
this is what you're talking about. I'll take a look at
that. I was hoping for something that wasn't so inbred with
Make's horrendous syntax for pattern matching and whatnot...
-Ted
| [reply] |
|
Cons has been talking for a long time about
moving to an architecture like you're describing--a
modular build engine to manage dependencies,
with plug-in modules for various dependency scanners,
compile tools, etc.
The consensus among that community is that
itwould be a Good Thing,
but no one has actually had time
or energy to go ahead and do it.
I agree completely about the hassles arising
from Make.pm being so closely tied to Make's syntax.
I'm not sure what you want to do in Perl
that you couldn't do within a Cons config file itself,
since it's just a Perl script.
You shouldn't need to do a separate system("cons $foo").
| [reply] |
RE: Make vs. Perl
by clemburg (Curate) on Nov 15, 2000 at 22:23 UTC
|
See Cons, also covered in "Cons: A Software Construction System" - The Perl Journal, Spring 1998. This is what you want, I think.
There is also pmake, but I think this is not what you want, since it merely emulates make in Perl.
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
| [reply] |
RE: Make vs. Perl
by merlyn (Sage) on Nov 15, 2000 at 21:40 UTC
|
| [reply] |
|
updatemerlyn fixed the above, you can ignore this now : )
after looking at the source for the node (which looked pretty funny) I think merlyn meant to say:
"See this or that for "make-in-Perl" solutions."
where this and that are my words placed between the <A href="... tags that merlyn supplied. I simply added those words and so the links would show up(they look useful). I did not change any other content. If I in any way altered the intent or meaning of the post please let me know.
update: I lied. I did change the content. I forgot to mention that i changed the code in the first link to query CPAN for make not pmake, as pmake gave no results and make gave plenty of relevant ones...again, seemed to be a typo...
<myExperience>
$mostLanguages = 'Designed for engineers by engineers.';
$perl = 'Designed for people who speak by a linguist.';
</myExperience>
| [reply] [d/l] [select] |
|
| [reply] |