diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-08-27 15:33:50 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-08-27 15:33:50 +0000 |
commit | d50fbf3bd28b0f58d2eeb075a8efe3e131c1d22b (patch) | |
tree | 9142a578c833568fb514cd0e2dcf4aa2dde3ec2f | |
parent | 0581a7046f2268036997cd759ee4745874e5ad41 (diff) | |
download | MPC-d50fbf3bd28b0f58d2eeb075a8efe3e131c1d22b.tar.gz |
ChangeLogTag: Wed Aug 27 10:32:03 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/Creator.pm | 10 | ||||
-rw-r--r-- | modules/Driver.pm | 4 | ||||
-rw-r--r-- | modules/Options.pm | 8 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 3 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 90 |
5 files changed, 109 insertions, 6 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm index 1f8a2261..b6d6cf5a 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -26,7 +26,7 @@ use vars qw(@ISA); my(@statekeys) = ('global', 'include', 'template', 'ti', 'dynamic', 'static', 'relative', 'addtemp', 'addproj', 'progress', 'toplevel', 'baseprojs', - 'feature_file', + 'feature_file', 'hierarchy', ); my(%all_written) = (); @@ -50,6 +50,7 @@ sub new { my($toplevel) = shift; my($baseprojs) = shift; my($feature) = shift; + my($hierarchy) = shift; my($type) = shift; my($self) = Parser::new($class, $inc); @@ -73,6 +74,7 @@ sub new { $self->{'dynamic'} = $dynamic; $self->{'static'} = $static; $self->{'feature_file'} = $feature; + $self->{'hierarchy'} = $hierarchy; return $self; } @@ -747,6 +749,12 @@ sub get_default_component_name { return 'default'; } + +sub get_hierarchy { + my($self) = shift; + return $self->{'hierarchy'}; +} + # ************************************************************ # Virtual Methods To Be Overridden # ************************************************************ diff --git a/modules/Driver.pm b/modules/Driver.pm index 108ce125..f81cd5ac 100644 --- a/modules/Driver.pm +++ b/modules/Driver.pm @@ -96,7 +96,7 @@ sub optionError { my($spaces) = (' ' x (length($base) + 8)); print STDERR "$base v$self->{'version'}\n" . "Usage: $base [-global <file>] [-include <directory>] [-recurse[=dir1,...]]\n" . - $spaces . "[-ti <dll | lib | dll_exe | lib_exe>:<file>]\n" . + $spaces . "[-ti <dll | lib | dll_exe | lib_exe>:<file>] [-hierarchy]\n" . $spaces . "[-template <file>] [-relative NAME=VAR] [-base <project>]\n" . $spaces . "[-noreldefs] [-notoplevel] [-static] [-static_only]\n" . $spaces . "[-value_template <NAME+=VAL | NAME=VAL | NAME-=VAL>]\n" . @@ -126,6 +126,7 @@ sub optionError { " config directory.\n" . " -global Specifies the global input file. Values stored\n" . " within this file are applied to all projects.\n" . +" -hierarchy Generate a workspace in a hierarchical fashion.\n" . " -include Specifies a directory to search when looking for base\n" . " projects, template input files and templates. This\n" . " option can be used multiple times to add directories.\n" . @@ -330,6 +331,7 @@ sub run { $options->{'baseprojs'}, $global_feature_file, $options->{'feature_file'}, + $options->{'hierarchy'}, $options->{'coexistence'}); if ($base ne $file) { my($dir) = ($base eq '' ? $file : dirname($file)); diff --git a/modules/Options.pm b/modules/Options.pm index 7862efa8..008ec6d7 100644 --- a/modules/Options.pm +++ b/modules/Options.pm @@ -29,7 +29,8 @@ sub completion_command { my($str) = "complete $name " . "'c/-/(global include type template relative " . "ti static noreldefs notoplevel feature_file " . - "value_template value_project make_coexistence)/' " . + "value_template value_project make_coexistence " . + "hierarchy)/' " . "'c/dll:/f/' 'c/dll_exe:/f/' 'c/lib_exe:/f/' 'c/lib:/f/' " . "'n/-ti/(dll lib dll_exe lib_exe)/:' 'n/-type/("; @@ -63,6 +64,7 @@ sub options { my($template) = undef; my($feature_f) = undef; my($recurse) = undef; + my($hierarchy) = 0; my($dynamic) = ($defaults ? 1 : undef); my($reldefs) = ($defaults ? 1 : undef); my($toplevel) = ($defaults ? 1 : undef); @@ -124,6 +126,9 @@ sub options { $self->optionError('-global requires a file name argument'); } } + elsif ($arg eq '-hierarchy') { + $hierarchy = 1; + } elsif ($arg eq '-include') { $i++; my($include) = $args[$i]; @@ -286,6 +291,7 @@ sub options { 'addtemp' => \%addtemp, 'addproj' => \%addproj, 'coexistence' => $makeco, + 'hierarchy' => $hierarchy, ); return \%options; diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 9b12a2ca..d1f55e15 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -145,12 +145,13 @@ sub new { my($baseprojs) = shift; my($gfeature) = shift; my($feature) = shift; + my($hierarchy) = shift; my($makeco) = shift; my($self) = Creator::new($class, $global, $inc, $template, $ti, $dynamic, $static, $relative, $addtemp, $addproj, $progress, $toplevel, $baseprojs, - $feature, 'project'); + $feature, $hierarchy, 'project'); $self->{$self->{'type_check'}} = 0; $self->{'feature_defined'} = 0; diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index 89618c48..cdb8f5ff 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -61,12 +61,13 @@ sub new { my($baseprojs) = shift; my($gfeature) = shift; my($feature) = shift; + my($hierarchy) = shift; my($makeco) = shift; my($self) = Creator::new($class, $global, $inc, $template, $ti, $dynamic, $static, $relative, $addtemp, $addproj, $progress, $toplevel, $baseprojs, - $feature, 'workspace'); + $feature, $hierarchy, 'workspace'); my($typecheck) = $self->{'type_check'}; $self->{'workspace_name'} = undef; @@ -593,6 +594,83 @@ sub save_project_info { } +sub topname { + my($self) = shift; + my($file) = shift; + my($dir) = '.'; + my($rest) = $file; + if ($file =~ /^([^\/\\]+)[\/\\](.*)/) { + $dir = $1; + $rest = $2; + } + return $dir, $rest; +} + + +sub generate_hierarchy { + my($self) = shift; + my($generator) = shift; + my($origproj) = shift; + my($originfo) = shift; + my($current) = undef; + my(@saved) = (); + my(%sinfo) = (); + my($cwd) = $self->getcwd(); + + ## Make a copy of these. We will be modifying them. + my(@projects) = sort @{$origproj}; + my(%projinfo) = %{$originfo}; + + foreach my $prj (@projects) { + my($top, $rest) = $self->topname($prj); + + + if (!defined $current) { + $current = $top; + push(@saved, $rest); + $sinfo{$rest} = $projinfo{$prj}; + } + elsif ($top ne $current) { + ## Write out the hierachical workspace + $self->cd($current); + $self->generate_hierarchy($generator, \@saved, \%sinfo); + + $self->{'projects'} = \@saved; + $self->{'project_info'} = \%sinfo; + $self->{'workspace_name'} = $self->base_directory(); + my($status, $error) = $self->write_workspace($generator); + if (!$status) { + print STDERR "$error\n"; + } + $self->cd($cwd); + + ## Start the next one + $current = $top; + @saved = ($rest); + %sinfo = (); + $sinfo{$rest} = $projinfo{$prj}; + } + else { + push(@saved, $rest); + $sinfo{$rest} = $projinfo{$prj}; + } + } + if (defined $current && $current ne '.') { + $self->cd($current); + $self->generate_hierarchy($generator, \@saved, \%sinfo); + + $self->{'projects'} = \@saved; + $self->{'project_info'} = \%sinfo; + $self->{'workspace_name'} = $self->base_directory(); + my($status, $error) = $self->write_workspace($generator); + if (!$status) { + print STDERR "$error\n"; + } + $self->cd($cwd); + } +} + + sub generate_project_files { my($self) = shift; my($status) = (scalar @{$self->{'project_files'}} == 0 ? 1 : 0); @@ -689,7 +767,8 @@ 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 '.' && defined $$gen[0] && $self->workspace_per_project()) { + if ($dir ne '.' && defined $$gen[0] && + $self->workspace_per_project() && !$self->get_hierarchy()) { my(%perpi) = (); my(@perprojects) = (); $self->save_project_info($gen, $gpi, '.', \@perprojects, \%perpi); @@ -740,6 +819,12 @@ sub generate_project_files { } } + if ($self->get_hierarchy()) { + my($orig) = $self->{'workspace_name'}; + $self->generate_hierarchy($generator, \@projects, \%pi); + $self->{'workspace_name'} = $orig; + } + $self->{'projects'} = \@projects; $self->{'project_info'} = \%pi; @@ -943,6 +1028,7 @@ sub project_creator { $parameters{'baseprojs'}, $self->{'global_feature_file'}, $parameters{'feature_file'}, + $parameters{'hierarchy'}, $self->make_coexistence()); } |