Disable XS code on perls with ${^GLOBAL_PHASE}
Florian Ragwitz [Wed, 1 Dec 2010 20:12:39 +0000 (21:12 +0100)]
Makefile.PL
lib/Devel/GlobalDestruction.pm

index 84887e1..7ab9cef 100644 (file)
@@ -6,15 +6,16 @@ require 5.006000;
 use ExtUtils::MakeMaker;
 
 WriteMakefile(
-       NAME             => 'Devel::GlobalDestruction',
-       VERSION_FROM     => 'lib/Devel/GlobalDestruction.pm',
-       INSTALLDIRS      => 'site',
-       SIGN             => 1,
-       PL_FILES         => { },
+    NAME             => 'Devel::GlobalDestruction',
+    VERSION_FROM     => 'lib/Devel/GlobalDestruction.pm',
+    INSTALLDIRS      => 'site',
+    SIGN             => 1,
+    PL_FILES         => { },
     MIN_PERL_VERSION => '5.006000',
-       PREREQ_PM        => {
-               'Sub::Exporter' => 0,
-               'Scope::Guard'  => 0,
-       },
+    PREREQ_PM        => {
+        'Sub::Exporter' => 0,
+        'Scope::Guard'  => 0,
+    },
+    ($] >= 5.013007 ? (XS => {}, C => []) : ()),
 );
 
index b8385b7..5fe7e89 100644 (file)
@@ -9,13 +9,18 @@ use XSLoader;
 
 our $VERSION = '0.02';
 
-XSLoader::load(__PACKAGE__, $VERSION);
-
 use Sub::Exporter -setup => {
        exports => [ qw(in_global_destruction) ],
        groups  => { default => [ -all ] },
 };
 
+if ($] >= 5.013007) {
+    eval 'sub in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }';
+}
+else {
+    XSLoader::load(__PACKAGE__, $VERSION);
+}
+
 __PACKAGE__
 
 __END__