1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2021-07-30 20:10:23 +0300 (Fri, 30 Jul 2021) $
#$Revision: 8841 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.11.0/tools/mkperldepend $
#------------------------------------------------------------------------------
use strict;
use warnings;
use Cwd qw( abs_path );
use File::Basename qw( dirname );
use Module::ScanDeps;
# The script is assumed to be located in "${base_dir}/tools"
my $base_dir = dirname( dirname( abs_path( __FILE__ ) ) );
my $lib_dir = 'src/lib/perl5';
local $\ = "\n";
foreach my $file (@ARGV) {
my $stderr;
close( STDERR );
open( STDERR, '>', \$stderr );
my $deps = scan_deps( files => [ $file ],
recurse => 1,
warn_missing => 1 );
my @modules;
# Exclude dependencies of modules that are not located
# in the current repository branch
for my $module ( keys %{$deps} ) {
my $parent_key = $deps->{$module}{'used_by'}[0];
if ( $deps->{$parent_key}{'file'} =~ /^\Q$base_dir/ ) {
push @modules, $module;
}
}
close( STDERR );
while( $stderr =~ /Could not find source file '([^']+)'/g ) {
push @modules, $1;
}
print "$file: ", join( ' ', sort map { "$lib_dir/$_" }
grep {/^COD/} @modules );
}
|