Crombie Tools
deps.pl
Go to the documentation of this file.
1 #! /usr/bin/env perl
2 
3 use strict;
4 use warnings;
5 use v5.10;
6 
7 use Data::Dumper;
8 
9 my @infiles;
10 my $firstfile = shift;
11 
12 push @infiles, $firstfile;
13 my @included;
14 push @included, $firstfile;
15 
16 while (scalar @infiles) {
17 
18  my $infile = pop @infiles;
19 
20  my @lines;
21  open (my $handle, '<', $infile) or die "Can't open $infile";
22  push @lines, <$handle>;
23  close $handle;
24 
25  for (grep {/#include\s.(\w+\.h)/} @lines) {
26  my ($checkfile) = /(\w+\.h)/;
27 
28  if (-f "include/$checkfile" && ! grep {/include\/$checkfile/} @included) {
29  push @infiles, "include/$checkfile";
30  push @included, "include/$checkfile";
31  }
32 
33  }
34 
35  for (grep {/INCLUDE\s(treedefs\/\w+\.txt)/} @lines) {
36  my ($checkfile) = /(treedefs\/\w+\.txt)/;
37 
38  if (-f $checkfile && ! grep {/$checkfile/} @included) {
39  push @infiles, $checkfile;
40  push @included, $checkfile;
41  }
42 
43  }
44 
45 }
46 
47 for (@included) {
48  say $_;
49 }