Author: ericwilhelm
Date: Sun Feb 18 13:13:42 2007
New Revision: 9127
Modified:
Module-Build/trunk/Changes
Module-Build/trunk/lib/Module/Build/ModuleInfo.pm
Log:
lib/Module/Build/ModuleInfo.pm - support for 'use version $VERSION => ...'
Changes - noted
Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes (original)
+++ Module-Build/trunk/Changes Sun Feb 18 13:13:42 2007
@@ -1,5 +1,8 @@
Revision history for Perl extension Module::Build.
+ - Made ModuleInfo's _evaluate_version_line() compatible with 'use
+ version ...$VERSION' lines. [Eric Wilhelm]
+
- Added some verbiage in Module::Build::API that officially blesses
the _build/prereqs file for external consumption. [Suggested by Andreas
Koenig]
Modified: Module-Build/trunk/lib/Module/Build/ModuleInfo.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/ModuleInfo.pm (original)
+++ Module-Build/trunk/lib/Module/Build/ModuleInfo.pm Sun Feb 18 13:13:42 2007
@@ -286,20 +286,29 @@
# Some of this code came from the ExtUtils:: hierarchy.
- my $eval = qq{q# Hide from _packages_inside()
- #; package Module::Build::ModuleInfo::_version;
- no strict;
-
- local $sigil$var;
- \$$var=undef; do {
- $line
- }; \$$var
- };
+ # We compile into $vsub because 'use version' would cause
+ # compiletime/runtime issues with local()
+ my $vsub;
+ my $eval = qq{BEGIN { q# Hide from _packages_inside()
+ #; package Module::Build::ModuleInfo::_version;
+ no strict;
+
+ local $sigil$var;
+ \$$var=undef;
+ \$vsub = sub {
+ $line;
+ \$$var
+ };
+ }};
local $^W;
- # Try and get the $VERSION
- my $result = eval $eval;
- warn "Error evaling version line '$eval' in $self->{filename}: [EMAIL
PROTECTED]" if $@;
+ # Try to get the $VERSION
+ eval $eval;
+ warn "Error evaling version line '$eval' in $self->{filename}: [EMAIL
PROTECTED]"
+ if $@;
+ (ref($vsub) eq 'CODE') or
+ die "failed to build version sub for $self->{filename}";
+ my $result = $vsub->();
# Bless it into our own version class
$result = Module::Build::Version->new($result);