# from Marvin Humphrey
# on Sunday 08 October 2006 11:31 pm:

>> An automatic error during "./Build dist" is the strong remedy.

>To follow the automagic-add approach out ad absurdum, should it ?
>automatically detect that you need other things besides CBuilder?

Maybe.  But, we're talking about compilers.  And, given that it 
currently only knows how to operate a C compiler, that's probably going 
to be some sort of build_requires entry anyway.  As for "other things", 
this is something that *Module::Build* needs, which is a rather finite 
list (the infinite set of possibilities stems from the requirements of 
your custom build class and presumably declared as such.)

BTW, how does "add an automagic dependency" differ from your prior 
request for "a stiff slap on the hand" WRT ad absurdum?  I'll wager you 
a tray of pitchers that C, XS, and CPP covers about 98% of the "needs 
compilin'" code on cpan (maybe excluding that which has an explicit 
dependency on /^Inline::/.)  Given that those in the minority typically 
have had to struggle quite a lot to get that far, they can probably 
figure out how to finagle the dependencies.  Also, taking into account 
the long-tail nature of lisp-based extensions vs smalltalk-based ones, 
maybe this crowd can't benefit all that much from any assistance and/or 
discipline dispensed by MB.

>?And no matter how
> elaborate the guessing apparatus, it'll guess wrong some of the
> time... so there will have to be an override mechanism.

Quite true.  And the same will be required to disable that annoying 
incorrectly-placed-but-well-meant slap on the hand.

>>> Answer:  Module::Build should provide some mechanism for the
>>> author to declare "yes, I know I have XS files, but the build
>>> doesn't absolutely require a compiler.

In Base.pm:

  sub ACTION_distmeta {
    my ($self) = @_;

+   $self->_check_implicit_deps;
    $self->do_create_makefile_pl if $self->create_makefile_pl;
  ...

  # name this whatever you like
  sub _check_implicit_deps {
    my $self = shift;

    # just use the same condition as check_prereq
    if($self->find_xs_files) {
      unless(
        eval { $self->does_not_require_compiler } or
        defined($self->build_requires('ExtUtils::CBuilder'))
      ) {
        $self->build_requires('ExtUtils::CBuilder' => 0.18)
      }
    }
  } # end sub

And in your build class:

  use constant {does_not_require_compiler => 1};

Caveats:
  * for clarity, should that be does_not_require_cbuilder() ?

I'm sure there's a handier way to do that that doesn't require you to 
subclass, but we're really only talking about Adam here, right?  (JK 
Adam.)  Point is, by the time you're providing pure-perl or 
pre-compiled code as an alternative to XS, you've probably already got 
your own build class started.

And, remember that the overall goal here ("here" being somewhere in 
Beaverton, though I hope the sister cities are roughly aligned) is to 
"do the right thing" often enough to eliminate "Module::Build ate my 
afternoon/computer" e-mail from the list while not getting in the 
author's way without a good reason.

Finally, if "slap me on the hand" is really the right thing to do, the 
only difference is:

-        $self->build_requires('ExtUtils::CBuilder' => 0.18)
+        die("Bad author!  Your poor users need a compiler.");

--Eric
-- 
You can't whack a chisel without a big wooden mallet.
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to