diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | docs/MPC.sgml | 5 | ||||
-rw-r--r-- | docs/USAGE | 2 | ||||
-rw-r--r-- | modules/Driver.pm | 50 | ||||
-rw-r--r-- | modules/MPC.pm | 19 | ||||
-rw-r--r-- | modules/MWC.pm | 19 | ||||
-rw-r--r-- | modules/Options.pm | 3 | ||||
-rwxr-xr-x | mpc.pl | 6 | ||||
-rwxr-xr-x | mwc.pl | 6 |
9 files changed, 64 insertions, 61 deletions
@@ -1,3 +1,18 @@ +Tue Dec 5 03:29:14 UTC 2006 Chad Elliott <elliott_c@ociweb.com> + + * docs/MPC.sgml: + * docs/USAGE: + * modules/Driver.pm: + * modules/MPC.pm: + * modules/MWC.pm: + * modules/Options.pm: + * mpc.pl: + * mwc.pl: + + Removed the default project type and simplified the addition of + new project/workspace creators. Now, you must specify a type on + the command line or a default type in the MPC.cfg. + Mon Dec 4 16:02:43 UTC 2006 Chad Elliott <elliott_c@ociweb.com> * modules/Driver.pm: diff --git a/docs/MPC.sgml b/docs/MPC.sgml index fa26c74c..60c6f1fe 100644 --- a/docs/MPC.sgml +++ b/docs/MPC.sgml @@ -394,9 +394,8 @@ <listitem> <para> specifies the type of project file to generate. This option can - be used multiple times to generate multiple types. If - <parameter>-type</parameter> is not used, it defaults to - <parameter>make</parameter>. NOTE: The <parameter>-ti</parameter> + be used multiple times to generate multiple types. There is no + longer a default. NOTE: The <parameter>-ti</parameter> option overrides the template input file for all types specified </para> </listitem> @@ -77,7 +77,7 @@ Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse] for the specific type (ex. -ti dll_exe:vc8exe). -type Specifies the type of project file to generate. This option can be used multiple times to generate multiple - types. If -type is not used, it defaults to 'make'. + types. There is no longer a default. -use_env Use environment variables for all uses of $() instead of the relative replacement values. -value_project This option allows modification of a project variable diff --git a/modules/Driver.pm b/modules/Driver.pm index b5421216..7c5e94e0 100644 --- a/modules/Driver.pm +++ b/modules/Driver.pm @@ -52,7 +52,6 @@ sub new { $self->{'name'} = $name; $self->{'types'} = {}; $self->{'creators'} = \@creators; - $self->{'default'} = $creators[0]; $self->{'reldefs'} = {}; $self->{'relorder'} = []; @@ -63,7 +62,7 @@ sub new { sub locate_default_type { my($self) = shift; my($name) = lc(shift) . - (index($self->{'creators'}->[0], 'Workspace') > 0 ? + (lc($self->{'name'}) eq 'mwc.pl' ? 'workspacecreator' : 'projectcreator') . '.pm'; my($fh) = new FileHandle(); @@ -110,14 +109,14 @@ sub locate_dynamic_directories { sub add_dynamic_creators { my($self) = shift; my($dirs) = shift; - my($type) = (index($self->{'creators'}->[0], 'Workspace') > 0 ? + my($type) = (lc($self->{'name'}) eq 'mwc.pl' ? 'WorkspaceCreator' : 'ProjectCreator'); foreach my $dir (@$dirs) { my($fh) = new FileHandle(); if (opendir($fh, "$dir/modules")) { foreach my $file (readdir($fh)) { if ($file =~ /(.+$type)\.pm$/i) { - $self->debug("Pulling in $1\n"); + $self->debug("Pulling in $1"); push(@{$self->{'creators'}}, $1); } } @@ -183,7 +182,6 @@ sub optionError { my($line) = shift; $self->printUsage($line, $self->{'name'}, Version::get(), - $self->extractType($self->{'default'}), keys %{$self->{'types'}}); exit(0); } @@ -250,14 +248,17 @@ sub run { ## If no MPC config file was found and ## there is one in the config directory, we will use that. if (!defined $cfgfile) { - $cfgfile = $self->{'basepath'} . '/config/MPC.cfg'; - $cfgfile = $self->{'path'} . '/config/MPC.cfg' if (!-e $cfgfile); + $cfgfile = $self->{'path'} . '/config/MPC.cfg'; + $cfgfile = $self->{'basepath'} . '/config/MPC.cfg' if (!-e $cfgfile); $cfgfile = undef if (!-e $cfgfile); } ## Read the MPC config file my($cfg) = new ConfigParser(\%valid_cfg); if (defined $cfgfile) { + my($ellipses) = $cfgfile; + $ellipses =~ s!.*(/[^/]+/[^/]+/[^/]+/[^/]+/[^/]+)!...$1!; + $self->diagnostic("Using $ellipses"); my($status, $error) = $cfg->read_file($cfgfile); if (!$status) { $self->error("$error at line " . $cfg->get_line_number() . @@ -285,6 +286,9 @@ sub run { } } + ## Add in the creators found in the main MPC/modules directory + $self->add_dynamic_creators([$self->{'basepath'}]); + ## Dynamically load in each perl module and set up ## the type tags and project creators my($creators) = $self->{'creators'}; @@ -348,12 +352,26 @@ sub run { } } - ## If there's still no default, issue a warning + ## Set up the default creator, if no type is selected + if (!defined $options->{'creators'}->[0]) { + my($utype) = $cfg->get_value('default_type'); + if (defined $utype) { + my($default) = $self->locate_default_type($utype); + if (defined $default) { + push(@{$options->{'creators'}}, $default); + } + else { + $self->error("Unable to locate the module that corresponds to " . + "the '$utype' type."); + return 1; + } + } + } + + ## If there's still no default, issue an error if (!defined $options->{'creators'}->[0]) { - push(@{$options->{'creators'}}, $self->{'default'}); - $self->warning('In the future, there will no longer be a default ' . - 'project type. You should ' . - 'specify one in MPC.cfg or use the -type option.'); + $self->error('There is no longer a default project type. Please ' . + 'specify one in MPC.cfg or use the -type option.'); } if ($options->{'recurse'}) { @@ -390,14 +408,12 @@ sub run { ## Add the default include paths. If the user has used the dynamic ## types method of adding types to MPC, we need to push the paths ## on. Otherwise, we unshift them onto the front. - if ($self->{'path'} eq $self->{'basepath'}) { - push(@{$options->{'include'}}, $self->{'path'} . '/config', - $self->{'path'} . '/templates'); - } - else { + if ($self->{'path'} ne $self->{'basepath'}) { unshift(@{$options->{'include'}}, $self->{'path'} . '/config', $self->{'path'} . '/templates'); } + push(@{$options->{'include'}}, $self->{'basepath'} . '/config', + $self->{'basepath'} . '/templates'); ## All includes (except the current directory) have been added by this time $self->debug("INCLUDES: @{$options->{'include'}}"); diff --git a/modules/MPC.pm b/modules/MPC.pm index f0e720b4..449849cc 100644 --- a/modules/MPC.pm +++ b/modules/MPC.pm @@ -1,7 +1,8 @@ package MPC; # ****************************************************************** -# Description : Instantiate a Driver and run it +# Description : Instantiate a Driver and run it. This is here to +# maintain backward compatibility. # Author : Chad Elliott # Create Date : 1/30/2004 # ****************************************************************** @@ -19,21 +20,7 @@ use Driver; sub new { my($class) = shift; - my($self) = bless {'creators' => [ 'MakeProjectCreator', - 'NMakeProjectCreator', - 'VC6ProjectCreator', - 'VC7ProjectCreator', - 'VC71ProjectCreator', - 'VC8ProjectCreator', - 'BDSProjectCreator', - 'GHSProjectCreator', - 'EM3ProjectCreator', - 'AutomakeProjectCreator', - 'BMakeProjectCreator', - 'HTMLProjectCreator', - 'SLEProjectCreator', - 'CCProjectCreator', - ], + my($self) = bless {'creators' => [], }, $class; return $self; } diff --git a/modules/MWC.pm b/modules/MWC.pm index 7ecc118a..40faf030 100644 --- a/modules/MWC.pm +++ b/modules/MWC.pm @@ -1,7 +1,8 @@ package MWC; # ****************************************************************** -# Description : Instantiate a Driver and run it +# Description : Instantiate a Driver and run it. This is here to +# maintain backward compatibility. # Author : Chad Elliott # Create Date : 1/30/2004 # ****************************************************************** @@ -19,21 +20,7 @@ use Driver; sub new { my($class) = shift; - my($self) = bless {'creators' => [ 'MakeWorkspaceCreator', - 'NMakeWorkspaceCreator', - 'VC6WorkspaceCreator', - 'VC7WorkspaceCreator', - 'VC71WorkspaceCreator', - 'VC8WorkspaceCreator', - 'BDSWorkspaceCreator', - 'GHSWorkspaceCreator', - 'EM3WorkspaceCreator', - 'AutomakeWorkspaceCreator', - 'BMakeWorkspaceCreator', - 'HTMLWorkspaceCreator', - 'SLEWorkspaceCreator', - 'CCWorkspaceCreator', - ], + my($self) = bless {'creators' => [], }, $class; return $self; } diff --git a/modules/Options.pm b/modules/Options.pm index 1252b350..dedd8efa 100644 --- a/modules/Options.pm +++ b/modules/Options.pm @@ -36,7 +36,6 @@ sub printUsage { my($msg) = shift; my($base) = shift; my($version) = shift; - my($default) = shift; my(@types) = @_; if (defined $msg) { @@ -149,7 +148,7 @@ sub printUsage { " for the specific type (ex. -ti dll_exe:vc8exe).\n" . " -type Specifies the type of project file to generate. This\n" . " option can be used multiple times to generate multiple\n" . -" types. If -type is not used, it defaults to '$default'.\n" . +" types. There is no longer a default.\n" . " -use_env Use environment variables for all uses of \$() instead\n" . " of the relative replacement values.\n" . " -value_project This option allows modification of a project variable\n" . @@ -26,7 +26,7 @@ if ($^O eq 'VMS') { } unshift(@INC, $basePath . '/modules'); -require MPC; +require Driver; # ************************************************************ # Subroutine Section @@ -40,5 +40,5 @@ sub getBasePath { # Main Section # ************************************************************ -my($driver) = new MPC(); -exit($driver->execute($basePath, basename($0), \@ARGV)); +my($driver) = new Driver($basePath, basename($0)); +exit($driver->run(@ARGV)); @@ -26,7 +26,7 @@ if ($^O eq 'VMS') { } unshift(@INC, $basePath . '/modules'); -require MWC; +require Driver; # ************************************************************ # Subroutine Section @@ -40,5 +40,5 @@ sub getBasePath { # Main Section # ************************************************************ -my($driver) = new MWC(); -exit($driver->execute($basePath, basename($0), \@ARGV)); +my($driver) = new Driver($basePath, basename($0)); +exit($driver->run(@ARGV)); |