Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

User-side module building with ExtUtils::MakeMaker

by merkys (Initiate)
on Feb 21, 2020 at 12:18 UTC ( #11113307=perlquestion: print w/replies, xml ) Need Help??

merkys has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am interested in autogenerating Perl modules for my distribution during user-side builds. To be precise, I have a Parse::Yapp-driven module, which I want to build on the user's side (motivation: 1. the parser is too huge to include it in the source distribution, 2. SPOT/DRY). To build the module on the user-side, I add the following to WriteMakefile of Makefile.PL (using ExtUtils::MakeMaker):
depend => { pm_to_blib => 'blib/lib/OPTiMaDe/Filter/Parser.pm' },
and, at the end of the Makefile.PL:
sub MY::postamble { <<'EOT' blib/lib/OPTiMaDe/Filter/%.pm: %.yp mkdir --parents $(@D) yapp -v -m OPTiMaDe::Filter::Parser -o $@ $< EOT }
However, CPAN Testers run into a variety of troubles, from inability to find the rules to make the dependency, to 'yapp' not being found, and mkdir not working (mainly Windows). My question: is there a standard way to write plugins for ExtUtils::MakeMaker (Dist::Zilla or any other equivalent) to produce Perl modules on the client side?

Replies are listed 'Best First'.
Re: User-side module building with ExtUtils::MakeMaker
by pryrt (Prior) on Feb 21, 2020 at 14:52 UTC
    instead of hardcoding the mkdir command, which isn't known on all systems, use the $(MKPATH) from ExtUtils::MakeMaker's Makefile, which calls mkpath. As a side benefit, mkpath automatically generates necessary parents as well, so you don't need the --parents argument.

    sub MY::postamble { <<'EOT' blib/lib/OPTiMaDe/Filter/%.pm: %.yp $(MKPATH) (@D) yapp -v -m OPTiMaDe::Filter::Parser -o $@ $< EOT }
Re: User-side module building with ExtUtils::MakeMaker
by thomas895 (Deacon) on Feb 22, 2020 at 12:26 UTC

    Perhaps you can include the generated parser, like how it's done in Verilog::Parser? There's still the original sources included for those who would like to hack on it; in that case you need flex/bison.

    In particular, to address the question of the makefile, look here for inspiration

    -Thomas
    "Excuse me for butting in, but I'm interrupt-driven..."
Re: User-side module building with ExtUtils::MakeMaker
by Anonymous Monk on Feb 21, 2020 at 13:04 UTC

    if you insist on making users generate Use PL_FILES

    Which make? Nmake? Dmake? Gmake? Mingw32-make?... Avoid postamble

    also there is no source code too big to include

    also including the source is equally SPOT/DRY

      also including the source is equally SPOT/DRY

      I did a super search and a google search of what SPOT/DRY betoken and didn't find anything.

        Don't Repeat Yourself for that one; from context then maybe Single Point Of Truth ?

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11113307]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2020-04-07 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (42 votes). Check out past polls.

    Notices?