1 package DependencyGenerator
;
3 # ************************************************************
4 # Description : Runs the correct dependency generator on the file.
5 # Author : Chad Elliott
6 # Create Date : 2/10/2002
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
16 use DependencyWriterFactory
;
17 use ObjectGeneratorFactory
;
19 # ************************************************************
21 # ************************************************************
24 my($class, $macros, $ipaths, $replace, $type, $noinline, $exclude) = @_;
25 my $self = bless {'pre' => new Preprocessor
($macros,
27 'replace' => $replace,
28 'dwrite' => DependencyWriterFactory
::create
($type),
29 'objgen' => ObjectGeneratorFactory
::create
($type),
30 'noinline' => $noinline,
33 ## Set the current working directory, but
34 ## escape regular expression special characters
35 $self->{'cwd'} = Cwd
::getcwd
() . '/';
36 $self->{'cwd'} =~ s/([\+\-\\\$\[\]\(\)\.])/\\$1/g;
38 ## Sort the replace keys to get the longest key first. This way
39 ## when we are replacing portions of the file path, we replace the
41 my @repkeys = sort { length($b) <=> length($a) } keys %$replace;
42 $self->{'repkeys'} = \
@repkeys;
49 my($self, $file) = @_;
51 ## Generate the dependency string
52 my $depstr = $self->{'dwrite'}->process(
53 $self->{'objgen'}->process($file),
54 $self->{'pre'}->process($file, $self->{'noinline'}));
56 ## Perform the replacements on the dependency string
57 $depstr =~ s/$self->{'cwd'}//go;
58 my $replace = $self->{'replace'};
59 foreach my $rep (@
{$self->{'repkeys'}}) {
60 $depstr =~ s/$rep/$$replace{$rep}/g;