summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-03-11 20:14:03 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-03-11 20:14:03 +0000
commit3739b778ca4c7f620f0d7f3d5297556a5a3bc080 (patch)
treeb7515d9b15f821d233dabf7f5f920a3c2d7c8ca0
parentbd102b93384794e7665c679169d74f5a78afe2dd (diff)
downloadATCD-3739b778ca4c7f620f0d7f3d5297556a5a3bc080.tar.gz
ChangeLogTag: Tue Mar 11 14:12:46 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--ChangeLog33
-rw-r--r--bin/MakeProjectCreator/USAGE8
-rw-r--r--bin/MakeProjectCreator/modules/Creator.pm31
-rw-r--r--bin/MakeProjectCreator/modules/Driver.pm130
-rw-r--r--bin/MakeProjectCreator/modules/ProjectCreator.pm7
-rw-r--r--bin/MakeProjectCreator/modules/WorkspaceCreator.pm12
6 files changed, 164 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index 57bcc7c5d30..22a98cc4211 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,21 @@
+Tue Mar 11 14:12:46 2003 Chad Elliott <elliott_c@ociweb.com>
+
+ * bin/MakeProjectCreator/USAGE:
+ * bin/MakeProjectCreator/modules/Creator.pm:
+ * bin/MakeProjectCreator/modules/Driver.pm:
+ * bin/MakeProjectCreator/modules/ProjectCreator.pm:
+ * bin/MakeProjectCreator/modules/WorkspaceCreator.pm:
+
+ Added a -recurse option and fixed a problem with changing
+ to non-existent directories.
+
Mon Mar 10 18:10:31 2003 Steve Huston <shuston@riverace.com>
- * ace/ARGV.h: Clarified the behavior of ACE_ARGV's behavior with
- respect to environment variable substitution; it only substitutes
- when the token is itself an environment variable reference and not
- if there's an environment variable reference contained within the
- token. e.g. $HOME will subtitute, $HOME/file will not.
+ * ace/ARGV.h: Clarified the behavior of ACE_ARGV's behavior with
+ respect to environment variable substitution; it only substitutes
+ when the token is itself an environment variable reference and not
+ if there's an environment variable reference contained within the
+ token. e.g. $HOME will subtitute, $HOME/file will not.
Mon Mar 10 14:03:11 2003 Chad Elliott <elliott_c@ociweb.com>
@@ -134,13 +145,13 @@ Thu Mar 6 18:14:21 2003 Steve Huston <shuston@riverace.com>
is that the separate template closure step is also used for
shared libraries, and thus, +inst_none needed to be added to
SOFLAGS.
- Also set AR to /usr/ccs/bin/ar to be sure to pick up the native
- HP-supplied ar command.
+ Also set AR to /usr/ccs/bin/ar to be sure to pick up the native
+ HP-supplied ar command.
- * examples/C++NPv1/Process_Per_Connection_Logging_Server.cpp: Don't
- reinterpret_cast on non-Windows. Not needed and aC++ complains.
- Also see:
- Wed Feb 19 10:41:20 2003 Steve Huston <shuston@riverace.com>
+ * examples/C++NPv1/Process_Per_Connection_Logging_Server.cpp: Don't
+ reinterpret_cast on non-Windows. Not needed and aC++ complains.
+ Also see:
+ Wed Feb 19 10:41:20 2003 Steve Huston <shuston@riverace.com>
Thu Mar 6 14:49:37 2003 Steve Huston <shuston@riverace.com>
diff --git a/bin/MakeProjectCreator/USAGE b/bin/MakeProjectCreator/USAGE
index e7cc3c950fd..6d031d06bbb 100644
--- a/bin/MakeProjectCreator/USAGE
+++ b/bin/MakeProjectCreator/USAGE
@@ -9,7 +9,7 @@ script was started. It looks for .mpc files and generates a project or
projects for each one found.
-Usage: mwc.pl [-global <file>] [-include <directory>]
+Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse]
[-ti <dll | lib | dll_exe | lib_exe>:<file>]
[-template <file>] [-dynamic_only] [-static_only]
[-relative NAME=VAR] [-noreldefs] [-notoplevel]
@@ -30,6 +30,8 @@ Usage: mwc.pl [-global <file>] [-include <directory>]
-template Specifies the template name (with no extension).
-dynamic_only Specifies that only dynamic projects will be generated.
-static_only Specifies that only static projects will be generated.
+ -recurse Recurse from the current directory and generate from
+ all found input files.
-relative Any $() variable in an mpc that is matched to NAME
is replaced by VAR only if VAR can be made into a
relative path based on the current working directory.
@@ -100,7 +102,7 @@ file) is not provided, the project creator will attempt to create a default
project in the directory from which the script was started.
-Usage: mpc.pl [-global <file>] [-include <directory>]
+Usage: mpc.pl [-global <file>] [-include <directory>] [-recurse]
[-ti <dll | lib | dll_exe | lib_exe>:<file>]
[-template <file>] [-dynamic_only] [-static_only]
[-relative NAME=VAR] [-noreldefs] [-notoplevel]
@@ -121,6 +123,8 @@ Usage: mpc.pl [-global <file>] [-include <directory>]
-template Specifies the template name (with no extension).
-dynamic_only Specifies that only dynamic projects will be generated.
-static_only Specifies that only static projects will be generated.
+ -recurse Recurse from the current directory and generate from
+ all found input files.
-relative Any $() variable in an mpc that is matched to NAME
is replaced by VAR only if VAR can be made into a
relative path based on the current working directory.
diff --git a/bin/MakeProjectCreator/modules/Creator.pm b/bin/MakeProjectCreator/modules/Creator.pm
index 06bb973806f..8605b2eb788 100644
--- a/bin/MakeProjectCreator/modules/Creator.pm
+++ b/bin/MakeProjectCreator/modules/Creator.pm
@@ -411,10 +411,41 @@ sub get_files_written {
return $self->{'files_written'};
}
+
+sub extension_recursive_input_list {
+ my($self) = shift;
+ my($dir) = shift;
+ my($ext) = shift;
+ my($fh) = new FileHandle();
+ my(@files) = ();
+
+ if (opendir($fh, $dir)) {
+ foreach my $file (grep(!/^\.\.?$/, readdir($fh))) {
+ my($full) = ($dir ne '.' ? "$dir/" : '') . $file;
+ if (-d $full) {
+ push(@files, $self->extension_recursive_input_list($full, $ext));
+ }
+ elsif ($full =~ /$ext$/) {
+ push(@files, $full);
+ }
+ }
+ closedir($fh);
+ }
+
+ return @files;
+}
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************
+sub generate_recursive_input_list {
+ #my($self) = shift;
+ #my($dir) = shift;
+ return ();
+}
+
+
sub crlf {
#my($self) = shift;
return "\n";
diff --git a/bin/MakeProjectCreator/modules/Driver.pm b/bin/MakeProjectCreator/modules/Driver.pm
index 76a759a23f8..a5be9e65179 100644
--- a/bin/MakeProjectCreator/modules/Driver.pm
+++ b/bin/MakeProjectCreator/modules/Driver.pm
@@ -23,7 +23,7 @@ use vars qw(@ISA);
# ************************************************************
my($index) = 0;
-my(@progress) = ("|", "/", "-", "\\");
+my(@progress) = ('|', '/', '-', '\\');
my($cmdenv) = 'MPC_COMMANDLINE';
# ************************************************************
@@ -39,7 +39,7 @@ sub new {
$self->{'path'} = $path;
$self->{'name'} = $name;
- $self->{'version'} = 1.3;
+ $self->{'version'} = 1.4;
$self->{'types'} = {};
$self->{'creators'} = \@creators;
$self->{'default'} = $creators[0];
@@ -56,9 +56,9 @@ sub usageAndExit {
if (defined $line) {
print STDERR "$line\n";
}
- my($spaces) = (" " x (length($base) + 8));
+ my($spaces) = (' ' x (length($base) + 8));
print STDERR "$base v$self->{'version'}\n" .
- "Usage: $base [-global <file>] [-include <directory>]\n" .
+ "Usage: $base [-global <file>] [-include <directory>] [-recurse]\n" .
$spaces . "[-ti <dll | lib | dll_exe | lib_exe>:<file>]\n" .
$spaces . "[-template <file>] " .
"[-dynamic_only] [-static_only]\n" .
@@ -69,9 +69,9 @@ sub usageAndExit {
my(@keys) = sort keys %{$self->{'types'}};
for(my $i = 0; $i <= $#keys; $i++) {
- print STDERR "$keys[$i]";
+ print STDERR $keys[$i];
if ($i != $#keys) {
- print STDERR " | ";
+ print STDERR ' | ';
}
if ((($i + 1) % 6) == 0) {
print STDERR "\n$spaces ";
@@ -93,6 +93,8 @@ sub usageAndExit {
" -template Specifies the template name (with no extension).\n" .
" -dynamic_only Specifies that only dynamic projects will be generated.\n" .
" -static_only Specifies that only static projects will be generated.\n" .
+" -recurse Recurse from the current directory and generate from\n" .
+" all found input files.\n" .
" -relative Any \$() variable in an mpc that is matched to NAME\n" .
" is replaced by VAR only if VAR can be made into a\n" .
" relative path based on the current working directory.\n" .
@@ -155,6 +157,7 @@ sub run {
my(%relative) = ();
my($reldefs) = 1;
my($toplevel) = 1;
+ my($recurse) = 0;
my(%addtemp) = ();
my(%addproj) = ();
@@ -183,7 +186,7 @@ sub run {
elsif ($arg eq '-type') {
$i++;
if (!defined $args[$i]) {
- $self->usageAndExit("-type requires an argument");
+ $self->usageAndExit('-type requires an argument');
}
my($type) = lc($args[$i]);
@@ -208,14 +211,14 @@ sub run {
$i++;
$global = $args[$i];
if (!defined $global) {
- $self->usageAndExit("-global requires a file name argument");
+ $self->usageAndExit('-global requires a file name argument');
}
}
elsif ($arg eq '-include') {
$i++;
my($include) = $args[$i];
if (!defined $include) {
- $self->usageAndExit("-include requires a directory argument");
+ $self->usageAndExit('-include requires a directory argument');
}
push(@include, $include);
}
@@ -225,18 +228,21 @@ sub run {
elsif ($arg eq '-notoplevel') {
$toplevel = 0;
}
+ elsif ($arg eq '-recurse') {
+ $recurse = 1;
+ }
elsif ($arg eq '-template') {
$i++;
$template = $args[$i];
if (!defined $template) {
- $self->usageAndExit("-template requires a file name argument");
+ $self->usageAndExit('-template requires a file name argument');
}
}
elsif ($arg eq '-relative') {
$i++;
my($rel) = $args[$i];
if (!defined $rel) {
- $self->usageAndExit("-relative requires a variable assignment argument");
+ $self->usageAndExit('-relative requires a variable assignment argument');
}
else {
if ($rel =~ /(\w+)\s*=\s*(.*)/) {
@@ -247,7 +253,7 @@ sub run {
$relative{$name} = $val;
}
else {
- $self->usageAndExit("Invalid option to -relative");
+ $self->usageAndExit('Invalid option to -relative');
}
}
}
@@ -255,7 +261,7 @@ sub run {
$i++;
my($tmpi) = $args[$i];
if (!defined $tmpi) {
- $self->usageAndExit("-ti requires a template input argument");
+ $self->usageAndExit('-ti requires a template input argument');
}
else {
if ($tmpi =~ /(dll|lib|dll_exe|lib_exe):(.*)/) {
@@ -272,7 +278,7 @@ sub run {
$i++;
my($value) = $args[$i];
if (!defined $value) {
- $self->usageAndExit("-value_template requires a variable assignment argument");
+ $self->usageAndExit('-value_template requires a variable assignment argument');
}
else {
if ($value =~ /(\w+)\s*([\-+]?=)\s*(.*)/) {
@@ -281,10 +287,10 @@ sub run {
my($val) = $3;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
- if ($op eq "+=") {
+ if ($op eq '+=') {
$op = 1;
}
- elsif ($op eq "-=") {
+ elsif ($op eq '-=') {
$op = -1;
}
else {
@@ -293,7 +299,7 @@ sub run {
$addtemp{$name} = [$op, $val];
}
else {
- $self->usageAndExit("Invalid option to -value_template");
+ $self->usageAndExit('Invalid option to -value_template');
}
}
}
@@ -301,7 +307,7 @@ sub run {
$i++;
my($value) = $args[$i];
if (!defined $value) {
- $self->usageAndExit("-value_project requires a variable assignment argument");
+ $self->usageAndExit('-value_project requires a variable assignment argument');
}
else {
if ($value =~ /(\w+)\s*([\-+]?=)\s*(.*)/) {
@@ -310,10 +316,10 @@ sub run {
my($val) = $3;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
- if ($op eq "+=") {
+ if ($op eq '+=') {
$op = 1;
}
- elsif ($op eq "-=") {
+ elsif ($op eq '-=') {
$op = -1;
}
else {
@@ -322,7 +328,7 @@ sub run {
$addproj{$name} = [$op, $val];
}
else {
- $self->usageAndExit("Invalid option to -value_project");
+ $self->usageAndExit('Invalid option to -value_project');
}
}
}
@@ -342,19 +348,54 @@ sub run {
}
}
- ## Set up default values
- if (!defined $input[0]) {
- push(@input, "");
- }
+ ## Set up a hash that we can use to keep track of what
+ ## has been 'required'
+ my(%loaded) = ();
+
+ ## Set up the default generator, if no type is selected
if (!defined $generators[0]) {
push(@generators, $self->{'default'});
}
+
+ if ($recurse) {
+ if (defined $input[0]) {
+ ## This is an error.
+ ## -recurse was used and input files were specified.
+ $self->usageAndExit('No files should be ' .
+ 'specified when using -recurse');
+ }
+ else {
+ ## We have to load at least one generator here in order
+ ## to call the generate_recursive_input_list virtual function.
+ my($name) = $generators[0];
+ if (!$loaded{$name}) {
+ require "$name.pm";
+ $loaded{$name} = 1;
+ }
+
+ ## Generate the recursive input list
+ my($generator) = $name->new();
+ @input = $generator->generate_recursive_input_list('.');
+
+ ## If no files were found above, then we issue a warning
+ ## that we are going to use the default input
+ if (!defined $input[0]) {
+ print "WARNING: No files were found using the -recurse option.\n" .
+ " Using the default input.\n";
+ }
+ }
+ }
+
+ ## Set up default values
+ if (!defined $input[0]) {
+ push(@input, '');
+ }
if (!defined $global) {
- $global = $self->{'path'} . "/config/global.mpb";
+ $global = $self->{'path'} . '/config/global.mpb';
}
## Always add the default include paths
- unshift(@include, $self->{'path'} . "/templates");
- unshift(@include, $self->{'path'} . "/config");
+ unshift(@include, $self->{'path'} . '/templates');
+ unshift(@include, $self->{'path'} . '/config');
if ($reldefs) {
if (!defined $relative{'ACE_ROOT'} && defined $ENV{ACE_ROOT}) {
@@ -373,10 +414,6 @@ sub run {
## Set up un-buffered output for the progress callback
$| = 1;
- ## Set up a hash that we can use to keep track of what
- ## has been 'required'
- my(%loaded) = ();
-
## Save the original directory outside of the loop
## to avoid calling it multiple times.
my($orig_dir) = Cwd::getcwd();
@@ -386,10 +423,6 @@ sub run {
## To correctly reference any pathnames in the input file, chdir to
## its directory if there's any directory component to the specified path.
my($base) = basename($file);
- if ($base ne $file) {
- chdir(dirname($file));
- $file = $base;
- }
foreach my $name (@generators) {
if (!$loaded{$name}) {
require "$name.pm";
@@ -400,16 +433,29 @@ sub run {
\%addtemp, \%addproj,
(-t 1 ? \&progress : undef),
$toplevel);
- print "Generating output using " .
- ($file eq "" ? "default input" : $file) . "\n";
- print "Start Time: " . scalar(localtime(time())) . "\n";
+ if ($base ne $file) {
+ my($dir) = dirname($file);
+ if (!$generator->cd($dir)) {
+ print STDERR "ERROR: Unable to change to directory: $dir\n";
+ $status++;
+ last;
+ }
+ $file = $base;
+ }
+ print 'Generating output using ' .
+ ($file eq '' ? 'default input' : $file) . "\n";
+ print 'Start Time: ' . scalar(localtime(time())) . "\n";
if (!$generator->generate($file)) {
- print STDERR "Unable to process: $file\n";
+ print STDERR "ERROR: Unable to process: $file\n";
$status++;
+ last;
}
- print " End Time: " . scalar(localtime(time())) . "\n";
+ print ' End Time: ' . scalar(localtime(time())) . "\n";
+ $generator->cd($orig_dir);
+ }
+ if ($status) {
+ last;
}
- chdir($orig_dir);
}
return $status;
diff --git a/bin/MakeProjectCreator/modules/ProjectCreator.pm b/bin/MakeProjectCreator/modules/ProjectCreator.pm
index 7f3a607e71e..be0d58eb4db 100644
--- a/bin/MakeProjectCreator/modules/ProjectCreator.pm
+++ b/bin/MakeProjectCreator/modules/ProjectCreator.pm
@@ -1476,6 +1476,13 @@ sub get_verbatim {
}
+sub generate_recursive_input_list {
+ my($self) = shift;
+ my($dir) = shift;
+ return $self->extension_recursive_input_list($dir,
+ $ProjectCreatorExtension);
+}
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************
diff --git a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm
index 3a53b6ac2be..b9679c1138f 100644
--- a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm
+++ b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm
@@ -24,6 +24,8 @@ use vars qw(@ISA);
# Data Section
# ************************************************************
+my($wsext) = 'mwc';
+
# ************************************************************
# Subroutine Section
# ************************************************************
@@ -105,12 +107,12 @@ sub parse_line {
if (defined $parents) {
foreach my $parent (@$parents) {
## Read in the parent onto ourself
- my($file) = $self->search_include_path("$parent.mwc");
+ my($file) = $self->search_include_path("$parent.$wsext");
if (defined $file) {
my($rp) = $self->{'reading_parent'};
push(@$rp, 1);
- $self->parse_file("$parent.mwc");
+ $self->parse_file("$parent.$wsext");
pop(@$rp);
if (!$status) {
$errorString = "ERROR: Invalid parent: $parent";
@@ -468,6 +470,12 @@ sub get_modified_workspace_name {
}
+sub generate_recursive_input_list {
+ my($self) = shift;
+ my($dir) = shift;
+ return $self->extension_recursive_input_list($dir, $wsext);
+}
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************