summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-03-31 20:04:08 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-03-31 20:04:08 +0000
commit6704372997f35c2fbed196b9473334831ad3248f (patch)
treee4f286e34c06823537253e42ceeb00237045f97d
parenta7b2198a3a3c1b1b9020c1619b3f7b4d39ad462e (diff)
downloadMPC-6704372997f35c2fbed196b9473334831ad3248f.tar.gz
ChangeLogTag: Mon Mar 31 14:03:35 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/ProjectCreator.pm61
-rw-r--r--modules/WorkspaceCreator.pm54
2 files changed, 90 insertions, 25 deletions
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index ebac1b4b..f04353b4 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -1276,6 +1276,23 @@ sub get_component_list {
}
+sub need_to_write_project {
+ my($self) = shift;
+ foreach my $key (keys %{$self->{'valid_components'}}) {
+ my($names) = $self->{$key};
+ foreach my $name (keys %$names) {
+ foreach my $key (sort keys %{$names->{$name}}) {
+ if (defined $names->{$name}->{$key}->[0]) {
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+
sub write_output_file {
my($self) = shift;
my($name) = shift;
@@ -1346,29 +1363,31 @@ sub write_project {
&$progress();
}
- ## Writing the non-static file so set it to 0
- if ($self->{'want_dynamic_projects'}) {
- $self->{'writing_type'} = 0;
- $self->process_assignment('project_name',
- $prjname . $self->get_type_append());
- ($status, $error) = $self->write_output_file($name);
- }
+ if ($self->need_to_write_project()) {
+ ## Writing the non-static file so set it to 0
+ if ($self->{'want_dynamic_projects'}) {
+ $self->{'writing_type'} = 0;
+ $self->process_assignment('project_name',
+ $prjname . $self->get_type_append());
+ ($status, $error) = $self->write_output_file($name);
+ }
- if ($status && $self->{'want_static_projects'} &&
- $self->separate_static_project()) {
- ## Set the project name back to what it originally was
- $self->process_assignment('project_name', $prjname);
- $name = $self->transform_file_name($self->static_project_file_name());
-
- ## Writing the static file so set it to 1
- $self->{'writing_type'} = 1;
- $self->process_assignment('project_name',
- $prjname . $self->get_type_append());
- ($status, $error) = $self->write_output_file($name);
- }
+ if ($status && $self->{'want_static_projects'} &&
+ $self->separate_static_project()) {
+ ## Set the project name back to what it originally was
+ $self->process_assignment('project_name', $prjname);
+ $name = $self->transform_file_name($self->static_project_file_name());
+
+ ## Writing the static file so set it to 1
+ $self->{'writing_type'} = 1;
+ $self->process_assignment('project_name',
+ $prjname . $self->get_type_append());
+ ($status, $error) = $self->write_output_file($name);
+ }
- if (!$status) {
- print STDERR "$error\n";
+ if (!$status) {
+ print STDERR "$error\n";
+ }
}
return $status;
diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm
index 7d51b9b2..232bc2af 100644
--- a/modules/WorkspaceCreator.pm
+++ b/modules/WorkspaceCreator.pm
@@ -28,7 +28,8 @@ use vars qw(@ISA);
my($wsext) = 'mwc';
## Valid names for assignments within a workspace
-my(%validNames) = ('cmdline' => 1,
+my(%validNames) = ('cmdline' => 1,
+ 'implicit' => 1,
);
# ************************************************************
@@ -188,17 +189,20 @@ sub search_for_files {
my($files) = shift;
my($exts) = shift;
my($array) = shift;
+ my($impl) = $self->get_assignment('implicit');
foreach my $file (@$files) {
if (-d $file) {
my(@f) = $self->generate_default_file_list($file);
$self->search_for_files(\@f, $exts, $array);
+ if ($impl) {
+ unshift(@$array, $file);
+ }
}
else {
foreach my $ext (@$exts) {
if ($file =~ /$ext$/) {
unshift(@$array, $file);
- last;
}
}
}
@@ -206,11 +210,32 @@ sub search_for_files {
}
+sub remove_duplicate_projects {
+ my($self) = shift;
+ my($list) = shift;
+ my($count) = scalar(@$list);
+
+ for(my $i = 0; $i < $count; ++$i) {
+ my($file) = $$list[$i];
+ foreach my $inner (@$list) {
+ if ($file ne $inner && $file eq dirname($inner) && ! -d $inner) {
+ splice(@$list, $i, 1);
+ --$count;
+ --$i;
+ last;
+ }
+ }
+ }
+}
+
+
sub generate_default_components {
my($self) = shift;
my($files) = shift;
my($pjf) = $self->{'project_files'};
my(@exts) = ('\\.mpc');
+ my($impl) = $self->get_assignment('implicit');
+
if (defined $$pjf[0]) {
## If we have files, then process directories
my(@built) = ();
@@ -225,6 +250,14 @@ sub generate_default_components {
push(@built, $file);
}
}
+
+ ## If the workspace is set to implicit
+ if ($impl) {
+ ## Remove duplicates from this list
+ $self->remove_duplicate_projects(\@built);
+ }
+
+ ## Set the project files
$self->{'project_files'} = \@built;
}
else {
@@ -232,6 +265,12 @@ sub generate_default_components {
## and in the subdirectories.
$self->search_for_files($files, \@exts, $pjf);
+ ## If the workspace is set to implicit
+ if ($impl) {
+ ## Remove duplicates from this list
+ $self->remove_duplicate_projects($pjf);
+ }
+
## If no files were found, then we push the empty
## string, so the Project Creator will generate
## the default project file.
@@ -328,10 +367,17 @@ sub generate_project_files {
my(%pi) = ();
my($generator) = $self->project_creator();
my($cwd) = $self->getcwd();
+ my($impl) = $self->get_assignment('implicit');
- foreach my $file (@{$self->{'project_files'}}) {
+ foreach my $ofile (@{$self->{'project_files'}}) {
+ my($file) = $ofile;
my($dir) = dirname($file);
+ if ($impl && -d $file) {
+ $dir = $file;
+ $file = '';
+ }
+
## We must change to the subdirectory for
## which this project file is intended
if ($self->cd($dir)) {
@@ -351,7 +397,7 @@ sub generate_project_files {
## 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 '.' && $self->workspace_per_project()) {
+ if ($dir ne '.' && defined $$gen[0] && $self->workspace_per_project()) {
my(%perpi) = ();
my(@perprojects) = ();
$self->save_project_info($gen, $gpi, '.', \@perprojects, \%perpi);