diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2008-07-18 16:05:54 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2008-07-18 16:05:54 +0000 |
commit | 6fd3ad3f828f394c6f668cc6b43981a22e1f6317 (patch) | |
tree | 61c90e72b7bf915d9d80c8e5e1837abbbaaadb0d /modules/CCWorkspaceCreator.pm | |
parent | 97fa1ff1e6cf30fa55cb9c32081ea3ef9055fbd2 (diff) | |
download | MPC-6fd3ad3f828f394c6f668cc6b43981a22e1f6317.tar.gz |
ChangeLogTag: Fri Jul 18 16:03:52 UTC 2008 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'modules/CCWorkspaceCreator.pm')
-rw-r--r-- | modules/CCWorkspaceCreator.pm | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/modules/CCWorkspaceCreator.pm b/modules/CCWorkspaceCreator.pm index 84afd883..5cb7bf72 100644 --- a/modules/CCWorkspaceCreator.pm +++ b/modules/CCWorkspaceCreator.pm @@ -24,23 +24,24 @@ use vars qw(@ISA); # ************************************************************ sub compare_output { - #my($self) = shift; + #my $self = shift; return 1; } sub workspace_file_extension { - #my($self) = shift; + #my $self = shift; return '.code_composer'; } sub write_comps { - my($self) = shift; - my($fh) = shift; - my($creator) = shift; - my($crlf) = $self->crlf(); + my($self, $fh, $creator) = @_; + my $crlf = $self->crlf(); + ## Workspace only consists of the name of the project. Really, Code + ## Composer doesn't use a workspace. Each project contains the + ## dependencies. foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) { print $fh "$project$crlf"; $self->add_dependencies($creator, $project); @@ -49,53 +50,61 @@ sub write_comps { sub add_dependencies { - my($self) = shift; - my($creator) = shift; - my($proj) = shift; - my($fh) = new FileHandle(); - my($outdir) = $self->get_outdir(); - $outdir = $self->getcwd() if ($outdir eq '.'); + my($self, $creator, $proj) = @_; + my $fh = new FileHandle(); + my $outdir = $self->get_outdir(); + $outdir = $self->getcwd() if ($outdir eq '.'); if (open($fh, "$outdir/$proj")) { - my($write) = 0; - my(@read) = (); - my($cwd) = $self->getcwd(); + my @read; + my $write; + my $cwd = $self->getcwd(); while(<$fh>) { + ## This is a comment found in cc.mpd if the project contains the + ## 'after' keyword setting. if (/MPC\s+ADD\s+DEPENDENCIES/) { - my(@projs) = (); - my($crlf) = $self->crlf(); - my($deps) = $self->get_validated_ordering($proj); + my @projs; + my $crlf = $self->crlf(); + my $deps = $self->get_validated_ordering($proj); foreach my $dep (@$deps) { - my($relative) = $self->get_relative_dep_file($creator, - "$cwd/$proj", - $dep); + my $relative = $self->get_relative_dep_file($creator, + "$cwd/$proj", $dep); if (defined $relative) { if (!$write) { + ## Indicate that we need to re-write the file and add in + ## the start of the project dependencies section $write = 1; push(@read, "[Project Dependencies]$crlf"); } + + ## Add in the dependency and save the project name for later. push(@read, "Source=\"$relative\"$crlf"); push(@projs, $relative); } } if ($write) { + ## Finish off the dependency information for the current + ## project. push(@read, $crlf); foreach my $proj (@projs) { push(@read, "[\"$proj\" Settings]$crlf", - "MatchConfigName=true$crlf", - $crlf); + "MatchConfigName=true$crlf", $crlf); } } else { + ## We don't need to re-write the file, so we can stop reading + ## it. last; } } else { + ## Save the line to possibly be written out at the end. push(@read, $_); } } close($fh); + ## If we need to re-write the file, then do so if ($write && open($fh, ">$outdir/$proj")) { foreach my $line (@read) { print $fh $line; |