[perl-ExtUtils-Depends] Doc, implement, test ::Install::Files->Inline.



commit feb1f2c39ac6532fbe03c57bf361c461c5dffbc3
Author: Ed J <mohawk2 users noreply github com>
Date:   Mon Jun 30 06:35:22 2014 +0100

    Doc, implement, test ::Install::Files->Inline.

 lib/ExtUtils/Depends.pm |   28 ++++++++++++++++++++++++++--
 t/02_save_load.t        |   13 ++++++++++++-
 2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
index 89d3365..72da6ad 100644
--- a/lib/ExtUtils/Depends.pm
+++ b/lib/ExtUtils/Depends.pm
@@ -147,6 +147,15 @@ sub save_config {
                        last;
                }
        }
+
+       sub Inline {
+               my (\$class, \$lang) = \ _;
+               if (\$lang ne 'C') {
+                       warn "Warning: Inline hints not available for \$lang language\n";
+                       return;
+               }
+               +{ map { (uc(\$_) => \$self->{\$_}) } qw(inc libs typemaps) };
+       }
 EOT
 
        print $file "\n1;\n";
@@ -451,6 +460,20 @@ For example:
      this command automatically brings in all the stuff needed
      for Glib, since Gtk2 depends on it.
 
+When the configuration information is saved, it also includes a class
+method called C<Inline>, inheritable by your module. This allows you in
+your module to simply say at the top:
+
+  package Mymod;
+  use parent 'Mymod::Install::Files'; # to inherit 'Inline' method
+
+And users of C<Mymod> who want to write inline code (using L<Inline>)
+will simply be able to write:
+
+  use Inline with => 'Mymod';
+
+And all the necessary header files, defines, and libraries will be added
+for them.
 
 =head1 METHODS
 
@@ -513,8 +536,9 @@ passed through WriteMakefile's PM key.
 Save the important information from I<$depends> to I<$filename>, and
 set it up to be installed as I<name>::Install::Files.
 
-Note: the actual value of I<$filename> seems to be irrelevant, but its
-usage is kept for backward compatibility.
+Note: the actual value of I<$filename> is unimportant so long as it
+doesn't clash with any other local files. It will be installed as
+I<name>::Install::Files.
 
 =item hash = $depends->get_makefile_vars
 
diff --git a/t/02_save_load.t b/t/02_save_load.t
index c68fa3f..3e6c4b1 100644
--- a/t/02_save_load.t
+++ b/t/02_save_load.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 28;
+use Test::More tests => 29;
 
 use FindBin;
 use lib "$FindBin::Bin/lib";
@@ -106,4 +106,15 @@ is_deeply (\ DepTest::Install::Files::deps, []);
 is ($DepTest::Install::Files::libs, $libs);
 }
 
+# test Inline class method
+is_deeply (
+  DepTest::Install::Files->Inline('C'),
+  {
+    INC => $inc,
+    LIBS => $libs,
+    TYPEMAPS => \ typemaps_expected,
+  },
+  'api check Inline method'
+);
+
 # --------------------------------------------------------------------------- #


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]