Skip Menu |

This queue is for tickets about the Module-ScanDeps CPAN distribution.

Report information
The Basics
Id: 73785
Status: resolved
Priority: 0/
Queue: Module-ScanDeps

People
Owner: RSCHUPP [...] cpan.org
Requestors: florent.angly [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.07
Fixed in: (no value)



Subject: scandeps -c fails on modules that depend on Getopt::Euclid
Hi, If a module uses Getopt::Euclid to parse its CLI arguments and that some arguments are required, the 'scandeps -c' command fails. For example, with the attached script: $ ./simple.pl Missing required argument: -s[ize]=<h>x<w> (Try this for usage help : simple.pl --help) (Try this for full manual: simple.pl --man ) This is an error because the required argument is missing. Now if I scan the dependencies: $ scandeps -c simple.pl Missing required argument: -s[ize]=<h>x<w> (Try this for usage help : simple.pl --help) (Try this for full manual: simple.pl --man ) SYSTEM ERROR in compiling simple.pl: 512 at /usr/share/perl5/Module/ScanDeps.pm line 1296. Whereas: $ perl -c simple.pl simple.pl syntax OK The reason perl -c works is that Getopt::Euclid checks the value of $^C to workaround the issues associated with having been called in compile-mode and to not report any error message. However, scandeps seems to call something around the lines of "perl simple.pl", which generates an error. In short, if scandeps could call "perl -c simple.pl" or "perl simple.pl" but somehow have $^C set to 1, then it would be fine. Regards, Florent
Subject: simple.pl
#! /usr/bin/env perl # Compiled with Par Packer: # export PAR_VERBATIM=1 && pp --compile --dependent --output simple.bin simple.pl use strict; use warnings; use Getopt::Euclid; =head1 NAME yourprog - Your program here =head1 VERSION This documentation refers to yourprog version 1.9.4 =head1 USAGE yourprog [options] -s[ize]=<h>x<w> -o[ut][file] <file> =head1 REQUIRED ARGUMENTS =over =item -s[ize]=<h>x<w> Specify size of simulation =back =cut for my $x (1 .. $ARGV{-size}{h}) { for my $y (1 .. $ARGV{-size}{w}) { print "x=$x y=$y\n"; } } exit;
On 2012-01-06 03:02:15, FANGLY wrote: Show quoted text
> In short, if scandeps could call "perl -c simple.pl" or "perl simple.pl" > but somehow have $^C set to 1, then it would be fine.
OK, in order to use "perl -c" instead of "perl" we have to instrument the script under examination with a CHECK block (which is executed even with "-c") instead of an INIT block (which is not). Please try the attached patch. Cheers, Roderich
Subject: compile.patch
Index: lib/Module/ScanDeps.pm =================================================================== --- lib/Module/ScanDeps.pm (revision 1312) +++ lib/Module/ScanDeps.pm (working copy) @@ -719,7 +719,7 @@ next unless $file =~ $ScanFileRE; ($inchash, $dl_shared_objects, $incarray) = ({}, [], []); - _compile($perl, $file, $inchash, $dl_shared_objects, $incarray); + _compile_or_execute($compile, $perl, $file, $inchash, $dl_shared_objects, $incarray); my $rv_sub = _make_rv($inchash, $dl_shared_objects, $incarray); _merge_rv($rv_sub, $rv); @@ -730,7 +730,7 @@ my $exc; foreach $exc (@$excarray) { ($inchash, $dl_shared_objects, $incarray) = ({}, [], []); - _execute($perl, $exc, $inchash, $dl_shared_objects, $incarray); + _compile_or_execute($compile, $perl, $exc, $inchash, $dl_shared_objects, $incarray); } # XXX only retains data from last execute ... Why? I suspect @@ -1232,11 +1234,8 @@ # scan_deps_runtime utility functions -sub _compile { _compile_or_execute(1, @_) } -sub _execute { _compile_or_execute(0, @_) } - sub _compile_or_execute { - my ($do_compile, $perl, $file, $inchash, $dl_shared_objects, $incarray) = @_; + my ($compile, $perl, $file, $inchash, $dl_shared_objects, $incarray) = @_; require Module::ScanDeps::DataFeed; # ... so we can find it's full pathname in %INC @@ -1250,14 +1249,14 @@ # NOTE: We don't directly assign to $0 as it has magic (i.e. # assigning has side effects and may actually fail, cf. perlvar(1)). # Instead we alias *0 to a package variable holding the correct value. - print $feed_fh "BEGIN { ", + print $feed_fh "BEGIN {\n", Data::Dumper->Dump([ $file ], [ "Module::ScanDeps::DataFeed::_0" ]), - "*0 = \\\$Module::ScanDeps::DataFeed::_0; }\n"; + "*0 = \\\$Module::ScanDeps::DataFeed::_0;\n", + "}\n"; - print $feed_fh $do_compile ? "INIT {\n" : "END {\n"; - # NOTE: When compiling the block will run _after_ all CHECK blocks - # (but _before_ the first INIT block) and will terminate the program. - # When executing the block will run as the first END block and + print $feed_fh $compile ? "CHECK {\n" : "END {\n"; + # NOTE: When compiling the block will run as the last CHECK block; + # when executing the block will run as the first END block and # the programs continues. # correctly escape strings containing filenames @@ -1265,20 +1264,19 @@ [ $INC{"Module/ScanDeps/DataFeed.pm"}, $dump_file ], [ qw( datafeedpm dump_file ) ]); + # save %INC etc so that further requires dont't pollute them print $feed_fh <<'...'; - # save %INC etc so that further requires dont't pollute them %Module::ScanDeps::DataFeed::_INC = %INC; @Module::ScanDeps::DataFeed::_INC = @INC; @Module::ScanDeps::DataFeed::_dl_shared_objects = @DynaLoader::dl_shared_objects; @Module::ScanDeps::DataFeed::_dl_modules = @DynaLoader::dl_modules; - require $datafeedpm; + require $datafeedpm; Module::ScanDeps::DataFeed::_dump_info($dump_file); +} ... - print $feed_fh $do_compile ? "exit(0);\n}\n" : "}\n"; - # append the file to compile { open my $fhin, "<", $file or die "Couldn't open $file: $!"; @@ -1288,14 +1286,19 @@ close $feed_fh; File::Path::rmtree( ['_Inline'], 0, 1); # XXX hack - my $rc = system($perl, (map { "-I$_" } @IncludeLibs), $feed_file); + + my @cmd = ($perl); + push @cmd, "-c" if $compile; + push @cmd, map { "-I$_" } @IncludeLibs; + my $rc = system(@cmd, $feed_file); - _extract_info($dump_file, $inchash, $dl_shared_objects, $incarray) if $rc == 0; + _extract_info($dump_file, $inchash, $dl_shared_objects, $incarray) + if $rc == 0; unlink($feed_file, $dump_file); - die $do_compile - ? "SYSTEM ERROR in compiling $file: $rc" - : "SYSTEM ERROR in executing $file: $rc" - unless $rc == 0; + die $compile + ? "SYSTEM ERROR in compiling $file: $rc" + : "SYSTEM ERROR in executing $file: $rc" + unless $rc == 0; } # create a new hashref, applying fixups
Hi Roderich, I got the curent SVN code, which has your patch and its works perfectly. Thank you, Florent
On 2012-01-06 19:33:55, FANGLY wrote: Show quoted text
> I got the curent SVN code, which has your patch and its works perfectly.
Thanks for testing. Patch will be in the next release of Module::ScanDeps. Cheers, Roderich