Hi Zefram,
It seems that this is a somewhat unexplored territory.
# from Zefram
# on Monday 17 September 2007 03:00:
>In my attempt at this so far, I've overridded M::B::compile_c (in a
>subclass),
I see you're using the subclass() method and do($file). This might be
more readable if you just put it all in a subclass in inc/MyBuilder.pm
and "use lib 'inc'".
Also, I think you might want to override ACTION_code(). Is there a
reason to have it in compile_c() ? That is, it looks like the "only
once" logic attached to no_feature_defs wouldn't be needed in
ACTION_code().
>so that it'll run the tests, add the feature definitions
>to its arguments, and pass the modified arguments on to the original
>compile_c method.
It seems to be creating all of the C code on the fly, so I think
ACTION_code() would be the way to handle this. As for overriding the
arguments to compile_c(), maybe that still requires an override, but
the %args could be lexical or an object attribute (gathered in
ACTION_code()) ad then your compile_c() is only a couple lines.
> ... with the linking part ... I call $self->_cbuilder
>to get the ExtUtils::CBuilder object, then call ->link_executable on
>that.... This works, but obviously I'm relying on an internal method
>of Module::Build.
You could "get your own", though I'm not really sure why _cbuilder()
shouldn't be public. Ken? If anything, maybe we just make sure it
throws an exception:
sub cbuilder {
my $self = shift;
my $builder = $self->_cbuilder or die "no c support";
return($builder);
}
I think overriding ACTION_code() will clean things up a lot.
sub ACTION_code {
my $self = shift;
$self->__probe_defs;
$self->SUPER::ACTION_code(@_);
}
If you run into difficulties implementing __probe_defs(), or can make
that generic enough to make it part of the M::B API, I would like to
hear about it. I imagine most of the prior examples are a bunch of
hand-rolled variations with MakeMaker, but I can't think of anything at
the moment.
--Eric
--
We who cut mere stones must always be envisioning cathedrals.
--Quarry worker's creed
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------