diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2002-11-08 19:02:33 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2002-11-08 19:02:33 +0000 |
commit | 835d136975faf4055dd20c11779c32c3f202b597 (patch) | |
tree | 346596b271f139f2260a160aacb108fae2ed5e03 | |
parent | 72fcb6e19fb0929f107ab215a1cb5190a7d1ba38 (diff) | |
download | MPC-835d136975faf4055dd20c11779c32c3f202b597.tar.gz |
ChangeLogTag: Fri Nov 8 13:00:56 2002 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/Creator.pm | 43 | ||||
-rw-r--r-- | modules/Driver.pm | 8 | ||||
-rw-r--r-- | modules/EM3ProjectCreator.pm | 28 | ||||
-rw-r--r-- | modules/EM3WorkspaceCreator.pm | 4 | ||||
-rw-r--r-- | modules/GHSProjectCreator.pm | 18 | ||||
-rw-r--r-- | modules/GHSWorkspaceCreator.pm | 4 | ||||
-rw-r--r-- | modules/GUID.pm | 4 | ||||
-rw-r--r-- | modules/NMakeProjectCreator.pm | 20 | ||||
-rw-r--r-- | modules/NMakeWorkspaceCreator.pm | 20 | ||||
-rw-r--r-- | modules/Parser.pm | 39 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 89 | ||||
-rw-r--r-- | modules/TemplateInputReader.pm | 8 | ||||
-rw-r--r-- | modules/TemplateParser.pm | 220 | ||||
-rw-r--r-- | modules/VA4ProjectCreator.pm | 34 | ||||
-rw-r--r-- | modules/VA4WorkspaceCreator.pm | 2 | ||||
-rw-r--r-- | modules/VC6ProjectCreator.pm | 48 | ||||
-rw-r--r-- | modules/VC6WorkspaceCreator.pm | 25 | ||||
-rw-r--r-- | modules/VC7ProjectCreator.pm | 23 | ||||
-rw-r--r-- | modules/VC7WorkspaceCreator.pm | 4 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 69 |
20 files changed, 362 insertions, 348 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm index bdfe8dd4..6abba798 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -11,7 +11,6 @@ package Creator; # ************************************************************ use strict; -use Cwd; use FileHandle; use File::Basename; @@ -45,7 +44,7 @@ sub new { $self->{'type_check'} = $type . '_defined'; $self->{'global_read'} = 0; $self->{'include_path'} = $inc; - $self->{'current_input'} = ""; + $self->{'current_input'} = ''; $self->{'progress'} = $progress; $self->{'addtemp'} = $addtemp; $self->{'addproj'} = $addproj; @@ -57,7 +56,7 @@ sub new { sub generate_default_input { my($self) = shift; $self->parse_line(undef, "$self->{'grammar_type'} {"); - $self->parse_line(undef, "}"); + $self->parse_line(undef, '}'); return 1; } @@ -108,7 +107,7 @@ sub generate { ## An empty input file name says that we ## should generate a default input file and use that - if ($input eq "") { + if ($input eq '') { $status = $self->generate_default_input(); } else { @@ -129,17 +128,17 @@ sub parse_assignment { if ($line =~ /^(\w+)\s*=\s*(.*)?/) { my($name) = lc($1); my($value) = $2; - push(@$values, "assignment", $name, $value); + push(@$values, 'assignment', $name, $value); } elsif ($line =~ /^(\w+)\s*\+=\s*(.*)?/) { my($name) = lc($1); my($value) = $2; - push(@$values, "assign_add", $name, $value); + push(@$values, 'assign_add', $name, $value); } elsif ($line =~ /^(\w+)\s*\-=\s*(.*)?/) { my($name) = lc($1); my($value) = $2; - push(@$values, "assign_sub", $name, $value); + push(@$values, 'assign_sub', $name, $value); } else { $status = 0; @@ -153,7 +152,7 @@ sub parse_known { my($self) = shift; my($line) = shift; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; my($type) = $self->{'grammar_type'}; my(@values) = (); my($typecheck) = $self->{'type_check'}; @@ -165,7 +164,7 @@ sub parse_known { ## allows for the most compact file as human readably ## possible. ## - if ($line eq "") { + if ($line eq '') { } elsif ($line =~ /^$type\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) { my($name) = $1; @@ -180,14 +179,14 @@ sub parse_known { foreach my $parent (split(/[:,]/, $parents)) { $parent =~ s/^\s+//; $parent =~ s/\s+$//; - if ($parent ne "") { + if ($parent ne '') { push(@parents, $parent); } } if (!defined $parents[0]) { ## The : was used, but no parents followed. This ## is an error. - $errorString = "ERROR: No parents listed"; + $errorString = 'ERROR: No parents listed'; $status = 0; } $parents = \@parents; @@ -220,9 +219,9 @@ sub parse_known { $name =~ s/\s*\)$//; } else { - $name = "default"; + $name = 'default'; } - push(@values, "component", $comp, $name); + push(@values, 'component', $comp, $name); } else { $errorString = "ERROR: Unrecognized line: $line"; @@ -235,7 +234,7 @@ sub parse_known { sub base_directory { my($self) = shift; - return basename(getcwd()); + return basename($self->getcwd()); } @@ -246,7 +245,7 @@ sub generate_default_file_list { my(@files) = (); if (!defined $dir) { - $dir = "."; + $dir = '.'; } if (opendir($dh, $dir)) { @@ -257,7 +256,7 @@ sub generate_default_file_list { ## Prefix each file name with the directory ## only if it's not . - if ($dir ne ".") { + if ($dir ne '.') { for(my $i = 0; $i <= $#files; $i++) { $files[$i] = "$dir/$files[$i]"; } @@ -315,7 +314,7 @@ sub get_relative { sub windows_crlf { - my($self) = shift; + #my($self) = shift; if ($^O eq 'MSWin32') { return "\n"; } @@ -363,18 +362,18 @@ sub get_addproj { # ************************************************************ sub crlf { - my($self) = shift; + #my($self) = shift; return "\n"; } sub reset_values { - my($self) = shift; + #my($self) = shift; } sub sort_files { - my($self) = shift; + #my($self) = shift; return 1; } @@ -388,8 +387,8 @@ sub file_sorter { sub read_global_configuration { - my($self) = shift; - my($input) = shift; + #my($self) = shift; + #my($input) = shift; return 1; } diff --git a/modules/Driver.pm b/modules/Driver.pm index b1aa3d0a..25336693 100644 --- a/modules/Driver.pm +++ b/modules/Driver.pm @@ -151,7 +151,6 @@ sub run { foreach my $creator (@$creators) { my($tag) = lc(substr($creator, 0, $signif)); $self->{'types'}->{$tag} = $creator; - require "$creator.pm"; } for(my $i = 0; $i <= $#args; $i++) { @@ -341,9 +340,16 @@ sub run { ## Set up un-buffered output for the progress callback $| = 1; + ## Set up a hash that we can use to keep track of what + ## has been 'required' + my(%loaded) = (); ## Generate the files foreach my $file (@input) { foreach my $name (@generators) { + if (!$loaded{$name}) { + require "$name.pm"; + $loaded{$name} = 1; + } my($generator) = $name->new($global, \@include, $template, \%ti, $dynamic, $static, \%relative, \%addtemp, \%addproj, diff --git a/modules/EM3ProjectCreator.pm b/modules/EM3ProjectCreator.pm index 8a3806f4..b15f24d9 100644 --- a/modules/EM3ProjectCreator.pm +++ b/modules/EM3ProjectCreator.pm @@ -26,8 +26,8 @@ sub fill_value { my($name) = shift; my($value) = undef; - if ($name eq "make_file_name") { - $value = $self->base_project_name() . ".vcn"; + if ($name eq 'make_file_name') { + $value = $self->base_project_name() . '.vcn'; } return $value; @@ -36,43 +36,43 @@ sub fill_value { sub project_file_name { my($self) = shift; - return $self->project_name() . ".vcp"; + return $self->project_name() . '.vcp'; } sub static_project_file_name { my($self) = shift; - return $self->project_name() . $self->get_static_append() . ".vcp"; + return $self->project_name() . $self->get_static_append() . '.vcp'; } sub get_dll_exe_template_input_file { - my($self) = shift; - return "em3vcpdllexe"; + #my($self) = shift; + return 'em3vcpdllexe'; } sub get_lib_exe_template_input_file { - my($self) = shift; - return "em3vcplibexe"; + #my($self) = shift; + return 'em3vcplibexe'; } sub get_lib_template_input_file { - my($self) = shift; - return "em3vcplib"; + #my($self) = shift; + return 'em3vcplib'; } sub get_dll_template_input_file { - my($self) = shift; - return "em3vcpdll"; + #my($self) = shift; + return 'em3vcpdll'; } sub get_template { - my($self) = shift; - return "em3vcp"; + #my($self) = shift; + return 'em3vcp'; } diff --git a/modules/EM3WorkspaceCreator.pm b/modules/EM3WorkspaceCreator.pm index 56fdb137..a149e551 100644 --- a/modules/EM3WorkspaceCreator.pm +++ b/modules/EM3WorkspaceCreator.pm @@ -25,7 +25,7 @@ use vars qw(@ISA); sub workspace_file_name { my($self) = shift; - return $self->get_workspace_name() . ".vcw"; + return $self->get_workspace_name() . '.vcw'; } @@ -36,7 +36,7 @@ sub pre_workspace { print $fh "Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00$crlf" . "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!$crlf" . - "$crlf"; + $crlf; } diff --git a/modules/GHSProjectCreator.pm b/modules/GHSProjectCreator.pm index c370bfbd..502d2e6e 100644 --- a/modules/GHSProjectCreator.pm +++ b/modules/GHSProjectCreator.pm @@ -26,11 +26,11 @@ sub translate_value { my($key) = shift; my($val) = shift; - if ($key eq 'depends' && $val ne "") { + if ($key eq 'depends' && $val ne '') { my($arr) = $self->create_array($val); - $val = ""; + $val = ''; foreach my $entry (@$arr) { - $val .= "\"" . $self->project_file_name($entry) . "\" "; + $val .= '"' . $self->project_file_name($entry) . '" '; } $val =~ s/\s+$//; } @@ -59,20 +59,20 @@ sub project_file_name { sub get_dll_exe_template_input_file { - my($self) = shift; - return "ghsexe"; + #my($self) = shift; + return 'ghsexe'; } sub get_dll_template_input_file { - my($self) = shift; - return "ghsdll"; + #my($self) = shift; + return 'ghsdll'; } sub get_template { - my($self) = shift; - return "ghs"; + #my($self) = shift; + return 'ghs'; } diff --git a/modules/GHSWorkspaceCreator.pm b/modules/GHSWorkspaceCreator.pm index 716be104..a3b0ebfb 100644 --- a/modules/GHSWorkspaceCreator.pm +++ b/modules/GHSWorkspaceCreator.pm @@ -24,8 +24,8 @@ use vars qw(@ISA); # ************************************************************ sub workspace_file_name { - my($self) = shift; - return "ghs/default.bld"; + #my($self) = shift; + return 'ghs/default.bld'; } diff --git a/modules/GUID.pm b/modules/GUID.pm index 944813a1..015db9c2 100644 --- a/modules/GUID.pm +++ b/modules/GUID.pm @@ -11,7 +11,6 @@ package GUID; # ************************************************************ use strict; -use Cwd; # ************************************************************ # Subroutine Section @@ -29,7 +28,8 @@ sub generate { my($self) = shift; my($out) = shift; my($in) = shift; - my($chash) = $self->hash(getcwd()); + my($cwd) = shift; + my($chash) = $self->hash($cwd); my($nhash) = $self->hash($out); my($ihash) = $self->hash($in); my($val) = 0xfeca1bad; diff --git a/modules/NMakeProjectCreator.pm b/modules/NMakeProjectCreator.pm index 131f435f..29469f48 100644 --- a/modules/NMakeProjectCreator.pm +++ b/modules/NMakeProjectCreator.pm @@ -22,7 +22,7 @@ use vars qw(@ISA); # ************************************************************ sub sort_files { - my($self) = shift; + #my($self) = shift; return 0; } @@ -32,11 +32,11 @@ sub translate_value { my($key) = shift; my($val) = shift; - if ($key eq 'depends' && $val ne "") { + if ($key eq 'depends' && $val ne '') { my($arr) = $self->create_array($val); - $val = ""; + $val = ''; foreach my $entry (@$arr) { - $val .= "\"" . $self->project_file_name($entry) . "\" "; + $val .= '"' . $self->project_file_name($entry) . '" '; } $val =~ s/\s+$//; } @@ -63,20 +63,20 @@ sub project_file_name { sub get_dll_exe_template_input_file { - my($self) = shift; - return "nmakeexe"; + #my($self) = shift; + return 'nmakeexe'; } sub get_dll_template_input_file { - my($self) = shift; - return "nmakedll"; + #my($self) = shift; + return 'nmakedll'; } sub get_template { - my($self) = shift; - return "nmake"; + #my($self) = shift; + return 'nmake'; } diff --git a/modules/NMakeWorkspaceCreator.pm b/modules/NMakeWorkspaceCreator.pm index 1fb9dce4..fea75097 100644 --- a/modules/NMakeWorkspaceCreator.pm +++ b/modules/NMakeWorkspaceCreator.pm @@ -31,13 +31,13 @@ sub crlf { sub workspace_file_name { - my($self) = shift; - return "Makefile"; + #my($self) = shift; + return 'Makefile'; } sub workspace_per_project { - my($self) = shift; + #my($self) = shift; return 1; } @@ -63,21 +63,21 @@ sub write_project_targets { my($chdir) = 0; my($back) = 1; - ## If the directory isn't "." then we need + ## If the directory isn't '.' then we need ## to figure out how to get back to our starting point - if ($dir ne ".") { + if ($dir ne '.') { $chdir = 1; my($length) = length($dir); for(my $i = 0; $i < $length; $i++) { - if (substr($dir, $i, 1) eq "/") { + if (substr($dir, $i, 1) eq '/') { $back++; } } } - print $fh ($chdir ? "\tcd $dir$crlf" : "") . + print $fh ($chdir ? "\tcd $dir$crlf" : '') . "\t\$(MAKE) /f " . basename($project) . " $target$crlf" . - ($chdir ? "\tcd " . ("../" x $back) . $crlf : ""); + ($chdir ? "\tcd " . ('../' x $back) . $crlf : ''); } } @@ -91,11 +91,11 @@ sub write_comps { my($crlf) = $self->crlf(); print $fh "ALL:$crlf"; - $self->write_project_targets($fh, "CFG=\"\$(CFG)\"", \@list); + $self->write_project_targets($fh, 'CFG="$(CFG)"', \@list); print $fh "$crlf" . "CLEAN\tREALCLEAN:$crlf"; - $self->write_project_targets($fh, "CLEAN", \@list); + $self->write_project_targets($fh, 'CLEAN', \@list); } diff --git a/modules/Parser.pm b/modules/Parser.pm index db0d0537..afc738ff 100644 --- a/modules/Parser.pm +++ b/modules/Parser.pm @@ -13,6 +13,8 @@ package Parser; use strict; use FileHandle; +my($cwd) = Cwd::getcwd(); + # ************************************************************ # Subroutine Section # ************************************************************ @@ -25,11 +27,28 @@ sub new { } +sub cd { + my($self) = shift; + my($dir) = shift; + my($status) = chdir($dir); + if ($status) { + $cwd = $dir; + } + return $status; +} + + +sub getcwd { + #my($self) = shift; + return $cwd; +} + + sub strip_line { my($self) = shift; my($line) = shift; - $self->{'line_number'}++; + ++$self->{'line_number'}; $line =~ s/\/\/.*//; $line =~ s/^\s+//; $line =~ s/\s+$//; @@ -46,11 +65,11 @@ sub process_special { for(my $i = 0; $i < $length; $i++) { my($ch) = substr($line, $i, 1); if ($ch eq "\\" && $i + 1 < $length) { - substr($line, $i, 1) = ""; + substr($line, $i, 1) = ''; $length--; } elsif ($ch eq '"') { - substr($line, $i, 1) = ""; + substr($line, $i, 1) = ''; $length--; $i--; } @@ -64,7 +83,7 @@ sub read_file { my($input) = shift; my($ih) = new FileHandle(); my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; $self->{'line_number'} = 0; if (open($ih, $input)) { @@ -80,7 +99,7 @@ sub read_file { close($ih); } else { - $errorString = "ERROR: Unable to open for reading"; + $errorString = 'ERROR: Unable to open for reading'; $status = 0; } @@ -110,7 +129,7 @@ sub create_array { for(my $i = 0; $i <= $length; $i++) { my($ch) = substr($line, $i, 1); - if (!$double && ($ch eq "" || $ch =~ /\s/)) { + if (!$double && ($ch eq '' || $ch =~ /\s/)) { my($val) = substr($line, $prev, $i - $prev); $val =~ s/^\s+//; $val =~ s/\s+$//; @@ -127,7 +146,7 @@ sub create_array { $prev = $i + 1; } elsif ($double && $ch eq "\\" && $i + 1 < $length) { - substr($line, $i, 1) = ""; + substr($line, $i, 1) = ''; $length--; } elsif ($ch eq '"') { @@ -151,9 +170,9 @@ sub slash_to_backslash { # ************************************************************ sub parse_line { - my($self) = shift; - my($ih) = shift; - my($line) = shift; + #my($self) = shift; + #my($ih) = shift; + #my($line) = shift; } diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index fe13bb5e..1e9353ef 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -128,7 +128,7 @@ sub new { $self->{'matching_assignments'} = \%ma; $self->{'valid_components'} = \%vc; $self->{'exclude_components'} = \%ec; - $self->{'skeleton_endings'} = [ "C", "S" ]; + $self->{'skeleton_endings'} = [ 'C', 'S' ]; ## Allow subclasses to override the default extensions $self->set_component_extensions(); @@ -171,7 +171,7 @@ sub parse_line { if ($values[0] eq $type) { my($name) = $values[1]; my($typecheck) = $self->{'type_check'}; - if (defined $name && $name eq "}") { + if (defined $name && $name eq '}') { ## Project Ending my($rp) = $self->{'reading_parent'}; if (!defined $$rp[0] && !$self->{'reading_global'}) { @@ -195,7 +195,7 @@ sub parse_line { } } else { - $errorString = "ERROR: Invalid " . + $errorString = 'ERROR: Invalid ' . "assignment modification name: $ap"; $status = 0; } @@ -265,7 +265,7 @@ sub parse_line { } } } - elsif ($values[0] eq "assignment") { + elsif ($values[0] eq 'assignment') { my($name) = $values[1]; my($value) = $values[2]; if (defined $validNames{$name}) { @@ -276,7 +276,7 @@ sub parse_line { $status = 0; } } - elsif ($values[0] eq "assign_add") { + elsif ($values[0] eq 'assign_add') { my($name) = $values[1]; my($value) = $values[2]; if (defined $validNames{$name}) { @@ -287,7 +287,7 @@ sub parse_line { $status = 0; } } - elsif ($values[0] eq "assign_sub") { + elsif ($values[0] eq 'assign_sub') { my($name) = $values[1]; my($value) = $values[2]; if (defined $validNames{$name}) { @@ -298,7 +298,7 @@ sub parse_line { $status = 0; } } - elsif ($values[0] eq "component") { + elsif ($values[0] eq 'component') { my($comp) = $values[1]; my($name) = $values[2]; if (defined $name) { @@ -375,7 +375,7 @@ sub parse_components { while(<$fh>) { my($line) = $self->strip_line($_); - if ($line eq "") { + if ($line eq '') { } elsif ($line =~ /^(\w+)\s*{$/) { if (!defined $current || !$set) { @@ -469,7 +469,7 @@ sub parse_verbatim { while(<$fh>) { my($line) = $self->strip_line($_); - if ($line eq "") { + if ($line eq '') { } elsif ($line =~ /^}/) { ## This is not an error, @@ -542,14 +542,13 @@ sub process_assignment_sub { if (defined $nval) { my($parts) = $self->create_array($nval); - $nval = ""; + $nval = ''; foreach my $part (@$parts) { - if ($part ne $value && $part ne "") { + if ($part ne $value && $part ne '') { $nval .= "$part "; } } $self->process_assignment($name, $nval, $assign); - $self->process_duplicate_modification($name, $assign); } } @@ -563,12 +562,12 @@ sub process_duplicate_modification { ## either addition or subtraction, we are going to ## perform a little fix on the value to avoid multiple ## libraries and to try to insure the correct linking order - if ($name eq "libs" || $name eq "libpaths" || $name eq "includes") { + if ($name eq 'libs' || $name eq 'libpaths' || $name eq 'includes') { my($nval) = $self->get_assignment($name, $assign); if (defined $nval) { my($parts) = $self->create_array($nval); my(%seen) = (); - my($value) = ""; + my($value) = ''; foreach my $part (reverse @$parts) { if (!defined $seen{$part}) { $value = "$part $value"; @@ -584,7 +583,7 @@ sub process_duplicate_modification { sub read_template_input { my($self) = shift; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; my($file) = undef; my($tag) = undef; my($ti) = $self->get_ti_override(); @@ -652,7 +651,7 @@ sub read_template_input { else { if ($override) { $status = 0; - $errorString = "Unable to locate template input file."; + $errorString = 'Unable to locate template input file.'; } } } @@ -1234,7 +1233,7 @@ sub write_output_file { my($self) = shift; my($name) = shift; my($status) = 0; - my($error) = ""; + my($error) = ''; my($dir) = dirname($name); my($fh) = new FileHandle(); my($tover) = $self->get_template_override(); @@ -1243,7 +1242,7 @@ sub write_output_file { my($tfile) = $self->search_include_path($template); if (defined $tfile) { - if ($dir ne ".") { + if ($dir ne '.') { mkpath($dir, 0, 0777); } @@ -1263,7 +1262,7 @@ sub write_output_file { if (open($fh, ">$name")) { my($lines) = $tp->get_lines(); foreach my $line (@$lines) { - print $fh "$line"; + print $fh $line; } close($fh); my($fw) = $self->{'files_written'}; @@ -1288,7 +1287,7 @@ sub write_output_file { sub write_project { my($self) = shift; my($status) = 1; - my($error) = ""; + my($error) = ''; my($name) = $self->transform_file_name($self->project_file_name()); my($prjname) = $self->get_assignment('project_name'); my($progress) = $self->get_progress_callback(); @@ -1400,7 +1399,7 @@ sub update_project_info { my($names) = shift; my($sep) = shift; my($pi) = $self->get_project_info(); - my($value) = ""; + my($value) = ''; my($arr) = ($append && defined $$pi[0] ? pop(@$pi) : []); ## Set up the hash table when we are starting a new project_info @@ -1414,7 +1413,7 @@ sub update_project_info { my($key) = $narr[$i]; $value .= $self->translate_value($key, $tparser->get_value_with_default($key)) . - (defined $sep && $i != $#narr ? $sep : ""); + (defined $sep && $i != $#narr ? $sep : ''); } ## If we haven't seen this value yet, put it on the array @@ -1444,7 +1443,7 @@ sub get_verbatim { my($crlf) = $self->crlf(); foreach my $line (@{$thash->{$marker}}) { if (!defined $str) { - $str = ""; + $str = ''; } $str .= $self->process_special($line) . $crlf; } @@ -1462,22 +1461,22 @@ sub get_verbatim { # ************************************************************ sub specific_lookup { - my($self) = shift; - my($key) = shift; + #my($self) = shift; + #my($key) = shift; return undef; } sub save_project_value { - my($self) = shift; - my($name) = shift; - my($value) = shift; + #my($self) = shift; + #my($name) = shift; + #my($value) = shift; } sub get_type_append { - my($self) = shift; - return ""; + #my($self) = shift; + return ''; } @@ -1490,76 +1489,76 @@ sub translate_value { sub convert_slashes { - my($self) = shift; + #my($self) = shift; return 1; } sub fill_value { - my($self) = shift; - my($name) = shift; + #my($self) = shift; + #my($name) = shift; return undef; } sub separate_static_project { - my($self) = shift; + #my($self) = shift; return 0; } sub project_file_name { - my($self) = shift; + #my($self) = shift; return undef; } sub static_project_file_name { - my($self) = shift; + #my($self) = shift; return undef; } sub override_valid_component_extensions { - my($self) = shift; - my($comp) = shift; + #my($self) = shift; + #my($comp) = shift; return undef; } sub override_exclude_component_extensions { - my($self) = shift; - my($comp) = shift; + #my($self) = shift; + #my($comp) = shift; return undef; } sub get_dll_exe_template_input_file { - my($self) = shift; + #my($self) = shift; return undef; } sub get_lib_exe_template_input_file { - my($self) = shift; + #my($self) = shift; return undef; } sub get_lib_template_input_file { - my($self) = shift; + #my($self) = shift; return undef; } sub get_dll_template_input_file { - my($self) = shift; + #my($self) = shift; return undef; } sub get_template { - my($self) = shift; + #my($self) = shift; return undef; } diff --git a/modules/TemplateInputReader.pm b/modules/TemplateInputReader.pm index 09ee7621..3b9a5e21 100644 --- a/modules/TemplateInputReader.pm +++ b/modules/TemplateInputReader.pm @@ -38,10 +38,10 @@ sub parse_line { my($ih) = shift; my($line) = shift; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; my($current) = $self->{'current'}; - if ($line eq "") { + if ($line eq '') { } elsif ($line =~ /^([\w\s]+)\s*{$/) { ## Entering a new scope @@ -60,7 +60,7 @@ sub parse_line { } else { $status = 0; - $errorString = "ERROR: Unmatched curly brace"; + $errorString = 'ERROR: Unmatched curly brace'; } } elsif ($line =~ /^(\w+)\s*=\s*(.*)?/) { @@ -71,7 +71,7 @@ sub parse_line { $value = $self->create_array($value); } else { - $value = ""; + $value = ''; } if (!defined $$current[$self->{'cindex'}]->{$name}) { diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index ce76cde0..d93a9ad2 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -11,7 +11,6 @@ package TemplateParser; # ************************************************************ use strict; -use Cwd; use Parser; @@ -22,11 +21,22 @@ use vars qw(@ISA); # Data Section # ************************************************************ -my(@keywords) = ('if', 'else', 'endif', - 'noextension', 'dirname', 'basename', 'basenoextension', - 'foreach', 'forfirst', 'fornotfirst', - 'fornotlast', 'forlast', 'endfor', - 'comment', 'flag_overrides', 'marker', +my(%keywords) = ('if' => 1, + 'else' => 1, + 'endif' => 1, + 'noextension' => 1, + 'dirname' => 1, + 'basename' => 1, + 'basenoextension' => 1, + 'foreach' => 1, + 'forfirst' => 1, + 'fornotfirst' => 1, + 'fornotlast' => 1, + 'forlast' => 1, + 'endfor' => 1, + 'comment' => 1, + 'flag_overrides' => 1, + 'marker' => 1, ); # ************************************************************ @@ -39,10 +49,12 @@ sub new { my($self) = Parser::new($class); $self->{'prjc'} = $prjc; + $self->{'ti'} = $prjc->get_template_input(); + $self->{'crlf'} = undef; $self->{'values'} = {}; $self->{'defaults'} = {}; $self->{'lines'} = []; - $self->{'built'} = ""; + $self->{'built'} = ''; $self->{'sstack'} = []; $self->{'lstack'} = []; $self->{'if_skip'} = 0; @@ -63,7 +75,7 @@ sub new { sub basename { my($self) = shift; my($file) = shift; - for(my $i = length($file) - 1; $i >= 0; $i--) { + for(my $i = length($file) - 1; $i >= 0; --$i) { my($ch) = substr($file, $i, 1); if ($ch eq '/' || $ch eq '\\') { ## The template file may use this value (<%basename_found%>) @@ -80,7 +92,7 @@ sub basename { sub dirname { my($self) = shift; my($file) = shift; - for(my $i = length($file) - 1; $i != 0; $i--) { + for(my $i = length($file) - 1; $i != 0; --$i) { my($ch) = substr($file, $i, 1); if ($ch eq '/' || $ch eq '\\') { ## The template file may use this value (<%dirname_found%>) @@ -90,7 +102,7 @@ sub dirname { } } delete $self->{'values'}->{'dirname_found'}; - return "."; + return '.'; } @@ -101,26 +113,13 @@ sub strip_line { ## Override strip_line() from Parser. ## We need to preserve leading space and ## there is no comment string in templates. - $self->{'line_number'}++; + ++$self->{'line_number'}; $line =~ s/\s+$//; return $line; } -sub is_keyword { - my($self) = shift; - my($name) = shift; - - foreach my $key (@keywords) { - if ($name eq $key) { - return 1; - } - } - return 0; -} - - ## Append the current value to the line that is being ## built. This line may be a foreach line or a general ## line without a foreach. @@ -167,9 +166,9 @@ sub adjust_value { $parts = $self->create_array($value); } - $value = ""; + $value = ''; foreach my $part (@$parts) { - if ($part ne $$val[1] && $part ne "") { + if ($part ne $$val[1] && $part ne '') { $value .= "$part "; } } @@ -193,16 +192,18 @@ sub set_current_values { ## If any value within a foreach matches the name ## of a hash table within the template input we will ## set the values of that hash table in the current scope - my($ti) = $self->{'prjc'}->get_template_input(); + my($ti) = $self->{'ti'}; if (defined $ti) { my($counter) = $self->{'foreach'}->{'count'}; - my($value) = $ti->get_value($name); - if (defined $value && $counter >= 0 && UNIVERSAL::isa($value, 'HASH')) { - my(%copy) = (); - foreach my $key (keys %$value) { - $copy{$key} = $self->adjust_value($key, $$value{$key}); + if ($counter >= 0) { + my($value) = $ti->get_value($name); + if (defined $value && UNIVERSAL::isa($value, 'HASH')) { + my(%copy) = (); + foreach my $key (keys %$value) { + $copy{$key} = $self->adjust_value($key, $$value{$key}); + } + $self->{'foreach'}->{'temp_scope'}->[$counter] = \%copy; } - $self->{'foreach'}->{'temp_scope'}->[$counter] = \%copy; } } } @@ -223,7 +224,7 @@ sub relative { $value = \@built; } else { - my($cwd) = getcwd(); + my($cwd) = $self->getcwd(); my($start) = 0; my($fixed) = 0; @@ -254,17 +255,17 @@ sub relative { if (index($cwd, $val) == 0) { my($count) = 0; - substr($cwd, 0, length($val)) = ""; + substr($cwd, 0, length($val)) = ''; while($cwd =~ /^\\/) { $cwd =~ s/^\///; } my($length) = length($cwd); - for(my $i = 0; $i < $length; $i++) { + for(my $i = 0; $i < $length; ++$i) { if (substr($cwd, $i, 1) eq '/') { - $count++; + ++$count; } } - $val = "../" x $count; + $val = '../' x $count; $val =~ s/\/$//; if ($self->{'prjc'}->convert_slashes()) { $val = slash_to_backslash($val); @@ -290,16 +291,15 @@ sub get_value { ## First, check the temporary scope (set inside a foreach) if ($counter >= 0) { while(!defined $value && $counter >= 0) { - my($scope) = $self->{'foreach'}->{'temp_scope'}->[$counter]; - $value = $$scope{$name}; - $counter--; + $value = $self->{'foreach'}->{'temp_scope'}->[$counter]->{$name}; + --$counter; } $counter = $self->{'foreach'}->{'count'}; } if (!defined $value) { ## Next, check for a template value - my($ti) = $self->{'prjc'}->get_template_input(); + my($ti) = $self->{'ti'}; if (defined $ti) { $value = $ti->get_value($name); if (defined $value) { @@ -311,9 +311,8 @@ sub get_value { ## Next, check the inner to outer foreach ## scopes for overriding values while(!defined $value && $counter >= 0) { - my($scope) = $self->{'foreach'}->{'scope'}->[$counter]; - $value = $$scope{$name}; - $counter--; + $value = $self->{'foreach'}->{'scope'}->[$counter]->{$name}; + --$counter; } ## Then get the value from the project creator @@ -350,7 +349,7 @@ sub get_value_with_default { $value = $self->{'prjc'}->fill_value($name); if (!defined $value) { # print "DEBUG: WARNING: $name defaulting to empty string\n"; - $value = ""; + $value = ''; } } else { @@ -366,17 +365,16 @@ sub get_value_with_default { sub process_foreach { my($self) = shift; my($index) = $self->{'foreach'}->{'count'}; - my($name) = $self->{'foreach'}->{'names'}->[$index]; my($text) = $self->{'foreach'}->{'text'}->[$index]; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; my(@values) = (); - my($names) = $self->create_array($name); + my($names) = $self->create_array($self->{'foreach'}->{'names'}->[$index]); + my($name) = undef; - $name = undef; foreach my $n (@$names) { my($vals) = $self->get_value($n); - if (defined $vals && $vals ne "") { + if (defined $vals && $vals ne '') { if (!UNIVERSAL::isa($vals, 'ARRAY')) { $vals = $self->create_array($vals); } @@ -388,7 +386,7 @@ sub process_foreach { } ## Reset the text (it will be regenerated by calling parse_line - $self->{'foreach'}->{'text'}->[$index] = ""; + $self->{'foreach'}->{'text'}->[$index] = ''; if (defined $values[0]) { my($inner) = $name; @@ -400,7 +398,7 @@ sub process_foreach { $$scope{'forfirst'} = 1; $$scope{'fornotfirst'} = 0; - for(my $i = 0; $i <= $#values; $i++) { + for(my $i = 0; $i <= $#values; ++$i) { my($value) = $values[$i]; ## Set the corresponding values in the temporary scope @@ -429,9 +427,9 @@ sub process_foreach { ## Now parse the line of text, each time ## with different values - $self->{'foreach'}->{'processing'}++; + ++$self->{'foreach'}->{'processing'}; ($status, $errorString) = $self->parse_line(undef, $text); - $self->{'foreach'}->{'processing'}--; + --$self->{'foreach'}->{'processing'}; if (!$status) { last; } @@ -446,11 +444,9 @@ sub handle_end { my($self) = shift; my($name) = shift; my($status) = 1; - my($errorString) = ""; - my($sstack) = $self->{'sstack'}; - my($lstack) = $self->{'lstack'}; - my($end) = pop(@$sstack); - pop(@$lstack); + my($errorString) = ''; + my($end) = pop(@{$self->{'sstack'}}); + pop(@{$self->{'lstack'}}); if (!defined $end) { $status = 0; @@ -463,7 +459,7 @@ sub handle_end { my($index) = $self->{'foreach'}->{'count'}; ($status, $errorString) = $self->process_foreach(); if ($status) { - $self->{'foreach'}->{'count'}--; + --$self->{'foreach'}->{'count'}; $self->append_current($self->{'foreach'}->{'text'}->[$index]); } } @@ -514,14 +510,12 @@ sub get_flag_overrides { sub handle_if { my($self) = shift; my($val) = shift; - my($sstack) = $self->{'sstack'}; - my($lstack) = $self->{'lstack'}; my($name) = 'endif'; - push(@$lstack, $self->line_number() . " $val"); + push(@{$self->{'lstack'}}, $self->line_number() . " $val"); if (!$self->{'if_skip'}) { my($true) = 1; - push(@$sstack, $name); + push(@{$self->{'sstack'}}, $name); if ($val =~ /^!(.*)/) { $val = $1; $val =~ s/^\s+//; @@ -543,21 +537,19 @@ sub handle_if { } } else { - push(@$sstack, "*$name"); + push(@{$self->{'sstack'}}, "*$name"); } } sub handle_else { - my($self) = shift; - my($sstack) = $self->{'sstack'}; - my(@scopy) = @$sstack; - my($name) = "endif"; + my($self) = shift; + my(@scopy) = @{$self->{'sstack'}}; ## This method does not take into account that ## multiple else clauses could be supplied to a single if. ## Someday, this may be fixed. - if (defined $scopy[$#scopy] && $scopy[$#scopy] eq $name) { + if (defined $scopy[$#scopy] && $scopy[$#scopy] eq 'endif') { $self->{'if_skip'} ^= 1; } } @@ -566,22 +558,20 @@ sub handle_else { sub handle_foreach { my($self) = shift; my($val) = shift; - my($sstack) = $self->{'sstack'}; - my($lstack) = $self->{'lstack'}; my($name) = 'endfor'; - push(@$lstack, $self->line_number()); + push(@{$self->{'lstack'}}, $self->line_number()); if (!$self->{'if_skip'}) { - push(@$sstack, $name); - $self->{'foreach'}->{'count'}++; + push(@{$self->{'sstack'}}, $name); + ++$self->{'foreach'}->{'count'}; my($index) = $self->{'foreach'}->{'count'}; $self->{'foreach'}->{'names'}->[$index] = $val; - $self->{'foreach'}->{'text'}->[$index] = ""; + $self->{'foreach'}->{'text'}->[$index] = ''; $self->{'foreach'}->{'scope'}->[$index] = {}; } else { - push(@$sstack, "*$name"); + push(@{$self->{'sstack'}}, "*$name"); } } @@ -649,14 +639,10 @@ sub handle_basenoextension { sub handle_flag_overrides { my($self) = shift; my($name) = shift; - my($type) = ""; + my($type) = ''; ($name, $type) = split(/,\s*/, $name); - my($file) = $self->get_value($name); - my($prjc) = $self->{'prjc'}; - my($fo) = $prjc->{'flag_overrides'}; - if (!$self->{'if_skip'}) { my($value) = $self->get_flag_overrides($name, $type); if (defined $value) { @@ -689,14 +675,14 @@ sub split_name_value { my($name) = undef; my($val) = undef; - for(my $i = 0; $i < $length; $i++) { + for(my $i = 0; $i < $length; ++$i) { my($ch) = substr($line, $i, 1); if (!defined $name && $ch eq '(') { $name = substr($line, 0, $i); - $val = ""; + $val = ''; } elsif (!defined $name && $ch eq '%') { - if (substr($line, $i + 1, 1) eq ">") { + if (substr($line, $i + 1, 1) eq '>') { $name = substr($line, 0, $i); last; } @@ -705,7 +691,7 @@ sub split_name_value { $val .= $ch; } elsif (defined $val && $ch eq ')') { - if (substr($line, $i + 1, 2) eq "%>") { + if (substr($line, $i + 1, 2) eq '%>') { last; } else { @@ -713,6 +699,7 @@ sub split_name_value { } } } + return $name, $val; } @@ -722,9 +709,9 @@ sub process_name { my($line) = shift; my($length) = 0; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; - if ($line eq "") { + if ($line eq '') { } elsif ($line =~ /^(\w+)(\(([^\)]+|\".*\"|flag_overrides\([^\)]+,\s*[^\)]+\))\))?%>/) { my($name, $val) = $self->split_name_value($line); @@ -734,7 +721,7 @@ sub process_name { $length += length($val) + 2; } - if ($self->is_keyword($name)) { + if (defined $keywords{$name}) { if ($name eq 'endif' || $name eq 'endfor') { ($status, $errorString) = $self->handle_end($name); } @@ -787,9 +774,9 @@ sub process_name { else { my($error) = $line; my($length) = length($line); - for(my $i = 0; $i < $length; $i++) { + for(my $i = 0; $i < $length; ++$i) { my($part) = substr($line, $i, 2); - if ($part eq "%>") { + if ($part eq '%>') { $error = substr($line, 0, $i + 2); last; } @@ -806,6 +793,9 @@ sub collect_data { my($self) = shift; my($prjc) = $self->{'prjc'}; + ## Save crlf so we don't have to keep going back to the prjc + $self->{'crlf'} = $prjc->crlf(); + ## Collect the components into {'values'} somehow foreach my $key (keys %{$prjc->{'valid_components'}}) { my(@list) = $prjc->get_component_list($key); @@ -832,23 +822,18 @@ sub collect_data { sub is_only_keyword { - my($self) = shift; - my($line) = shift; - my($status) = 0; + my($self) = shift; + my($line) = shift; ## Does the line contain only a keyword? if ($line =~ /^<%(.*)%>$/) { my($part) = $1; if ($part !~ /%>/) { - foreach my $keyword (@keywords) { - if ($part =~ /^$keyword/) { - $status = 1; - last; - } - } + $part =~ s/\(.*//; + return (defined $keywords{$part} ? 1 : 0); } } - return $status; + return 0; } @@ -857,12 +842,12 @@ sub parse_line { my($ih) = shift; my($line) = shift; my($status) = 1; - my($errorString) = ""; + my($errorString) = ''; my($length) = length($line); my($name) = 0; - my($crlf) = $self->{'prjc'}->crlf(); + my($crlf) = $self->{'crlf'}; my($clen) = length($crlf); - my($startempty) = ($line eq "" ? 1 : 0); + my($startempty) = ($line eq '' ? 1 : 0); my($append_name) = 0; ## If processing a foreach or the line only @@ -875,17 +860,17 @@ sub parse_line { } if ($self->{'foreach'}->{'count'} < 0) { - $self->{'built'} = ""; + $self->{'built'} = ''; } - for(my $i = 0; $i < $length; $i++) { + for(my $i = 0; $i < $length; ++$i) { my($part) = substr($line, $i, 2); - if ($part eq "<%") { - $i++; + if ($part eq '<%') { + ++$i; $name = 1; } - elsif ($part eq "%>") { - $i++; + elsif ($part eq '%>') { + ++$i; $name = 0; if ($append_name) { $append_name = 0; @@ -895,12 +880,12 @@ sub parse_line { } } elsif ($name) { - my($substr) = substr($line, $i); + my($substr) = substr($line, $i); my($efcheck) = ($substr =~ /^endfor\%\>/); my($focheck) = ($substr =~ /^foreach\(/); if ($focheck && $self->{'foreach'}->{'count'} >= 0) { - $self->{'foreach'}->{'nested'}++; + ++$self->{'foreach'}->{'nested'}; } if ($self->{'foreach'}->{'count'} < 0 || @@ -925,13 +910,13 @@ sub parse_line { else { $name = 0; if (!$self->{'if_skip'}) { - $self->append_current("<%" . substr($line, $i, 1)); + $self->append_current('<%' . substr($line, $i, 1)); $append_name = 1; } } if ($efcheck && $self->{'foreach'}->{'nested'} > 0) { - $self->{'foreach'}->{'nested'}--; + --$self->{'foreach'}->{'nested'}; } } else { @@ -945,9 +930,8 @@ sub parse_line { ## If the line started out empty and we're not ## skipping from the start or the built up line is not empty if ($startempty || - ($self->{'built'} ne $crlf && $self->{'built'} ne "")) { - my($lines) = $self->{'lines'}; - push(@$lines, $self->{'built'}); + ($self->{'built'} ne $crlf && $self->{'built'} ne '')) { + push(@{$self->{'lines'}}, $self->{'built'}); } } diff --git a/modules/VA4ProjectCreator.pm b/modules/VA4ProjectCreator.pm index dd2a9964..942be40a 100644 --- a/modules/VA4ProjectCreator.pm +++ b/modules/VA4ProjectCreator.pm @@ -21,7 +21,7 @@ use vars qw(@ISA); # Data Section # ************************************************************ -my($sname) = "_Static"; +my($sname) = '_Static'; # ************************************************************ # Subroutine Section @@ -32,13 +32,13 @@ sub translate_value { my($key) = shift; my($val) = shift; - if ($key eq 'depends' && $val ne "") { + if ($key eq 'depends' && $val ne '') { my($wt) = $self->get_writing_type(); my($arr) = $self->create_array($val); - $val = ""; + $val = ''; foreach my $entry (@$arr) { - $val .= "\"" . ($wt == 1 ? $self->static_project_file_name($entry) : - $self->project_file_name($entry)) . "\" "; + $val .= '"' . ($wt == 1 ? $self->static_project_file_name($entry) : + $self->project_file_name($entry)) . '" '; } $val =~ s/\s+$//; } @@ -47,7 +47,7 @@ sub translate_value { sub convert_slashes { - my($self) = shift; + #my($self) = shift; return 0; } @@ -67,7 +67,7 @@ sub crlf { sub separate_static_project { - my($self) = shift; + #my($self) = shift; return 1; } @@ -97,32 +97,32 @@ sub static_project_file_name { sub get_dll_exe_template_input_file { - my($self) = shift; - return "va4iccdllexe"; + #my($self) = shift; + return 'va4iccdllexe'; } sub get_lib_exe_template_input_file { - my($self) = shift; - return "va4icclibexe"; + #my($self) = shift; + return 'va4icclibexe'; } sub get_lib_template_input_file { - my($self) = shift; - return "va4icclib"; + #my($self) = shift; + return 'va4icclib'; } sub get_dll_template_input_file { - my($self) = shift; - return "va4iccdll"; + #my($self) = shift; + return 'va4iccdll'; } sub get_template { - my($self) = shift; - return "va4icc"; + #my($self) = shift; + return 'va4icc'; } diff --git a/modules/VA4WorkspaceCreator.pm b/modules/VA4WorkspaceCreator.pm index f1eebf02..53b64969 100644 --- a/modules/VA4WorkspaceCreator.pm +++ b/modules/VA4WorkspaceCreator.pm @@ -31,7 +31,7 @@ sub crlf { sub workspace_file_name { my($self) = shift; - return $self->get_workspace_name() . ".icp"; + return $self->get_workspace_name() . '.icp'; } diff --git a/modules/VC6ProjectCreator.pm b/modules/VC6ProjectCreator.pm index 17093fa3..f2d4fccd 100644 --- a/modules/VC6ProjectCreator.pm +++ b/modules/VC6ProjectCreator.pm @@ -21,11 +21,11 @@ use vars qw(@ISA); # Data Section # ************************************************************ -my($dynamiclib) = "DLL"; -my($staticlib) = "LIB"; -my($dynamicexe) = "EXE"; -my($staticexe) = "Static EXE"; -my($sname) = "_Static"; +my($dynamiclib) = 'DLL'; +my($staticlib) = 'LIB'; +my($dynamicexe) = 'EXE'; +my($staticexe) = 'Static EXE'; +my($sname) = '_Static'; # ************************************************************ # Subroutine Section @@ -50,19 +50,19 @@ sub base_project_name { my($self) = shift; return $self->transform_file_name( $self->remove_type_append($self->project_name()) . - ($self->get_writing_type() == 1 ? $sname : "")); + ($self->get_writing_type() == 1 ? $sname : '')); } sub get_static_append { - my($self) = shift; + #my($self) = shift; return $sname; } sub get_type_append { my($self) = shift; - my($type) = ""; + my($type) = ''; if ($self->lib_target()) { ## Set the type_append preserving whitespace if ($self->get_writing_type() == 1) { @@ -90,10 +90,10 @@ sub translate_value { my($key) = shift; my($val) = shift; - if ($key eq 'depends' && $val ne "") { + if ($key eq 'depends' && $val ne '') { my($arr) = $self->create_array($val); my($app) = $dynamiclib; - $val = ""; + $val = ''; ## Only write dependencies for non-static projects ## and static exe projects @@ -142,8 +142,8 @@ sub fill_value { my($name) = shift; my($value) = undef; - if ($name eq "make_file_name") { - $value = $self->base_project_name() . ".mak"; + if ($name eq 'make_file_name') { + $value = $self->base_project_name() . '.mak'; } return $value; @@ -151,14 +151,14 @@ sub fill_value { sub separate_static_project { - my($self) = shift; + #my($self) = shift; return 1; } sub project_file_name { my($self) = shift; - return $self->project_name() . ".dsp"; + return $self->project_name() . '.dsp'; } @@ -197,32 +197,32 @@ sub override_exclude_component_extensions { sub get_dll_exe_template_input_file { - my($self) = shift; - return "vc6dspdllexe"; + #my($self) = shift; + return 'vc6dspdllexe'; } sub get_lib_exe_template_input_file { - my($self) = shift; - return "vc6dsplibexe"; + #my($self) = shift; + return 'vc6dsplibexe'; } sub get_lib_template_input_file { - my($self) = shift; - return "vc6dsplib"; + #my($self) = shift; + return 'vc6dsplib'; } sub get_dll_template_input_file { - my($self) = shift; - return "vc6dspdll"; + #my($self) = shift; + return 'vc6dspdll'; } sub get_template { - my($self) = shift; - return "vc6dsp"; + #my($self) = shift; + return 'vc6dsp'; } diff --git a/modules/VC6WorkspaceCreator.pm b/modules/VC6WorkspaceCreator.pm index d68e2962..f7ca71cf 100644 --- a/modules/VC6WorkspaceCreator.pm +++ b/modules/VC6WorkspaceCreator.pm @@ -31,7 +31,7 @@ sub crlf { sub workspace_file_name { my($self) = shift; - return $self->get_workspace_name() . ".dsw"; + return $self->get_workspace_name() . '.dsw'; } @@ -42,7 +42,7 @@ sub pre_workspace { print $fh "Microsoft Developer Studio Workspace File, Format Version 6.00$crlf" . "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!$crlf" . - "$crlf"; + $crlf; } @@ -61,17 +61,17 @@ sub write_comps { $project = $self->slash_to_backslash($project); print $fh "###############################################################################$crlf" . - "$crlf" . + $crlf . "Project: \"$name\"=$project - Package Owner=<4>$crlf" . - "$crlf" . + $crlf . "Package=<5>$crlf" . "{{{$crlf" . "}}}$crlf" . - "$crlf" . + $crlf . "Package=<4>$crlf" . "{{{$crlf"; - if (defined $deps && $deps ne "") { + if (defined $deps && $deps ne '') { my($darr) = $self->create_array($deps); foreach my $dep (@$darr) { ## Avoid cirular dependencies @@ -83,8 +83,7 @@ sub write_comps { } } - print $fh "}}}$crlf" . - "$crlf"; + print $fh "}}}$crlf$crlf"; } } @@ -95,19 +94,19 @@ sub post_workspace { my($crlf) = $self->crlf(); print $fh "###############################################################################$crlf" . - "$crlf" . + $crlf . "Global:$crlf" . - "$crlf" . + $crlf . "Package=<5>$crlf" . "{{{$crlf" . "}}}$crlf" . - "$crlf" . + $crlf . "Package=<3>$crlf" . "{{{$crlf" . "}}}$crlf" . - "$crlf" . + $crlf . "###############################################################################$crlf" . - "$crlf"; + $crlf; } diff --git a/modules/VC7ProjectCreator.pm b/modules/VC7ProjectCreator.pm index 08bc44a6..ae85b933 100644 --- a/modules/VC7ProjectCreator.pm +++ b/modules/VC7ProjectCreator.pm @@ -27,11 +27,11 @@ sub translate_value { my($key) = shift; my($val) = shift; - if ($key eq 'depends' && $val ne "") { + if ($key eq 'depends' && $val ne '') { my($arr) = $self->create_array($val); - $val = ""; + $val = ''; foreach my $entry (@$arr) { - $val .= "\"" . $self->project_file_name($entry) . "\" "; + $val .= '"' . $self->project_file_name($entry) . '" '; } $val =~ s/\s+$//; } @@ -78,10 +78,11 @@ sub fill_value { my($name) = shift; my($value) = undef; - if ($name eq "guid") { + if ($name eq 'guid') { my($guid) = new GUID(); $value = $guid->generate($self->project_file_name(), - $self->get_current_input()); + $self->get_current_input(), + $self->getcwd()); } return $value; } @@ -100,20 +101,20 @@ sub project_file_name { sub get_dll_exe_template_input_file { - my($self) = shift; - return "vc7exe"; + #my($self) = shift; + return 'vc7exe'; } sub get_dll_template_input_file { - my($self) = shift; - return "vc7dll"; + #my($self) = shift; + return 'vc7dll'; } sub get_template { - my($self) = shift; - return "vc7"; + #my($self) = shift; + return 'vc7'; } diff --git a/modules/VC7WorkspaceCreator.pm b/modules/VC7WorkspaceCreator.pm index 23fa4931..fff045ce 100644 --- a/modules/VC7WorkspaceCreator.pm +++ b/modules/VC7WorkspaceCreator.pm @@ -31,7 +31,7 @@ sub crlf { sub workspace_file_name { my($self) = shift; - return $self->get_workspace_name() . ".sln"; + return $self->get_workspace_name() . '.sln'; } @@ -92,7 +92,7 @@ sub write_comps { foreach my $project (@list) { my($pi) = $$pjs{$project}; my($name, $deps, $pguid) = @$pi; - if (defined $deps && $deps ne "") { + if (defined $deps && $deps ne '') { my($darr) = $self->create_array($deps); my($i) = 0; foreach my $dep (@$darr) { diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index d357481e..895c2f81 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -11,7 +11,6 @@ package WorkspaceCreator; # ************************************************************ use strict; -use Cwd; use FileHandle; use File::Path; use File::Basename; @@ -73,7 +72,7 @@ sub parse_line { if ($values[0] eq $self->{'grammar_type'}) { my($name) = $values[1]; my($typecheck) = $self->{'type_check'}; - if (defined $name && $name eq "}") { + if (defined $name && $name eq '}') { my($rp) = $self->{'reading_parent'}; if (!defined $$rp[0]) { ## Fill in all the default values @@ -86,8 +85,8 @@ sub parse_line { $self->write_workspace($generator); } else { - $errorString = "ERROR: Unable to " . - "generate all of the project files"; + $errorString = 'ERROR: Unable to ' . + 'generate all of the project files'; $status = 0; } @@ -200,7 +199,7 @@ sub generate_default_components { ## string, so the Project Creator will generate ## the default project file. if (!defined $$pjf[0]) { - push(@$pjf, ""); + push(@$pjf, ''); } } } @@ -236,7 +235,7 @@ sub write_workspace { my($name) = $self->transform_file_name($self->workspace_file_name()); my($dir) = dirname($name); - if ($dir ne ".") { + if ($dir ne '.') { mkpath($dir, 0, 0777); } if (open($fh, ">$name")) { @@ -263,7 +262,7 @@ sub save_project_info { my($pi) = shift; my($c) = 0; foreach my $pj (@$gen) { - my($full) = ($dir ne "." ? "$dir/" : "") . $pj; + my($full) = ($dir ne '.' ? "$dir/" : '') . $pj; push(@$projects, $full); $$pi{$full} = $$gpi[$c]; $c++; @@ -277,35 +276,34 @@ sub generate_project_files { my(@projects) = (); my(%pi) = (); my($generator) = $self->project_creator(); - my($cwd) = getcwd(); + my($cwd) = $self->getcwd(); foreach my $file (@{$self->{'project_files'}}) { my($dir) = dirname($file); - my($gen) = []; ## We must change to the subdirectory for ## which this project file is intended - if (chdir($dir)) { + if ($self->cd($dir)) { $status = $generator->generate(basename($file)); ## If any one project file fails, then stop ## processing altogether. if (!$status) { - return $status; + return $status, $generator; } ## Get the individual project information and ## generated file name(s) - $gen = $generator->get_files_written(); + my($gen) = $generator->get_files_written(); + my($gpi) = $generator->get_project_info(); ## 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 '.' && $self->workspace_per_project()) { my(%perpi) = (); my(@perprojects) = (); - my($gpi) = $generator->get_project_info(); - $self->save_project_info($gen, $gpi, ".", \@perprojects, \%perpi); + $self->save_project_info($gen, $gpi, '.', \@perprojects, \%perpi); ## Set our per project information $self->{'projects'} = \@perprojects; @@ -318,10 +316,13 @@ sub generate_project_files { $self->{'projects'} = []; $self->{'project_info'} = {}; } - chdir($cwd); + $self->cd($cwd); + $self->save_project_info($gen, $gpi, $dir, \@projects, \%pi); + } + else { + ## Unable to change to the directory + return 0, $generator; } - my($gpi) = $generator->get_project_info(); - $self->save_project_info($gen, $gpi, $dir, \@projects, \%pi); } $self->{'projects'} = \@projects; @@ -364,7 +365,7 @@ sub sort_dependencies { foreach my $project (@list) { my($dname) = dirname($project); - if ($dname ne ".") { + if ($dname ne '.') { $prepend{basename($project)} = dirname($project); } } @@ -376,13 +377,13 @@ sub sort_dependencies { my($pi) = $$pjs{$project}; my($name, $deps) = @$pi; - if ($deps ne "") { + if ($deps ne '') { my($darr) = $self->create_array($deps); my($moved) = 0; foreach my $dep (@$darr) { my($base) = basename($dep); my($full) = (defined $prepend{$base} ? - "$prepend{$base}/" : "") . $base; + "$prepend{$base}/" : '') . $base; if ($project ne $full) { ## See if the dependency is listed after this project for(my $j = $i; $j <= $#list; $j++) { @@ -429,38 +430,44 @@ sub project_creator { } +sub sort_files { + #my($self) = shift; + return 0; +} + + # ************************************************************ # Virtual Methods To Be Overridden # ************************************************************ sub workspace_file_name { - my($self) = shift; - return ""; + #my($self) = shift; + return ''; } sub workspace_per_project { - my($self) = shift; + #my($self) = shift; return 0; } sub pre_workspace { - my($self) = shift; - my($fh) = shift; + #my($self) = shift; + #my($fh) = shift; } sub write_comps { - my($self) = shift; - my($fh) = shift; - my($gens) = shift; + #my($self) = shift; + #my($fh) = shift; + #my($gens) = shift; } sub post_workspace { - my($self) = shift; - my($fh) = shift; + #my($self) = shift; + #my($fh) = shift; } |