Skip to content

Commit

Permalink
Fixed generated C files with wrong GSL version numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambs committed Jun 9, 2014
1 parent d6938f4 commit 30b095f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ my $builder = GSLBuilder->new(
'Test::Class' => '0.12',
},
requires => {
'PkgConfig' => '0.07520',
'PkgConfig' => '0.07720',
'Scalar::Util' => 0,
version => '0.77',
perl => '5.8.0',
},
sign => 0,
configure_requires => {
'PkgConfig' => '0.07520',
'PkgConfig' => '0.07720',
'Module::Build' => '0.38',
},
swig_source => [
Expand Down Expand Up @@ -276,7 +276,7 @@ sub check_gsl_version_pkgconfig {

return {
gsl_version => $gsl_version,
gsl_prefix => undef,
gsl_prefix => $gsl_pkgcfg->get_var("prefix"),
gsl_libs => join (" ", $gsl_pkgcfg->get_ldflags),
gsl_cflags => join (" ", $gsl_pkgcfg->get_cflags),
};
Expand Down
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
=head1 Math::GSL Changes

- Fixed generated C files with wrong GSL version numbers.
- Refactored Build.PL in order to use either gsl-config or PkgConfig.
- Change Build.PL to return 0 when GSL library not found.
- Use PkgConfig instead of ExtUtils::PkgConfig.
Expand Down
19 changes: 18 additions & 1 deletion inc/GSLBuilder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ sub process_swig {

# don't bother with swig if this is a CPAN release
$self->compile_swig($main_swig_file, $c_file, $ver)
unless($self->up_to_date([$main_swig_file, @deps], $c_file));
unless $self->up_to_date([$main_swig_file, @deps], $c_file);
}

sub swig_binary_name {
Expand Down Expand Up @@ -209,6 +209,23 @@ sub compile_swig {
or die "error : $! while building ( @swig_flags ) $c_file in $gsldir from '$file'";
move($from, "$from.$ver");

{
## updates the version number.
## all files are being processed right now.
## later versions might use a fixed list of candidate files.
undef $/;
open my $in, "<", $c_file or die "Can't open file $c_file: $!";
my $contents = <$in>;
close $in;

$contents =~ s{("GSL_VERSION", TRUE \| 0x2 \| GV_ADDMULTI\);[\s\n]*sv_setsv\(sv, SWIG_FromCharPtr\(")\d\.\d+}
{$1$ver};

open my $out, ">", $c_file or die "Can't overwrite file $c_file: $!";
print $out $contents;
close $out;
}

if ($p->{current_version} eq $ver) {
print "Copying from: $from.$ver, to: $to; it makes the CPAN indexer happy.\n";
copy("$from.$ver", $to);
Expand Down

0 comments on commit 30b095f

Please sign in to comment.