diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2007-03-22 13:56:08 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2007-03-22 13:56:08 +0000 |
commit | c999c4f1b130984eb5dbeb9c4c05f758a6f3daf5 (patch) | |
tree | d3193c2c83ae20bff62cc3c1fa1cff50d924c9c6 /ACE/bin/DependencyGenerator | |
parent | e891fb85473f0dd0d6df96a13ac48890a1f72301 (diff) | |
download | ATCD-c999c4f1b130984eb5dbeb9c4c05f758a6f3daf5.tar.gz |
ChangeLogTag: Thu Mar 22 14:51:46 UTC 2007 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'ACE/bin/DependencyGenerator')
-rw-r--r-- | ACE/bin/DependencyGenerator/DependencyEditor.pm | 118 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/DependencyGenerator.pm | 77 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/DependencyWriter.pm | 33 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/DependencyWriterFactory.pm | 35 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/MakeDependencyWriter.pm | 32 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/MakeObjectGenerator.pm | 47 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/NMakeDependencyWriter.pm | 53 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/NMakeObjectGenerator.pm | 28 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/ObjectGenerator.pm | 32 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/ObjectGeneratorFactory.pm | 35 | ||||
-rw-r--r-- | ACE/bin/DependencyGenerator/Preprocessor.pm | 147 |
11 files changed, 0 insertions, 637 deletions
diff --git a/ACE/bin/DependencyGenerator/DependencyEditor.pm b/ACE/bin/DependencyGenerator/DependencyEditor.pm deleted file mode 100644 index 646ae2ae574..00000000000 --- a/ACE/bin/DependencyGenerator/DependencyEditor.pm +++ /dev/null @@ -1,118 +0,0 @@ -package DependencyEditor; - -# ************************************************************ -# Description : Edits existing dependencies. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use FileHandle; - -use DependencyGenerator; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub new { - return bless { - }, $_[0]; -} - - -sub process { - my($self) = shift; - my($output) = shift; - my($type) = shift; - my($noinline) = shift; - my($macros) = shift; - my($ipaths) = shift; - my($replace) = shift; - my($exclude) = shift; - my($files) = shift; - - ## Back up the original file and receive the contents - my($contents) = undef; - if (-s $output) { - $contents = []; - if (!$self->backup($output, $contents)) { - print STDERR "ERROR: Unable to backup $output\n"; - return 1; - } - } - - ## Write out the new file - my($fh) = new FileHandle(); - if (open($fh, ">$output")) { - if (defined $contents) { - foreach my $line (@$contents) { - print $fh $line; - } - } - - print $fh "# DO NOT DELETE THIS LINE -- depgen.pl uses it.\n", - "# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.\n\n"; - - my($dep) = new DependencyGenerator($macros, $ipaths, $replace, - $type, $noinline, $exclude); - ## Sort the files so the dependencies are reproducible - foreach my $file (sort @$files) { - print $fh $dep->process($file), "\n"; - } - - print $fh "# IF YOU PUT ANYTHING HERE IT WILL GO AWAY\n"; - close($fh); - } - else { - print STDERR "ERROR: Unable to open $output for output\n"; - return 1; - } - - return 0; -} - - -sub backup { - my($self) = shift; - my($source) = shift; - my($contents) = shift; - my($status) = 0; - my($fh) = new FileHandle(); - my($backup) = "$source.bak"; - - if (open($fh, $source)) { - my($oh) = new FileHandle(); - if (open($oh, ">$backup")) { - my($record) = 1; - $status = 1; - while(<$fh>) { - print $oh $_; - if ($record) { - if (index($_, 'DO NOT DELETE') >= 0) { - $record = undef; - } - else { - push(@$contents, $_); - } - } - } - close($oh); - - ## Set file permission - my(@buf) = stat($source); - if (defined $buf[8] && defined $buf[9]) { - utime($buf[8], $buf[9], $backup); - } - } - close($fh); - } - return $status; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/DependencyGenerator.pm b/ACE/bin/DependencyGenerator/DependencyGenerator.pm deleted file mode 100644 index 58caa43b53e..00000000000 --- a/ACE/bin/DependencyGenerator/DependencyGenerator.pm +++ /dev/null @@ -1,77 +0,0 @@ -package DependencyGenerator; - -# ************************************************************ -# Description : Runs the correct dependency generator on the file. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; - -use Preprocessor; -use DependencyWriterFactory; -use ObjectGeneratorFactory; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub new { - my($class) = shift; - my($macros) = shift; - my($ipaths) = shift; - my($replace) = shift; - my($type) = shift; - my($noinline) = shift; - my($exclude) = shift; - my($self) = bless {'pre' => new Preprocessor($macros, - $ipaths, $exclude), - 'replace' => $replace, - 'dwrite' => DependencyWriterFactory::create($type), - 'objgen' => ObjectGeneratorFactory::create($type), - 'noinline' => $noinline, - }, $class; - - ## Set the current working directory, but - ## escape regular expression special characters - $self->{'cwd'} = Cwd::getcwd() . '/'; - $self->{'cwd'} =~ s/([\+\-\\\$\[\]\(\)\.])/\\$1/g; - - ## Sort the replace keys to get the longest key first. This way - ## when we are replacing portions of the file path, we replace the - ## most we can. - my(@repkeys) = sort { length($b) <=> length($a) } keys %$replace; - $self->{'repkeys'} = \@repkeys; - - return $self; -} - - -sub process { - my($self) = shift; - my($file) = shift; - - ## Generate the dependency string - my($depstr) = $self->{'dwrite'}->process( - $self->{'objgen'}->process($file), - $self->{'pre'}->process($file, $self->{'noinline'})); - - ## Perform the replacements on the dependency string - if ($depstr =~ s/$self->{'cwd'}//go) { - } - else { - my($replace) = $self->{'replace'}; - foreach my $rep (@{$self->{'repkeys'}}) { - $depstr =~ s/$rep/$$replace{$rep}/g; - } - } - - return $depstr; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/DependencyWriter.pm b/ACE/bin/DependencyGenerator/DependencyWriter.pm deleted file mode 100644 index c0c8243004f..00000000000 --- a/ACE/bin/DependencyGenerator/DependencyWriter.pm +++ /dev/null @@ -1,33 +0,0 @@ -package DependencyWriter; - -# ************************************************************ -# Description : Base class for all Dependency Writers. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub new { - return bless { - }, $_[0]; -} - - -sub process { - #my($self) = shift; - #my($objects) = shift; - #my($files) = shift; - return ''; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/DependencyWriterFactory.pm b/ACE/bin/DependencyGenerator/DependencyWriterFactory.pm deleted file mode 100644 index 74fdbe2d871..00000000000 --- a/ACE/bin/DependencyGenerator/DependencyWriterFactory.pm +++ /dev/null @@ -1,35 +0,0 @@ -package DependencyWriterFactory; - -# ************************************************************ -# Description : Create DependencyWriter objects. -# Author : Chad Elliott -# Create Date : 5/23/2003 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; - -use GNUDependencyWriter; -use NMakeDependencyWriter; -use MakeDependencyWriter; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub create { - switch: { - $_[0] eq 'gnu' && do { return new GNUDependencyWriter(); }; - $_[0] eq 'nmake' && do { return new NMakeDependencyWriter(); }; - $_[0] eq 'make' && do { return new MakeDependencyWriter(); }; - print STDERR "WARNING: Invalid dependency writer type: $_[0]\n"; - } - - return new DependencyWriter(); -} - - -1; diff --git a/ACE/bin/DependencyGenerator/MakeDependencyWriter.pm b/ACE/bin/DependencyGenerator/MakeDependencyWriter.pm deleted file mode 100644 index ee9d0db4a89..00000000000 --- a/ACE/bin/DependencyGenerator/MakeDependencyWriter.pm +++ /dev/null @@ -1,32 +0,0 @@ -package MakeDependencyWriter; - -# ************************************************************ -# Description : Generates generic Makefile dependencies. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use DependencyWriter; - -use vars qw(@ISA); -@ISA = qw(DependencyWriter); - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub process { - my($objects) = $_[1]; - my($files) = $_[2]; - - ## Sort the dependencies to make them reproducible - return "@$objects: \\\n " . join(" \\\n ", sort @$files) . "\n"; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/MakeObjectGenerator.pm b/ACE/bin/DependencyGenerator/MakeObjectGenerator.pm deleted file mode 100644 index 67e5cf174b8..00000000000 --- a/ACE/bin/DependencyGenerator/MakeObjectGenerator.pm +++ /dev/null @@ -1,47 +0,0 @@ -package MakeObjectGenerator; - -# ************************************************************ -# Description : Generates object files for generic Makefiles. -# Author : Chad Elliott -# Create Date : 5/23/2003 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use ObjectGenerator; - -use vars qw(@ISA); -@ISA = qw(ObjectGenerator); - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub process { - my($noext) = $_[1]; - my(@objects) = (); - my(@exts) = ('o'); - my(@dirs) = (defined $ENV{VDIR} ? $ENV{VDIR} : ''); - $noext =~ s/\.[^\.]+$//o; - - if (defined $ENV{SOEXT}) { - push(@exts, $ENV{SOEXT}); - } - if (defined $ENV{VSHDIR}) { - push(@dirs, $ENV{VSHDIR}); - } - - foreach my $dirs (@dirs) { - foreach my $ext (@exts) { - push(@objects, "$dirs$noext.$ext"); - } - } - - return \@objects; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/NMakeDependencyWriter.pm b/ACE/bin/DependencyGenerator/NMakeDependencyWriter.pm deleted file mode 100644 index 903406562ac..00000000000 --- a/ACE/bin/DependencyGenerator/NMakeDependencyWriter.pm +++ /dev/null @@ -1,53 +0,0 @@ -package NMakeDependencyWriter; - -# ************************************************************ -# Description : Generates NMake dependencies. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use DependencyWriter; - -use vars qw(@ISA); -@ISA = qw(DependencyWriter); - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub process { - my($sources) = $_[1]; - my($files) = $_[2]; - my($total) = 0; - - $$sources[0] =~ s/\//\\/g; - $$sources[0] =~ s/\\\\/\\/g; - my($dep) = "$$sources[0] :\\\n"; - - ## Sort the dependencies to make them reproducible - foreach my $file (sort @$files) { - $file =~ s/\//\\/g; - $file =~ s/\\\\/\\/g; - if ($file ne $$sources[0]) { - $dep .= "\t\"$file\"\\\n"; - ++$total; - } - } - - if ($total == 0) { - $dep = ''; - } - else { - $dep .= "\n\n"; - } - - return $dep; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/NMakeObjectGenerator.pm b/ACE/bin/DependencyGenerator/NMakeObjectGenerator.pm deleted file mode 100644 index ac4f11fa902..00000000000 --- a/ACE/bin/DependencyGenerator/NMakeObjectGenerator.pm +++ /dev/null @@ -1,28 +0,0 @@ -package NMakeObjectGenerator; - -# ************************************************************ -# Description : Generates object files for NMake Makefiles. -# Author : Chad Elliott -# Create Date : 5/23/2003 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use ObjectGenerator; - -use vars qw(@ISA); -@ISA = qw(ObjectGenerator); - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub process { - return [ $_[1] ]; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/ObjectGenerator.pm b/ACE/bin/DependencyGenerator/ObjectGenerator.pm deleted file mode 100644 index d7e92070642..00000000000 --- a/ACE/bin/DependencyGenerator/ObjectGenerator.pm +++ /dev/null @@ -1,32 +0,0 @@ -package ObjectGenerator; - -# ************************************************************ -# Description : Base class for all Object Generators. -# Author : Chad Elliott -# Create Date : 5/23/2003 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub new { - return bless { - }, $_[0]; -} - - -sub process { - #my($self) = shift; - #my($file) = shift; - return []; -} - - -1; diff --git a/ACE/bin/DependencyGenerator/ObjectGeneratorFactory.pm b/ACE/bin/DependencyGenerator/ObjectGeneratorFactory.pm deleted file mode 100644 index e161db948ab..00000000000 --- a/ACE/bin/DependencyGenerator/ObjectGeneratorFactory.pm +++ /dev/null @@ -1,35 +0,0 @@ -package ObjectGeneratorFactory; - -# ************************************************************ -# Description : Create ObjectGenerator objects. -# Author : Chad Elliott -# Create Date : 5/23/2003 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; - -use GNUObjectGenerator; -use NMakeObjectGenerator; -use MakeObjectGenerator; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub create { - switch: { - $_[0] eq 'gnu' && do { return new GNUObjectGenerator(); }; - $_[0] eq 'nmake' && do { return new NMakeObjectGenerator(); }; - $_[0] eq 'make' && do { return new MakeObjectGenerator(); }; - print STDERR "WARNING: Invalid object generator type: $_[0]\n"; - } - - return new ObjectGenerator(); -} - - -1; diff --git a/ACE/bin/DependencyGenerator/Preprocessor.pm b/ACE/bin/DependencyGenerator/Preprocessor.pm deleted file mode 100644 index 66e5d206b66..00000000000 --- a/ACE/bin/DependencyGenerator/Preprocessor.pm +++ /dev/null @@ -1,147 +0,0 @@ -package Preprocessor; - -# ************************************************************ -# Description : Preprocesses the supplied file. -# Author : Chad Elliott -# Create Date : 2/10/2002 -# ************************************************************ - -# ************************************************************ -# Pragmas -# ************************************************************ - -use strict; -use FileHandle; -use File::Basename; - -# ************************************************************ -# Subroutine Section -# ************************************************************ - -sub new { - my($class) = shift; - my($macros) = shift; - my($ipaths) = shift; - my($exclude) = shift; - return bless {'macros' => $macros, - 'ipaths' => $ipaths, - 'exclude' => $exclude, - 'files' => {}, - 'ifound' => {}, - 'recurse' => 0, - }, $class; -} - - -sub process { - my($self) = shift; - my($file) = shift; - my($noinline) = shift; - my($noincs) = shift; - my($fh) = new FileHandle(); - - if (open($fh, $file)) { - my($ifcount) = 0; - my(@zero) = (); - my($files) = $self->{'files'}; - my($recurse) = ++$self->{'recurse'}; - my($dir) = dirname($file); - - $$files{$file} = []; - while(<$fh>) { - ## As an optimization, use a very simple regular expression on the - ## outside that all of the inner regular expressions have in - ## common. That way we go down the path of if elsif only if it is - ## even possible due to the outside regular expression. - ## index() is faster than a regular expression, so use index first. - next if (index($_, '#') == -1 || not /^\s*#/); - - ## Remove same line c comments (no need to worry about c++ - ## comments due to the regular expressions) inside this if statement. - ## This saves about 5% off of processing the ace directory - ## and we only need to strip comments if we are actually - ## going to look at the string. - $_ =~ s/\/\*.*\*\///o; - - if (/^\s*#\s*endif/) { - --$ifcount; - if (defined $zero[0] && $ifcount == $zero[$#zero]) { - pop(@zero); - } - } - elsif (/^\s*#\s*if\s+0/) { - push(@zero, $ifcount); - ++$ifcount; - } - elsif (/^\s*#\s*if/) { - ++$ifcount; - } - elsif (!defined $zero[0] && - /^\s*#\s*include\s+[<"]([^">]+)[">]/o) { - ## Locate the include file - my($inc) = undef; - if (exists $self->{'ifound'}->{$1}) { - $inc = $self->{'ifound'}->{$1}; - } - else { - foreach my $dirp (@{$self->{'ipaths'}}) { - if (-r "$dirp/$1") { - $inc = "$dirp/$1"; - last; - } - } - - if (!defined $inc) { - ## If the file we're currently looking at contains a - ## directory name then, we need to look for include - ## files in that directory. - if (-r "$dir/$1") { - $inc = "$dir/$1"; - } - } - $self->{'ifound'}->{$1} = $inc; - } - - ## If we've found the include file, then process it too. - next if (not defined $inc); - - $inc =~ s/\\/\//go; - if (!$noinline || - ($recurse == 1 || $inc !~ /\.i(nl)?$/o)) { - push(@{$$files{$file}}, $inc); - if (!defined $$files{$inc}) { - ## Process this file, but do not return the include files - if (!defined $self->{'exclude'}->{substr($inc, rindex($inc, '/') + 1)}) { - $self->process($inc, $noinline, 1); - } - } - } - } - } - close($fh); - - --$self->{'recurse'}; - } - - ## This has to be outside the if (open(... - ## If the last file to be processed isn't accessable then - ## we still need to return the array reference of includes. - if (!$noincs) { - my(@files) = ($file); - my(%ifiles) = (); - - foreach my $processed (@files) { - foreach my $inc (@{$self->{'files'}->{$processed}}) { - if (!defined $ifiles{$inc}) { - $ifiles{$inc} = 1; - push(@files, $inc); - } - } - } - shift(@files); - return \@files; - } -} - - -1; |