r68043 - in /branches/upstream/libextutils-cchecker-perl/current: Changes LICENSE META.yml README lib/ExtUtils/CChecker.pm

periapt-guest at users.alioth.debian.org periapt-guest at users.alioth.debian.org
Sat Jan 29 22:45:54 UTC 2011


Author: periapt-guest
Date: Sat Jan 29 22:45:47 2011
New Revision: 68043

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=68043
Log:
[svn-upgrade] new version libextutils-cchecker-perl (0.06)

Modified:
    branches/upstream/libextutils-cchecker-perl/current/Changes
    branches/upstream/libextutils-cchecker-perl/current/LICENSE
    branches/upstream/libextutils-cchecker-perl/current/META.yml
    branches/upstream/libextutils-cchecker-perl/current/README
    branches/upstream/libextutils-cchecker-perl/current/lib/ExtUtils/CChecker.pm

Modified: branches/upstream/libextutils-cchecker-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-cchecker-perl/current/Changes?rev=68043&op=diff
==============================================================================
--- branches/upstream/libextutils-cchecker-perl/current/Changes (original)
+++ branches/upstream/libextutils-cchecker-perl/current/Changes Sat Jan 29 22:45:47 2011
@@ -1,4 +1,8 @@
 Revision history for ExtUtils-CChecker
+
+0.06    CHANGES:
+         * Added 'defines_to' constructor arg for writing a "config.h" file
+           instead of -DFOO on compiler commandline
 
 0.05    CHANGES:
          * Added accessors for callers to push more library dirs or compiler

Modified: branches/upstream/libextutils-cchecker-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-cchecker-perl/current/LICENSE?rev=68043&op=diff
==============================================================================
--- branches/upstream/libextutils-cchecker-perl/current/LICENSE (original)
+++ branches/upstream/libextutils-cchecker-perl/current/LICENSE Sat Jan 29 22:45:47 2011
@@ -1,4 +1,4 @@
-This software is copyright (c) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@
 
 --- The GNU General Public License, Version 1, February 1989 ---
 
-This software is Copyright (c) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is Copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
 
 This is free software, licensed under:
 
@@ -270,7 +270,7 @@
 
 --- The Artistic License 1.0 ---
 
-This software is Copyright (c) 2010 by Paul Evans <leonerd at leonerd.org.uk>.
+This software is Copyright (c) 2011 by Paul Evans <leonerd at leonerd.org.uk>.
 
 This is free software, licensed under:
 

Modified: branches/upstream/libextutils-cchecker-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-cchecker-perl/current/META.yml?rev=68043&op=diff
==============================================================================
--- branches/upstream/libextutils-cchecker-perl/current/META.yml (original)
+++ branches/upstream/libextutils-cchecker-perl/current/META.yml Sat Jan 29 22:45:47 2011
@@ -17,9 +17,9 @@
 provides:
   ExtUtils::CChecker:
     file: lib/ExtUtils/CChecker.pm
-    version: 0.05
+    version: 0.06
 requires:
   ExtUtils::CBuilder: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.05
+version: 0.06

Modified: branches/upstream/libextutils-cchecker-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-cchecker-perl/current/README?rev=68043&op=diff
==============================================================================
--- branches/upstream/libextutils-cchecker-perl/current/README (original)
+++ branches/upstream/libextutils-cchecker-perl/current/README Sat Jan 29 22:45:47 2011
@@ -6,7 +6,11 @@
      use Module::Build;
      use ExtUtils::CChecker;
 
-     my $check_PF_MOONLASER = <<'EOF';
+     my $cc = ExtUtils::CChecker->new;
+ 
+     $cc->assert_compile_run(
+        diag => "no PF_MOONLASER",
+        source => <<'EOF' );
      #include <stdio.h>
      #include <sys/socket.h>
      int main(int argc, char *argv[]) {
@@ -15,11 +19,6 @@
      }
      EOF
 
-     ExtUtils::CChecker->new->assert_compile_run(
-        diag => "no PF_MOONLASER",
-        source => $check_PF_MOONLASER,
-     );
-
      Module::Build->new(
        ...
      )->create_build_script;
@@ -39,8 +38,14 @@
     This class also provides assistance here.
 
 CONSTRUCTOR
-  $cc = ExtUtils::CChecker->new
-    Returns a new instance of a "ExtUtils::CChecker" object.
+  $cc = ExtUtils::CChecker->new( %args )
+    Returns a new instance of a "ExtUtils::CChecker" object. Takes teh
+    following named parameters:
+
+    defines_to => PATH
+            If given, defined symbols will be written to a C preprocessor .h
+            file of the given name, instead of by adding extra "-D*SYMBOL*"
+            arguments to the compiler flags.
 
 METHODS
   $dirs = $cc->include_dirs
@@ -88,9 +93,10 @@
 
     *       define => STRING
 
-            Optional. If specified, then the named symbol will be defined on
-            the C compiler commandline if the program ran successfully (by
-            passing an option "-D*SYMBOL*").
+            Optional. If specified, then the named symbol will be defined if
+            the program ran successfully. This will either on the C compiler
+            commandline (by passing an option "-D*SYMBOL*"), or in the
+            "defines_to" file.
 
   $cc->assert_compile_run( %args )
     Calls "try_compile_run". If it fails, die with an "OS unsupported"
@@ -127,9 +133,10 @@
 
     *       define => STRING
 
-            Optional. If specified, then the named symbol will be defined on
-            the C compiler commandline if the program ran successfully (by
-            passing an option "-D*SYMBOL*").
+            Optional. If specified, then the named symbol will be defined if
+            the program ran successfully. This will either on the C compiler
+            commandline (by passing an option "-D*SYMBOL*"), or in the
+            "defines_to" file.
 
   $success = $cc->try_find_libs_for( %args )
     Try to compile, link and execute the given source, when linked against a
@@ -154,9 +161,10 @@
 
     *       define => STRING
 
-            Optional. If specified, then the named symbol will be defined on
-            the C compiler commandline if the program ran successfully (by
-            passing an option "-D*SYMBOL*").
+            Optional. If specified, then the named symbol will be defined if
+            the program ran successfully. This will either on the C compiler
+            commandline (by passing an option "-D*SYMBOL*"), or in the
+            "defines_to" file.
 
   $cc->find_include_dirs_for( %args )
   $cc->find_libs_for( %args )
@@ -186,7 +194,6 @@
     libc. Others keep it in a separate library which should be linked
     against. The following example demonstrates how this would be handled.
 
-     use Module::Build;
      use ExtUtils::CChecker;
 
      my $cc = ExtUtils::CChecker->new;
@@ -225,7 +232,6 @@
     found. The XS code can then use this symbol to select between differing
     implementations. For example, the Build.PL:
 
-     use Module::Build;
      use ExtUtils::CChecker;
 
      my $cc = ExtUtils::CChecker->new;
@@ -305,6 +311,34 @@
     including the kernel headers, which should make the constant and
     structure visible, allowing the program to compile.
 
+  Creating a config.h
+    Sometimes, rather than setting defined symbols on the compiler
+    commandline, it is preferrable to have them written to a C preprocessor
+    include (.h) file.
+
+     use ExtUtils::CChecker;
+
+     my $cc = ExtUtils::CChecker->new(
+        defines_to => "config.h",
+     );
+
+     $cc->try_compile_run(
+        define => "HAVE_MANGO",
+        source => <<'EOF' );
+     #include <mango.h>
+     #include <unistd.h>
+     #include "config.h"
+     int main(void) {
+       if(mango() != 0)
+         exit(1);
+       exit(0);
+     }
+     EOF
+
+    Because the config.h file is written and flushed after every define
+    operation, it will still be useable in later C fragments to test for
+    features detected in earlier ones.
+
 AUTHOR
     Paul Evans <leonerd at leonerd.org.uk>
 

Modified: branches/upstream/libextutils-cchecker-perl/current/lib/ExtUtils/CChecker.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-cchecker-perl/current/lib/ExtUtils/CChecker.pm?rev=68043&op=diff
==============================================================================
--- branches/upstream/libextutils-cchecker-perl/current/lib/ExtUtils/CChecker.pm (original)
+++ branches/upstream/libextutils-cchecker-perl/current/lib/ExtUtils/CChecker.pm Sat Jan 29 22:45:47 2011
@@ -1,14 +1,14 @@
 #  You may distribute under the terms of either the GNU General Public License
 #  or the Artistic License (the same terms as Perl itself)
 #
-#  (C) Paul Evans, 2010 -- leonerd at leonerd.org.uk
+#  (C) Paul Evans, 2010-2011 -- leonerd at leonerd.org.uk
 
 package ExtUtils::CChecker;
 
 use strict;
 use warnings;
 
-our $VERSION = '0.05';
+our $VERSION = '0.06';
 
 use Carp;
 
@@ -24,7 +24,11 @@
  use Module::Build;
  use ExtUtils::CChecker;
 
- my $check_PF_MOONLASER = <<'EOF';
+ my $cc = ExtUtils::CChecker->new;
+ 
+ $cc->assert_compile_run(
+    diag => "no PF_MOONLASER",
+    source => <<'EOF' );
  #include <stdio.h>
  #include <sys/socket.h>
  int main(int argc, char *argv[]) {
@@ -33,11 +37,6 @@
  }
  EOF
 
- ExtUtils::CChecker->new->assert_compile_run(
-    diag => "no PF_MOONLASER",
-    source => $check_PF_MOONLASER,
- );
-
  Module::Build->new(
    ...
  )->create_build_script;
@@ -63,21 +62,35 @@
 
 =cut
 
-=head2 $cc = ExtUtils::CChecker->new
-
-Returns a new instance of a C<ExtUtils::CChecker> object.
+=head2 $cc = ExtUtils::CChecker->new( %args )
+
+Returns a new instance of a C<ExtUtils::CChecker> object. Takes teh following
+named parameters:
+
+=over 8
+
+=item defines_to => PATH
+
+If given, defined symbols will be written to a C preprocessor F<.h> file of
+the given name, instead of by adding extra C<-DI<SYMBOL>> arguments to the
+compiler flags.
+
+=back
 
 =cut
 
 sub new
 {
    my $class = shift;
+   my %args = @_;
 
    my $cb = ExtUtils::CBuilder->new( quiet => 1 );
 
    return bless {
       cb  => $cb,
       seq => 0,
+
+      defines_to => $args{defines_to},
 
       include_dirs         => [],
       extra_compiler_flags => [],
@@ -205,7 +218,17 @@
    my $self = shift;
    my ( $symbol ) = @_;
 
-   $self->push_extra_compiler_flags( "-D$symbol" );
+   if( $self->{defines_to} ) {
+      unless( $self->{defines_fh} ) {
+         open $self->{defines_fh}, ">", $self->{defines_to} or croak "Cannot open $self->{defines_to} for writing - $!";
+         $self->{defines_fh}->autoflush(1);
+      }
+
+      $self->{defines_fh}->print( "#define $symbol /**/\n" );
+   }
+   else {
+      $self->push_extra_compiler_flags( "-D$symbol" );
+   }
 }
 
 =head2 $success = $cc->try_compile_run( %args )
@@ -235,9 +258,9 @@
 
 =item * define => STRING
 
-Optional. If specified, then the named symbol will be defined on the C
-compiler commandline if the program ran successfully (by passing an option
-C<-DI<SYMBOL>>).
+Optional. If specified, then the named symbol will be defined if the program
+ran successfully. This will either on the C compiler commandline (by passing
+an option C<-DI<SYMBOL>>), or in the C<defines_to> file.
 
 =back
 
@@ -355,9 +378,9 @@
 
 =item * define => STRING
 
-Optional. If specified, then the named symbol will be defined on the C
-compiler commandline if the program ran successfully (by passing an option
-C<-DI<SYMBOL>>).
+Optional. If specified, then the named symbol will be defined if the program
+ran successfully. This will either on the C compiler commandline (by passing
+an option C<-DI<SYMBOL>>), or in the C<defines_to> file.
 
 =back
 
@@ -409,9 +432,9 @@
 
 =item * define => STRING
 
-Optional. If specified, then the named symbol will be defined on the C
-compiler commandline if the program ran successfully (by passing an option
-C<-DI<SYMBOL>>).
+Optional. If specified, then the named symbol will be defined if the program
+ran successfully. This will either on the C compiler commandline (by passing
+an option C<-DI<SYMBOL>>), or in the C<defines_to> file.
 
 =back
 
@@ -517,7 +540,6 @@
 Others keep it in a separate library which should be linked against. The
 following example demonstrates how this would be handled.
 
- use Module::Build;
  use ExtUtils::CChecker;
 
  my $cc = ExtUtils::CChecker->new;
@@ -556,7 +578,6 @@
 this symbol to select between differing implementations. For example, the
 F<Build.PL>:
 
- use Module::Build;
  use ExtUtils::CChecker;
 
  my $cc = ExtUtils::CChecker->new;
@@ -636,6 +657,34 @@
 including the kernel headers, which should make the constant and structure
 visible, allowing the program to compile.
 
+=head2 Creating a F<config.h>
+
+Sometimes, rather than setting defined symbols on the compiler commandline, it
+is preferrable to have them written to a C preprocessor include (F<.h>) file.
+
+ use ExtUtils::CChecker;
+
+ my $cc = ExtUtils::CChecker->new(
+    defines_to => "config.h",
+ );
+
+ $cc->try_compile_run(
+    define => "HAVE_MANGO",
+    source => <<'EOF' );
+ #include <mango.h>
+ #include <unistd.h>
+ #include "config.h"
+ int main(void) {
+   if(mango() != 0)
+     exit(1);
+   exit(0);
+ }
+ EOF
+
+Because the F<config.h> file is written and flushed after every define
+operation, it will still be useable in later C fragments to test for features
+detected in earlier ones.
+
 =head1 AUTHOR
 
 Paul Evans <leonerd at leonerd.org.uk>




More information about the Pkg-perl-cvs-commits mailing list