diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-05-13 14:05:57 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-05-13 14:05:57 +0000 |
commit | 8306dd4bc31fdf0fa2988ee7e493878c424a257e (patch) | |
tree | 6ab8a639a8fa91102062511ecc80ba58e83f6cfb | |
parent | 972c528c027687ecc81bc20b360f59cbbf953da4 (diff) | |
download | ATCD-8306dd4bc31fdf0fa2988ee7e493878c424a257e.tar.gz |
ChangeLogTag: Tue May 13 09:04:18 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | bin/MakeProjectCreator/README | 11 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/Creator.pm | 36 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/ProjectCreator.pm | 48 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/WorkspaceCreator.pm | 43 |
5 files changed, 117 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog index 7afed6a3ea6..0950fb9fccb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue May 13 09:04:18 2003 Chad Elliott <elliott_c@ociweb.com> + + * bin/MakeProjectCreator/README: + * bin/MakeProjectCreator/modules/Creator.pm: + * bin/MakeProjectCreator/modules/ProjectCreator.pm: + * bin/MakeProjectCreator/modules/WorkspaceCreator.pm: + + Added support for dynamic workspace and project names based on the + default project name. Asterisks in the project or workspace name + are replaced by the default name. See the README for more + details. + Tue May 13 07:47:09 2003 Chad Elliott <elliott_c@ociweb.com> * bin/MakeProjectCreator/modules/TemplateParser.pm: diff --git a/bin/MakeProjectCreator/README b/bin/MakeProjectCreator/README index 9e50383e094..3712943176a 100644 --- a/bin/MakeProjectCreator/README +++ b/bin/MakeProjectCreator/README @@ -83,6 +83,17 @@ The (project_name) part of the project declaration is optional. If it is left off, the project name will default to the name of the mpc file without the extension. Inheritance is optional. +If the project name or workspace name contains an asterisk (*) then the +default project (workspace) name will be used in its place. For example, if +the mpc file is named example.mpc and it contains the following: + +project(*client) { + +The project name will be example_client. If the any part of the modified +project (workspace) name contains a capital letter then each word will be +capitalized. For instance, if the above mpc file example was named +Example.mpc, then the modified project name would be Example_Client. + Project Keywords ---------------- diff --git a/bin/MakeProjectCreator/modules/Creator.pm b/bin/MakeProjectCreator/modules/Creator.pm index 7af3fbdd8c4..8f891ceaff8 100644 --- a/bin/MakeProjectCreator/modules/Creator.pm +++ b/bin/MakeProjectCreator/modules/Creator.pm @@ -534,6 +534,42 @@ sub process_assignment_sub { } +sub fill_type_name { + my($self) = shift; + my($name) = shift; + my($def) = shift; + + if ($name =~ /\*/) { + my($pre) = $def . '_'; + my($mid) = '_' . $def . '_'; + my($post) = '_' . $def; + + ## Replace the beginning and end first then the middle + $name =~ s/^\*/$pre/; + $name =~ s/\*$/$post/; + $name =~ s/\*/$mid/g; + + ## If any one word is capitalized then capitalize each word + if ($name =~ /[A-Z][0-9a-z_]+/) { + ## Do the first word + if ($name =~ /^([a-z])([^_]+)/) { + my($first) = uc($1); + my($rest) = $2; + $name =~ s/^[a-z][^_]+/$first$rest/; + } + ## Do subsequent words + while($name =~ /(_[a-z])([^_]+)/) { + my($first) = uc($1); + my($rest) = $2; + $name =~ s/_[a-z][^_]+/$first$rest/; + } + } + } + + return $name; +} + + sub save_state { my($self) = shift; my(%state) = (); diff --git a/bin/MakeProjectCreator/modules/ProjectCreator.pm b/bin/MakeProjectCreator/modules/ProjectCreator.pm index 94b89523b47..ad3d42629a6 100644 --- a/bin/MakeProjectCreator/modules/ProjectCreator.pm +++ b/bin/MakeProjectCreator/modules/ProjectCreator.pm @@ -317,6 +317,11 @@ sub parse_line { $name =~ s/^\(\s*//; $name =~ s/\s*\)$//; $name = $self->transform_file_name($name); + + ## Replace any *'s with the default name + my($def) = $self->get_default_project_name(); + $name = $self->fill_type_name($name, $def); + $self->process_assignment('project_name', $name); } } @@ -1477,29 +1482,36 @@ sub add_corresponding_component_files { } +sub get_default_project_name { + my($self) = shift; + my($name) = $self->get_current_input(); + + if ($name eq '') { + $name = $self->transform_file_name($self->base_directory()); + } + else { + ## Since files on UNIX can have back slashes, we transform them + ## into underscores. + $name =~ s/\\/_/g; + + ## Convert then name to a usable name + $name = $self->transform_file_name($name); + + ## Take off the extension + $name =~ s/\.[^\.]+$//; + } + + return $name; +} + + sub generate_defaults { my($self) = shift; ## Generate default project name if (!defined $self->get_assignment('project_name')) { - my($current) = $self->get_current_input(); - if ($current eq '') { - my($base) = $self->base_directory(); - $base = $self->transform_file_name($base); - $self->process_assignment('project_name', $base); - } - else { - ## Since files on UNIX can have back slashes, we transform them - ## into underscores. - $current =~ s/\\/_/g; - - ## Convert then name to a usable name - $current = $self->transform_file_name($current); - - ## Take off the extension - $current =~ s/\.[^\.]+$//; - $self->process_assignment('project_name', $current); - } + $self->process_assignment('project_name', + $self->get_default_project_name()); } ## Generate the default pch file names (if needed) diff --git a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm index 1ca72a4e15e..332d93c66ea 100644 --- a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm @@ -166,14 +166,19 @@ sub parse_line { ## Set up some initial values if (defined $name) { - $name =~ s/^\(\s*//; - $name =~ s/\s*\)$//; if ($name =~ /[\/\\]/) { $status = 0; $errorString = 'ERROR: Workspaces can not have a slash ' . 'or a back slash in the name'; } else { + $name =~ s/^\(\s*//; + $name =~ s/\s*\)$//; + + ## Replace any *'s with the default name + my($def) = $self->get_default_workspace_name(); + $name = $self->fill_type_name($name, $def); + $self->{'workspace_name'} = $name; } } @@ -417,24 +422,32 @@ sub generate_default_components { } +sub get_default_workspace_name { + my($self) = shift; + my($name) = $self->get_current_input(); + + if ($name eq '') { + $name = $self->base_directory(); + } + else { + ## Since files on UNIX can have back slashes, we transform them + ## into underscores. + $name =~ s/\\/_/g; + + ## Take off the extension + $name =~ s/\.[^\.]+$//; + } + + return $name; +} + + sub generate_defaults { my($self) = shift; ## Generate default workspace name if (!defined $self->{'workspace_name'}) { - my($current) = $self->get_current_input(); - if ($current eq '') { - $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; - } + $self->{'workspace_name'} = $self->get_default_workspace_name(); } my(@files) = $self->generate_default_file_list(); |