tools: Improve makeDbDepends
Rewrite, add support for quotes around filenames in "file" statements.
This commit is contained in:
@@ -3,31 +3,22 @@ eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
|
||||
|
||||
# Called from within RULES.Db in the Db directories.
|
||||
# Searches .substitutions and .template files (from the command line) for
|
||||
# "file xxx {" entries to create a DEPENDS file
|
||||
# and
|
||||
# 'include "xxx"' entries to create a DEPENDS file
|
||||
# file ["']xxx["'] {
|
||||
# and
|
||||
# include "xxx"
|
||||
# entries to include in the DEPENDS file
|
||||
|
||||
use strict;
|
||||
|
||||
$target = $ARGV[0];
|
||||
shift @ARGV;
|
||||
my $target = shift @ARGV;
|
||||
my %depends;
|
||||
|
||||
|
||||
foreach $file (@ARGV) {
|
||||
open(IN, "<$file") or die "Cannot open $file: $!";
|
||||
@infile = <IN>;
|
||||
close IN or die "Cannot close $file: $!";
|
||||
|
||||
@depends = grep { s/^\s*file\s*(.*)\s*\{.*$/\1/ } @infile;
|
||||
chomp @depends;
|
||||
|
||||
if (@depends) {
|
||||
print "$target: @depends\n";
|
||||
}
|
||||
|
||||
@depends2 = grep { s/^\s*include\s*\"\s*(.*)\s*\".*$/\1/ } @infile;
|
||||
chomp @depends2;
|
||||
|
||||
if (@depends2) {
|
||||
print "$target: @depends2\n";
|
||||
}
|
||||
while (my $line = <>) {
|
||||
$depends{$2}++ if $line =~ m/^\s*file\s*(["']?)(.*)\1/;
|
||||
$depends{$1}++ if $line =~ m/^\s*include\s+"(.*)"/;
|
||||
}
|
||||
|
||||
if (%depends) {
|
||||
my @depends = keys %depends;
|
||||
print "$target: @depends\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user