summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-04-22 14:19:16 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-04-22 14:19:16 +0000
commitda5ea9fec3cbd0ed12cec911e7b898d3d69a3775 (patch)
tree53489dc94db194095df54b34dd4d3fe8df4ee1be
parentb0478e74f300edebfba9910492a06b0c797f8a17 (diff)
downloadMPC-da5ea9fec3cbd0ed12cec911e7b898d3d69a3775.tar.gz
ChangeLogTag: Tue Apr 22 09:16:29 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/Creator.pm2
-rw-r--r--modules/ProjectCreator.pm14
-rw-r--r--modules/WorkspaceCreator.pm296
3 files changed, 204 insertions, 108 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm
index c1400dda..7da4762a 100644
--- a/modules/Creator.pm
+++ b/modules/Creator.pm
@@ -388,7 +388,7 @@ sub transform_file_name {
my($self) = shift;
my($name) = shift;
- $name =~ s/[\s\/\\]/_/g;
+ $name =~ s/\s/_/g;
return $name;
}
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index b7bee0b9..7dddf6ae 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -287,7 +287,14 @@ sub parse_line {
if (defined $name) {
$name =~ s/^\(\s*//;
$name =~ s/\s*\)$//;
- $self->process_assignment('project_name', $name);
+ if ($name =~ /[\/\\]/) {
+ $status = 0;
+ $errorString = 'ERROR: Projects can not have a slash ' .
+ 'or a back slash in the name';
+ }
+ else {
+ $self->process_assignment('project_name', $name);
+ }
}
$self->{$typecheck} = 1;
@@ -1259,6 +1266,11 @@ sub generate_defaults {
$self->process_assignment('project_name', $self->base_directory());
}
else {
+ ## Since files on UNIX can have back slashes, we transform them
+ ## into underscores.
+ $current =~ s/\\/_/g;
+
+ ## Take off the extension
$current =~ s/\.[^\.]+$//;
$self->process_assignment('project_name', $current);
}
diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm
index 2901fdac..6898dd04 100644
--- a/modules/WorkspaceCreator.pm
+++ b/modules/WorkspaceCreator.pm
@@ -70,6 +70,8 @@ sub new {
$self->{'project_files'} = [];
$self->{'scoped_assign'} = {};
$self->{'cacheok'} = 1;
+ $self->{'exclude'} = {};
+ $self->{'wctype'} = $self->extractType("$self");
return $self;
}
@@ -156,7 +158,14 @@ sub parse_line {
if (defined $name) {
$name =~ s/^\(\s*//;
$name =~ s/\s*\)$//;
- $self->{'workspace_name'} = $name;
+ if ($name =~ /[\/\\]/) {
+ $status = 0;
+ $errorString = 'ERROR: Workspaces can not have a slash ' .
+ 'or a back slash in the name';
+ }
+ else {
+ $self->{'workspace_name'} = $name;
+ }
}
$self->{$typecheck} = 1;
}
@@ -189,10 +198,16 @@ sub parse_line {
}
}
elsif ($values[0] eq 'component') {
- ($status, $errorString) = $self->parse_scope($ih,
- $values[1],
- $values[2],
- \%validNames);
+ if ($values[1] eq 'exclude') {
+ ($status, $errorString) = $self->parse_exclude($ih,
+ $values[2]);
+ }
+ else {
+ ($status, $errorString) = $self->parse_scope($ih,
+ $values[1],
+ $values[2],
+ \%validNames);
+ }
}
else {
$errorString = "ERROR: Unrecognized line: $line";
@@ -208,6 +223,62 @@ sub parse_line {
}
+sub parse_exclude {
+ my($self) = shift;
+ my($fh) = shift;
+ my($typestr) = shift;
+ my($status) = 0;
+ my($errorString) = 'ERROR: Unable to process exclude';
+
+ if ($typestr eq 'default') {
+ $errorString = 'ERROR: You must specify a project type ' .
+ 'for exclusions';
+ }
+ else {
+ my(@types) = split(/\s+/, $typestr);
+ my(@exclude) = ();
+
+ while(<$fh>) {
+ my($line) = $self->strip_line($_);
+
+ if ($line eq '') {
+ }
+ elsif ($line =~ /^}/) {
+ $status = 1;
+ $errorString = '';
+ last;
+ }
+ else {
+ push(@exclude, $line);
+ }
+ }
+
+ foreach my $type (@types) {
+ if (!defined $self->{'exclude'}->{$type}) {
+ $self->{'exclude'}->{$type} = [];
+ }
+ push(@{$self->{'exclude'}->{$type}}, @exclude);
+ }
+ }
+
+ return $status, $errorString;
+}
+
+
+sub excluded {
+ my($self) = shift;
+ my($file) = shift;
+
+ foreach my $excluded (@{$self->{'exclude'}->{$self->{'wctype'}}}) {
+ if ($excluded eq $file || $file =~ /$excluded\//) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
sub handle_scoped_unknown {
my($self) = shift;
my($fh) = shift;
@@ -295,14 +366,16 @@ sub generate_default_components {
## If we have files, then process directories
my(@built) = ();
foreach my $file (@$pjf) {
- if (-d $file) {
- my(@found) = ();
- my(@gen) = $self->generate_default_file_list($file);
- $self->search_for_files(\@gen, \@exts, \@found);
- push(@built, @found);
- }
- else {
- push(@built, $file);
+ if (!$self->excluded($file)) {
+ if (-d $file) {
+ my(@found) = ();
+ my(@gen) = $self->generate_default_file_list($file);
+ $self->search_for_files(\@gen, \@exts, \@found);
+ push(@built, @found);
+ }
+ else {
+ push(@built, $file);
+ }
}
}
@@ -346,6 +419,11 @@ sub generate_defaults {
$self->{'workspace_name'} = $self->base_directory();
}
else {
+ ## Since files on UNIX can have back slashes, we transform them
+ ## into underscores.
+ $current =~ s/\\/_/g;
+
+ ## Take off the extension
$current =~ s/\.[^\.]+$//;
$self->{'workspace_name'} = $current;
}
@@ -429,7 +507,7 @@ sub save_project_info {
sub generate_project_files {
my($self) = shift;
- my($status) = 0;
+ my($status) = (scalar @{$self->{'project_files'}} == 0 ? 1 : 0);
my(@projects) = ();
my(%pi) = ();
my($generator) = $self->project_creator();
@@ -445,113 +523,119 @@ sub generate_project_files {
$postkey =~ s/=.*//;
foreach my $ofile (@{$self->{'project_files'}}) {
- my($file) = $ofile;
- my($dir) = dirname($file);
- my($restore) = 0;
+ if (!$self->excluded($ofile)) {
+ my($file) = $ofile;
+ my($dir) = dirname($file);
+ my($restore) = 0;
+
+ if (defined $self->{'scoped_assign'}->{$ofile}) {
+ ## Handle the implicit assignment
+ my($oi) = $self->{'scoped_assign'}->{$ofile}->{'implicit'};
+ if (defined $oi) {
+ $previmpl = $impl;
+ $impl = $oi;
+ }
- if (defined $self->{'scoped_assign'}->{$ofile}) {
- ## Handle the implicit assignment
- my($oi) = $self->{'scoped_assign'}->{$ofile}->{'implicit'};
- if (defined $oi) {
- $previmpl = $impl;
- $impl = $oi;
- }
+ ## Handle the cmdline assignment
+ my($cmdline) = $self->{'scoped_assign'}->{$ofile}->{'cmdline'};
+ if (defined $cmdline && $cmdline ne '') {
+ ## Save the cacheok value
+ $prevcache = $self->{'cacheok'};
- ## Handle the cmdline assignment
- my($cmdline) = $self->{'scoped_assign'}->{$ofile}->{'cmdline'};
- if (defined $cmdline && $cmdline ne '') {
- ## Save the cacheok value
- $prevcache = $self->{'cacheok'};
+ ## Get the current parameters and process the command line
+ my(%parameters) = $self->current_parameters();
+ $self->process_cmdline($cmdline, \%parameters);
- ## Get the current parameters and process the command line
- my(%parameters) = $self->current_parameters();
- $self->process_cmdline($cmdline, \%parameters);
+ ## Set the parameters on the generator
+ $generator->restore_state(\%parameters);
+ $restore = 1;
+ }
+ }
- ## Set the parameters on the generator
- $generator->restore_state(\%parameters);
- $restore = 1;
+ ## If we are generating implicit projects and the file is a
+ ## directory, then we set the dir to the file and empty the file
+ if ($impl && -d $file) {
+ $dir = $file;
+ $file = '';
}
- }
- ## If we are generating implicit projects and the file is a
- ## directory, then we set the dir to the file and empty the file
- if ($impl && -d $file) {
- $dir = $file;
- $file = '';
- }
+ ## Generate the key for this project file
+ my($prkey) = $self->getcwd() . "/$file-$postkey";
+
+ ## We must change to the subdirectory for
+ ## which this project file is intended
+ if ($self->cd($dir)) {
+ my($gen) = [];
+ my($gpi) = [];
+ if ($self->{'cacheok'} && defined $allprojects{$prkey}) {
+ $gen = $allprojects{$prkey};
+ $gpi = $allprinfo{$prkey};
+ $status = 1;
+ }
+ else {
+ $status = $generator->generate(basename($file));
+
+ ## If any one project file fails, then stop
+ ## processing altogether.
+ if (!$status) {
+ ## We don't restore the state before we leave,
+ ## but that's ok since we will be exiting soon.
+ return $status, $generator;
+ }
- ## Generate the key for this project file
- my($prkey) = $self->getcwd() . "/$file-$postkey";
-
- ## We must change to the subdirectory for
- ## which this project file is intended
- if ($self->cd($dir)) {
- my($gen) = [];
- my($gpi) = [];
- if ($self->{'cacheok'} && defined $allprojects{$prkey}) {
- $gen = $allprojects{$prkey};
- $gpi = $allprinfo{$prkey};
- $status = 1;
+ ## Get the individual project information and
+ ## generated file name(s)
+ $gen = $generator->get_files_written();
+ $gpi = $generator->get_project_info();
+
+ ## If we need to generate a workspace file per project
+ ## then we generate a temporary project info and projects
+ ## array and call write_project().
+ if ($dir ne '.' && defined $$gen[0] && $self->workspace_per_project()) {
+ my(%perpi) = ();
+ my(@perprojects) = ();
+ $self->save_project_info($gen, $gpi, '.', \@perprojects, \%perpi);
+
+ ## Set our per project information
+ $self->{'projects'} = \@perprojects;
+ $self->{'project_info'} = \%perpi;
+
+ ## Write our per project workspace
+ $self->write_workspace($generator);
+
+ ## Reset our project information to empty
+ $self->{'projects'} = [];
+ $self->{'project_info'} = {};
+ }
+
+ if ($self->{'cacheok'}) {
+ $allprojects{$prkey} = $gen;
+ $allprinfo{$prkey} = $gpi;
+ }
+ }
+ $self->cd($cwd);
+ $self->save_project_info($gen, $gpi, $dir, \@projects, \%pi);
}
else {
- $status = $generator->generate(basename($file));
-
- ## If any one project file fails, then stop
- ## processing altogether.
- if (!$status) {
- ## We don't restore the state before we leave,
- ## but that's ok since we will be exiting soon.
- return $status, $generator;
- }
+ ## Unable to change to the directory.
+ ## We don't restore the state before we leave,
+ ## but that's ok since we will be exiting soon.
+ return 0, $generator;
+ }
- ## Get the individual project information and
- ## generated file name(s)
- $gen = $generator->get_files_written();
- $gpi = $generator->get_project_info();
-
- ## If we need to generate a workspace file per project
- ## then we generate a temporary project info and projects
- ## array and call write_project().
- if ($dir ne '.' && defined $$gen[0] && $self->workspace_per_project()) {
- my(%perpi) = ();
- my(@perprojects) = ();
- $self->save_project_info($gen, $gpi, '.', \@perprojects, \%perpi);
-
- ## Set our per project information
- $self->{'projects'} = \@perprojects;
- $self->{'project_info'} = \%perpi;
-
- ## Write our per project workspace
- $self->write_workspace($generator);
-
- ## Reset our project information to empty
- $self->{'projects'} = [];
- $self->{'project_info'} = {};
- }
+ ## Return things to the way they were
+ if (defined $self->{'scoped_assign'}->{$ofile}) {
+ $impl = $previmpl;
- if ($self->{'cacheok'}) {
- $allprojects{$prkey} = $gen;
- $allprinfo{$prkey} = $gpi;
+ if ($restore) {
+ $self->{'cacheok'} = $prevcache;
+ $generator->restore_state(\%gstate);
}
}
- $self->cd($cwd);
- $self->save_project_info($gen, $gpi, $dir, \@projects, \%pi);
}
else {
- ## Unable to change to the directory.
- ## We don't restore the state before we leave,
- ## but that's ok since we will be exiting soon.
- return 0, $generator;
- }
-
- ## Return things to the way they were
- if (defined $self->{'scoped_assign'}->{$ofile}) {
- $impl = $previmpl;
-
- if ($restore) {
- $self->{'cacheok'} = $prevcache;
- $generator->restore_state(\%gstate);
- }
+ ## This one was excluded, so status is ok
+ $status = 1;
}
}