Skip to content

Commit

Permalink
ExtUtils-ParseXS: add author/mksnapshot.pl utility
Browse files Browse the repository at this point in the history
Crude tool to collect before and after snapshots of all .c files created
by xsubpp, in order to see what (if anything) has changed in
functionality while working on ParseXS files.
  • Loading branch information
iabyn committed Jul 29, 2024
1 parent 24382a3 commit fee5e5b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4157,6 +4157,7 @@ dist/ExtUtils-CBuilder/t/01-basic.t tests for ExtUtils::CBuilder
dist/ExtUtils-CBuilder/t/02-link.t tests for ExtUtils::CBuilder
dist/ExtUtils-CBuilder/t/03-cplusplus.t tests for ExtUtils::CBuilder
dist/ExtUtils-CBuilder/t/04-base.t tests for ExtUtils::CBuilder
dist/ExtUtils-ParseXS/author/mksnapshot.pl Utility for detecting before/after changes to xsubpp output
dist/ExtUtils-ParseXS/Changes ExtUtils::ParseXS change log
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm converts Perl XS code into C code
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pod ExtUtils::ParseXS documentation
Expand Down
1 change: 1 addition & 0 deletions Porting/exec-bit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dist/Devel-PPPort/devel/regenerate
dist/Devel-PPPort/devel/scanprov
dist/Devel-PPPort/devel/update_release_date.pl
dist/Devel-PPPort/soak
dist/ExtUtils-ParseXS/author/mksnapshot.pl
dist/Thread-Queue/examples/callback.pl
dist/Thread-Queue/examples/queue.pl
installperl
Expand Down
69 changes: 69 additions & 0 deletions dist/ExtUtils-ParseXS/author/mksnapshot.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/perl
#
# mksnapshot.pl
#
# This is a very crude script to help check whether and/or what has
# changed in generated .c files as a result of changes to xsubpp and its
# modules.
#
# It finds all .xs files under the current directory, then copies to
# another directory, each associated .c file if it exists.
#
# The idea is that, while cd'ed to the base of the perl distribution, you
# run this script, which will copy all the generated .c files to one
# directory. You then rebuild perl with the newly modified xsubpp, and
# create a second snapshot to another directory, then compare the results.
#
# For example,
#
# ... build perl...
#
# $ mkdir /tmp/snap1 /tmp/snap2
# $ dist/ExtUtils-ParseXS/author/mksnapshot.pl /tmp/snap1
# $ git clean -xdf
#
# ... modify xsubpp ...
# ... build perl...
#
# $ dist/ExtUtils-ParseXS/author/mksnapshot.pl /tmp/snap2
# $ diff -ru /tmp/snap[12]
#
# Each snapped .c file is saved with each '/' component of its pathname
# changed to a '='. So ext/POSIX/POSIX.c would be copied to
# /tmp/snap1/ext=POSIX=POSIX.c

use warnings;
use strict;

use File::Find;
use File::Copy;

die "usage: $0 snapdirectory\n" unless @ARGV == 1;
my $snapdir = shift @ARGV;

die "No such directory: $snapdir\n" unless -d $snapdir;

find(
{
wanted => \&wanted,
no_chdir => 1,
},

'.'
);



sub wanted {
return unless /\.xs$/;
my $f = $_;
$f =~ s/\.xs$/.c/ or die;
return unless -f $f;
my $df = $f;
$df =~ s{^/}{};
$df =~ s{^\./}{};
$df =~ s{/}{=}g;
$df = "$snapdir/$df";
print "snapping $f\n";
copy($f, $df) or die "Can't copy $f to $df: $!\n";
}

0 comments on commit fee5e5b

Please sign in to comment.