diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2004-09-07 12:10:05 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2004-09-07 12:10:05 +0000 |
commit | c834a8d6d7df7e1ac529aeb9f457fa4f6ce23358 (patch) | |
tree | bacb87434bf50990469caaccd92c5f17bdf85f69 | |
parent | 5e74a27dd5aa0be6caac2b1a72d6e8a50b7ce88c (diff) | |
download | MPC-c834a8d6d7df7e1ac529aeb9f457fa4f6ce23358.tar.gz |
ChangeLogTag: Tue Sep 7 07:08:26 2004 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | USAGE | 4 | ||||
-rw-r--r-- | modules/Creator.pm | 52 | ||||
-rw-r--r-- | modules/Driver.pm | 3 | ||||
-rw-r--r-- | modules/Options.pm | 27 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 214 | ||||
-rw-r--r-- | modules/TemplateParser.pm | 8 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 67 | ||||
-rw-r--r-- | templates/vc7.mpd | 12 |
9 files changed, 206 insertions, 199 deletions
@@ -1,3 +1,21 @@ +Tue Sep 7 07:08:26 2004 Chad Elliott <elliott_c@ociweb.com> + + * USAGE: + * modules/Creator.pm: + * modules/Driver.pm: + * modules/Options.pm: + * modules/ProjectCreator.pm: + * modules/TemplateParser.pm: + * modules/WorkspaceCreator.pm: + + Added an option, -expand_env, to replace all $() variables + referenced in MPC with the environment variable equivalent. + + * templates/vc7.mpd: + + Converted all slashes to back-slashes to more closely match the + Windows style. + Fri Sep 3 09:14:21 2004 Chad Elliott <elliott_c@ociweb.com> * templates/em3vcp.mpd: @@ -12,7 +12,7 @@ projects for each one found. Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse] [-ti <dll | lib | dll_exe | lib_exe>:<file>] [-hierarchy] [-template <file>] [-relative NAME=VAR] [-base <project>] - [-noreldefs] [-notoplevel] [-static] [-genins] + [-noreldefs] [-notoplevel] [-static] [-genins] [-expand_env] [-value_template <NAME+=VAL | NAME=VAL | NAME-=VAL>] [-value_project <NAME+=VAL | NAME=VAL | NAME-=VAL>] [-feature_file <file name>] [-make_coexistence] @@ -30,6 +30,8 @@ Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse] .mpc extension will be tried. -exclude Use this option to exclude directories when searching for input files. + -expand_env Expand all uses of $() to the value set in the + environment. -feature_file Specifies the feature file to read before processing. The default feature file is default.features under the config directory. diff --git a/modules/Creator.pm b/modules/Creator.pm index 4402b8e2..b31fcae2 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -27,7 +27,7 @@ my(@statekeys) = ('global', 'include', 'template', 'ti', 'dynamic', 'static', 'relative', 'addtemp', 'addproj', 'progress', 'toplevel', 'baseprojs', 'feature_file', 'hierarchy', 'name_modifier', - 'apply_project', 'into', + 'apply_project', 'into', 'expand_env', ); my(%all_written) = (); @@ -37,27 +37,28 @@ my(%all_written) = (); # ************************************************************ sub new { - my($class) = shift; - my($global) = shift; - my($inc) = shift; - my($template) = shift; - my($ti) = shift; - my($dynamic) = shift; - my($static) = shift; - my($relative) = shift; - my($addtemp) = shift; - my($addproj) = shift; - my($progress) = shift; - my($toplevel) = shift; - my($baseprojs) = shift; - my($feature) = shift; - my($hierarchy) = shift; - my($nmodifier) = shift; - my($applypj) = shift; - my($into) = shift; - my($language) = shift; - my($type) = shift; - my($self) = Parser::new($class, $inc); + my($class) = shift; + my($global) = shift; + my($inc) = shift; + my($template) = shift; + my($ti) = shift; + my($dynamic) = shift; + my($static) = shift; + my($relative) = shift; + my($addtemp) = shift; + my($addproj) = shift; + my($progress) = shift; + my($toplevel) = shift; + my($baseprojs) = shift; + my($feature) = shift; + my($hierarchy) = shift; + my($nmodifier) = shift; + my($applypj) = shift; + my($into) = shift; + my($language) = shift; + my($expand_env) = shift; + my($type) = shift; + my($self) = Parser::new($class, $inc); $self->{'relative'} = $relative; $self->{'template'} = $template; @@ -85,6 +86,7 @@ sub new { $self->{'apply_project'} = $applypj; $self->{'into'} = $into; $self->{'language'} = $language; + $self->{'expand_env'} = $expand_env; $self->{'convert_slashes'} = $self->convert_slashes(); return $self; @@ -802,6 +804,12 @@ sub get_into { } +sub get_expand_env { + my($self) = shift; + return $self->{'expand_env'}; +} + + sub get_files_written { my($self) = shift; return $self->{'real_fwritten'}; diff --git a/modules/Driver.pm b/modules/Driver.pm index c8318e3d..0df06f58 100644 --- a/modules/Driver.pm +++ b/modules/Driver.pm @@ -307,7 +307,8 @@ sub run { $options->{'apply_project'}, $options->{'genins'}, $options->{'into'}, - $options->{'language'}); + $options->{'language'}, + $options->{'expand_env'}); if ($base ne $file) { my($dir) = ($base eq '' ? $file : $self->mpc_dirname($file)); if (!$creator->cd($dir)) { diff --git a/modules/Options.pm b/modules/Options.pm index 21c6a021..2a5c05c4 100644 --- a/modules/Options.pm +++ b/modules/Options.pm @@ -42,7 +42,7 @@ sub printUsage { "Usage: $base [-global <file>] [-include <directory>] [-recurse]\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] [-genins]\n" . + $spaces . "[-noreldefs] [-notoplevel] [-static] [-genins] [-expand_env]\n" . $spaces . "[-value_template <NAME+=VAL | NAME=VAL | NAME-=VAL>]\n" . $spaces . "[-value_project <NAME+=VAL | NAME=VAL | NAME-=VAL>]\n" . $spaces . "[-feature_file <file name>] [-make_coexistence]\n" . @@ -83,6 +83,8 @@ sub printUsage { " .mpc extension will be tried.\n" . " -exclude Use this option to exclude directories when searching\n" . " for input files.\n" . +" -expand_env Expand all uses of \$() to the value set in the\n" . +" environment.\n" . " -feature_file Specifies the feature file to read before processing.\n" . " The default feature file is default.features under the\n" . " config directory.\n" . @@ -148,13 +150,23 @@ sub completion_command { my($types) = shift; my($str) = "complete $name " . "'c/-/(genins global include type template relative " . - "ti static noreldefs notoplevel feature_file " . - "value_template value_project make_coexistence " . + "ti static noreldefs notoplevel feature_file expand_env " . + "value_template value_project make_coexistence language " . "hierarchy exclude name_modifier apply_project version)/' " . "'c/dll:/f/' 'c/dll_exe:/f/' 'c/lib_exe:/f/' 'c/lib:/f/' " . - "'n/-ti/(dll lib dll_exe lib_exe)/:' 'n/-type/("; + "'n/-ti/(dll lib dll_exe lib_exe)/:' "; - my(@keys) = sort keys %$types; + $str .= "'n/-language/("; + my(@keys) = sort keys %languages; + for(my $i = 0; $i <= $#keys; $i++) { + $str .= $keys[$i]; + if ($i != $#keys) { + $str .= " "; + } + } + $str .= ")/' 'n/-type/("; + + @keys = sort keys %$types; for(my $i = 0; $i <= $#keys; $i++) { $str .= $keys[$i]; if ($i != $#keys) { @@ -191,6 +203,7 @@ sub options { my($dynamic) = ($defaults ? 1 : undef); my($reldefs) = ($defaults ? 1 : undef); my($toplevel) = ($defaults ? 1 : undef); + my($expand_env) = ($defaults ? 0 : undef); my($static) = ($defaults ? 0 : undef); my($recurse) = ($defaults ? 0 : undef); my($makeco) = ($defaults ? 0 : undef); @@ -251,6 +264,9 @@ sub options { 'comma separated list argument'); } } + elsif ($arg eq '-expand_env') { + $expand_env = 1; + } elsif ($arg eq '-feature_file') { $i++; $feature_f = $args[$i]; @@ -473,6 +489,7 @@ sub options { 'genins' => $genins, 'into' => $into, 'language' => $language, + 'expand_env' => $expand_env, ); return \%options; diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 12891b3a..6774f808 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -192,36 +192,37 @@ my(%language) = ('cplusplus' => [ \%cppvc, \%cppec, {} , 'main' ], # ************************************************************ sub new { - my($class) = shift; - my($global) = shift; - my($inc) = shift; - my($template) = shift; - my($ti) = shift; - my($dynamic) = shift; - my($static) = shift; - my($relative) = shift; - my($addtemp) = shift; - my($addproj) = shift; - my($progress) = shift; - my($toplevel) = shift; - my($baseprojs) = shift; - my($gfeature) = shift; - my($feature) = shift; - my($hierarchy) = shift; - my($exclude) = shift; - my($makeco) = shift; - my($nmod) = shift; - my($applypj) = shift; - my($genins) = shift; - my($into) = shift; - my($language) = shift; - my($self) = $class->SUPER::new($global, $inc, - $template, $ti, $dynamic, $static, - $relative, $addtemp, $addproj, - $progress, $toplevel, $baseprojs, - $feature, $hierarchy, $nmod, $applypj, - $into, $language, - 'project'); + my($class) = shift; + my($global) = shift; + my($inc) = shift; + my($template) = shift; + my($ti) = shift; + my($dynamic) = shift; + my($static) = shift; + my($relative) = shift; + my($addtemp) = shift; + my($addproj) = shift; + my($progress) = shift; + my($toplevel) = shift; + my($baseprojs) = shift; + my($gfeature) = shift; + my($feature) = shift; + my($hierarchy) = shift; + my($exclude) = shift; + my($makeco) = shift; + my($nmod) = shift; + my($applypj) = shift; + my($genins) = shift; + my($into) = shift; + my($language) = shift; + my($expand_env) = shift; + my($self) = $class->SUPER::new($global, $inc, + $template, $ti, $dynamic, $static, + $relative, $addtemp, $addproj, + $progress, $toplevel, $baseprojs, + $feature, $hierarchy, $nmod, $applypj, + $into, $language, $expand_env, + 'project'); $self->{$self->{'type_check'}} = 0; $self->{'feature_defined'} = 0; @@ -3393,8 +3394,9 @@ sub relative { $value = \@built; } elsif ($value =~ /\$/) { - my($rel) = $self->get_relative(); - my(@keys) = keys %$rel; + my($expenv) = $self->get_expand_env(); + my($rel) = ($expenv ? \%ENV : $self->get_relative()); + my(@keys) = keys %$rel; if (defined $keys[0]) { my($cwd) = $self->getcwd(); @@ -3406,52 +3408,61 @@ sub relative { my($val) = $$rel{$name}; if (defined $val) { - ## Fix up the value for Windows switch the \\'s to / - if ($self->{'convert_slashes'}) { - $val =~ s/\\/\//g; + if ($expenv) { + if ($self->{'convert_slashes'}) { + $val = $self->slash_to_backslash($val); + } + substr($value, $start) =~ s/\$\([^)]+\)/$val/; + $whole = $val; } + else { + ## Fix up the value for Windows switch the \\'s to / + if ($self->{'convert_slashes'}) { + $val =~ s/\\/\//g; + } - ## Here we make an assumption that if we convert slashes to - ## back-slashes, we also have a case-insensitive file system. - my($icwd) = ($self->{'convert_slashes'} ? lc($cwd) : $cwd); - my($ival) = ($self->{'convert_slashes'} ? lc($val) : $val); - my($iclen) = length($icwd); - my($ivlen) = length($ival); - - ## If the relative value contains the current working - ## directory plus additional subdirectories, we must pull - ## off the additional directories into a temporary where - ## it can be put back after the relative replacement is done. - my($append) = undef; - if (index($ival, $icwd) == 0 && $iclen != $ivlen && - substr($ival, $iclen, 1) eq '/') { - my($diff) = $ivlen - $iclen; - $append = substr($ival, $iclen); - substr($ival, $iclen, $diff) = ''; - $ivlen -= $diff; - } + ## Here we make an assumption that if we convert slashes to + ## back-slashes, we also have a case-insensitive file system. + my($icwd) = ($self->{'convert_slashes'} ? lc($cwd) : $cwd); + my($ival) = ($self->{'convert_slashes'} ? lc($val) : $val); + my($iclen) = length($icwd); + my($ivlen) = length($ival); + + ## If the relative value contains the current working + ## directory plus additional subdirectories, we must pull + ## off the additional directories into a temporary where + ## it can be put back after the relative replacement is done. + my($append) = undef; + if (index($ival, $icwd) == 0 && $iclen != $ivlen && + substr($ival, $iclen, 1) eq '/') { + my($diff) = $ivlen - $iclen; + $append = substr($ival, $iclen); + substr($ival, $iclen, $diff) = ''; + $ivlen -= $diff; + } - if (index($icwd, $ival) == 0 && - ($iclen == $ivlen || substr($icwd, $ivlen, 1) eq '/')) { - my($current) = $icwd; - substr($current, 0, $ivlen) = ''; + if (index($icwd, $ival) == 0 && + ($iclen == $ivlen || substr($icwd, $ivlen, 1) eq '/')) { + my($current) = $icwd; + substr($current, 0, $ivlen) = ''; - my($dircount) = ($current =~ tr/\///); - if ($dircount == 0) { - $ival = '.'; - } - else { - $ival = '../' x $dircount; - $ival =~ s/\/$//; - } - if (defined $append) { - $ival .= $append; - } - if ($self->{'convert_slashes'}) { - $ival = $self->slash_to_backslash($ival); + my($dircount) = ($current =~ tr/\///); + if ($dircount == 0) { + $ival = '.'; + } + else { + $ival = '../' x $dircount; + $ival =~ s/\/$//; + } + if (defined $append) { + $ival .= $append; + } + if ($self->{'convert_slashes'}) { + $ival = $self->slash_to_backslash($ival); + } + substr($value, $start) =~ s/\$\([^)]+\)/$ival/; + $whole = $ival; } - substr($value, $start) =~ s/\$\([^)]+\)/$ival/; - $whole = $ival; } } elsif ($expand_template || @@ -3473,6 +3484,12 @@ sub relative { ## replaced too. $whole = ''; } + else { + if ($expenv) { + $self->warning("Unable to expand $name " . + "as an environment variable."); + } + } } $start += length($whole); } @@ -3484,57 +3501,6 @@ sub relative { } -sub reverse_relative { - my($self) = shift; - my($value) = shift; - - if (defined $value) { - if (UNIVERSAL::isa($value, 'ARRAY')) { - my(@built) = (); - foreach my $val (@$value) { - push(@built, $self->reverse_relative($val)); - } - $value = \@built; - } - else { - my($rel) = $self->get_relative(); - - foreach my $key (keys %$rel) { - ## Get the relative replacement value and convert back-slashes - my($val) = $$rel{$key}; - $val =~ s/\\/\//g; - - ## We only need to check for reverse replacement if the length - ## of the string is less than or equal to the length of our - ## replacement value or the string has a slash at the position - ## of the length of the replacement value - my($vlen) = length($val); - if (length($value) <= $vlen || substr($value, $vlen, 1) eq '/') { - ## Cut the string down by the length of the replacement value - my($lval) = substr($value, 0, $vlen); - - ## Here we make an assumption that if we convert slashes to - ## back-slashes, we also have a case-insensitive file system. - if ($self->{'convert_slashes'}) { - if (lc($lval) eq lc($val)) { - substr($value, 0, length($val)) = "\$($key)"; - last; - } - } - else { - if ($lval eq $val) { - substr($value, 0, length($val)) = "\$($key)"; - last; - } - } - } - } - } - } - return $value; -} - - sub get_verbatim { my($self) = shift; my($marker) = shift; diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index 62a90747..b8dda99f 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -914,7 +914,6 @@ sub collect_data { my($self) = shift; my($prjc) = $self->{'prjc'}; my($cwd) = $self->getcwd(); - my($relwd) = $prjc->reverse_relative($cwd); ## Set the current working directory if ($self->{'cslashes'}) { @@ -922,13 +921,6 @@ sub collect_data { } $self->{'values'}->{'cwd'} = $cwd; - ## Set the relative working directory - $relwd =~ s/\$\([^\)]+\)[\/\\]//; - if ($self->{'cslashes'}) { - $relwd = $prjc->slash_to_backslash($relwd); - } - $self->{'values'}->{'relwd'} = $relwd; - ## Collect the components into {'values'} somehow foreach my $key (keys %{$prjc->{'valid_components'}}) { my(@list) = $prjc->get_component_list($key); diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index d60907f7..635b33ad 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -49,36 +49,37 @@ my($aggregated) = 'aggregated_workspace'; # ************************************************************ sub new { - my($class) = shift; - my($global) = shift; - my($inc) = shift; - my($template) = shift; - my($ti) = shift; - my($dynamic) = shift; - my($static) = shift; - my($relative) = shift; - my($addtemp) = shift; - my($addproj) = shift; - my($progress) = shift; - my($toplevel) = shift; - my($baseprojs) = shift; - my($gfeature) = shift; - my($feature) = shift; - my($hierarchy) = shift; - my($exclude) = shift; - my($makeco) = shift; - my($nmod) = shift; - my($applypj) = shift; - my($genins) = shift; - my($into) = shift; - my($language) = shift; - my($self) = Creator::new($class, $global, $inc, - $template, $ti, $dynamic, $static, - $relative, $addtemp, $addproj, - $progress, $toplevel, $baseprojs, - $feature, $hierarchy, $nmod, $applypj, - $into, $language, - 'workspace'); + my($class) = shift; + my($global) = shift; + my($inc) = shift; + my($template) = shift; + my($ti) = shift; + my($dynamic) = shift; + my($static) = shift; + my($relative) = shift; + my($addtemp) = shift; + my($addproj) = shift; + my($progress) = shift; + my($toplevel) = shift; + my($baseprojs) = shift; + my($gfeature) = shift; + my($feature) = shift; + my($hierarchy) = shift; + my($exclude) = shift; + my($makeco) = shift; + my($nmod) = shift; + my($applypj) = shift; + my($genins) = shift; + my($into) = shift; + my($language) = shift; + my($expand_env) = shift; + my($self) = Creator::new($class, $global, $inc, + $template, $ti, $dynamic, $static, + $relative, $addtemp, $addproj, + $progress, $toplevel, $baseprojs, + $feature, $hierarchy, $nmod, $applypj, + $into, $language, $expand_env, + 'workspace'); $self->{'workspace_name'} = undef; $self->{$self->{'type_check'}} = 0; @@ -1604,7 +1605,8 @@ sub process_cmdline { ## Determine if it's ok to use the cache my(@cacheInvalidating) = ('global', 'include', 'baseprojs', 'template', 'ti', 'relative', - 'addtemp', 'addproj', 'feature_file'); + 'addtemp', 'addproj', 'feature_file', + 'expand_env'); foreach my $key (@cacheInvalidating) { if ($self->is_set($key, $options)) { $self->{'cacheok'} = 0; @@ -1667,7 +1669,8 @@ sub project_creator { $parameters{'apply_project'}, $self->{'generate_ins'}, $parameters{'into'}, - $self->get_language()); + $self->get_language(), + $parameters{'expand_env'}); } diff --git a/templates/vc7.mpd b/templates/vc7.mpd index 95640d9f..31cdbb4d 100644 --- a/templates/vc7.mpd +++ b/templates/vc7.mpd @@ -15,7 +15,7 @@ <Configuration Name="<%configuration%>|<%platform%>" OutputDirectory="<%if(type_is_dynamic)%><%if(dllout)%><%dllout%><%else%><%libout%><%endif%><%else%><%if(type_is_static)%><%libout%><%else%><%if(install)%><%install%><%else%><%output_dir%><%endif%><%endif%><%endif%>" - IntermediateDirectory="<%intermediate_dir%>/<%noextension(project_file)%>" + IntermediateDirectory="<%intermediate_dir%>\<%noextension(project_file)%>" ConfigurationType="<%configuration_type("2")%>" UseOfMFC="<%use_mfc("0")%>" ATLMinimizesCRunTimeLibraryUsage="FALSE"> @@ -63,7 +63,7 @@ <%if(type_is_static)%> Name="VCLibrarianTool" <%if(staticname)%> - OutputFile="$(OutDir)/<%staticname%><%lib_modifier%>.lib" + OutputFile="$(OutDir)\<%staticname%><%lib_modifier%>.lib" <%endif%> <%else%> Name="VCLinkerTool" @@ -74,7 +74,7 @@ AdditionalDependencies="<%foreach(pure_libs)%><%pure_lib%> <%endfor%><%foreach(lit_libs)%><%lit_lib%>.lib <%endfor%><%foreach(libs)%><%lib%><%lib_modifier%>.lib<%fornotlast(" ")%><%endfor%>" <%endif%> <%if(exename || sharedname || staticname)%> - OutputFile="$(OutDir)/<%if(type_is_dynamic)%><%sharedname%><%lib_modifier%>.dll<%else%><%exename%><%if(use_modifier)%><%lib_modifier%><%endif%>.exe<%endif%>" + OutputFile="$(OutDir)\<%if(type_is_dynamic)%><%sharedname%><%lib_modifier%>.dll<%else%><%exename%><%if(use_modifier)%><%lib_modifier%><%endif%>.exe<%endif%>" <%endif%> Version="<%version("1.0")%>" LinkIncremental="<%LinkIncremental("1")%>" @@ -82,10 +82,10 @@ AdditionalLibraryDirectories="<%foreach(libpaths)%><%libpath%><%fornotlast(";")%><%endfor%>" GenerateDebugInformation="TRUE" <%if(type_is_dynamic)%> - ProgramDatabaseFile="$(OutDir)/<%sharedname%><%lib_modifier%>.pdb" + ProgramDatabaseFile="$(OutDir)\<%sharedname%><%lib_modifier%>.pdb" <%else%> <%if(type_is_binary)%> - ProgramDatabaseFile="$(OutDir)/<%exename%><%if(use_modifier)%><%lib_modifier%><%endif%>.pdb" + ProgramDatabaseFile="$(OutDir)\<%exename%><%if(use_modifier)%><%lib_modifier%><%endif%>.pdb" <%endif%> <%endif%> SubSystem="<%subsystem("1")%>" @@ -94,7 +94,7 @@ EnableCOMDATFolding="<%opticf("2")%>" <%endif%> <%if(type_is_dynamic)%> - ImportLibrary="$(OutDir)/<%sharedname%><%lib_modifier%>.lib" + ImportLibrary="$(OutDir)\<%sharedname%><%lib_modifier%>.lib" <%endif%> <%endif%> TargetMachine="<%machine("1")%>"/> |