summaryrefslogtreecommitdiff
path: root/modules/CCWorkspaceCreator.pm
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2006-09-26 11:52:21 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2006-09-26 11:52:21 +0000
commit65ab209e41b7f99a40f1440eec143a2e38cff301 (patch)
treef0e8042c09193c157aff55ec099dc2466ffabf8b /modules/CCWorkspaceCreator.pm
parentcdba65e2981b01d1f4099c411b6fc6b3f9fbdc2e (diff)
downloadMPC-65ab209e41b7f99a40f1440eec143a2e38cff301.tar.gz
ChangeLogTag: Tue Sep 26 11:49:52 UTC 2006 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'modules/CCWorkspaceCreator.pm')
-rw-r--r--modules/CCWorkspaceCreator.pm113
1 files changed, 113 insertions, 0 deletions
diff --git a/modules/CCWorkspaceCreator.pm b/modules/CCWorkspaceCreator.pm
new file mode 100644
index 00000000..ab68c042
--- /dev/null
+++ b/modules/CCWorkspaceCreator.pm
@@ -0,0 +1,113 @@
+package CCWorkspaceCreator;
+
+# ************************************************************
+# Description : A Code Composer Workspace creator
+# Author : Chad Elliott
+# Create Date : 9/18/2006
+# ************************************************************
+
+# ************************************************************
+# Pragmas
+# ************************************************************
+
+use strict;
+
+use CCProjectCreator;
+use WorkspaceCreator;
+
+use vars qw(@ISA);
+@ISA = qw(WorkspaceCreator);
+
+# ************************************************************
+# Subroutine Section
+# ************************************************************
+
+sub compare_output {
+ #my($self) = shift;
+ return 1;
+}
+
+
+sub crlf {
+ my($self) = shift;
+ return $self->windows_crlf();
+}
+
+
+sub workspace_file_name {
+ my($self) = shift;
+ return $self->get_modified_workspace_name($self->get_workspace_name(),
+ '.code_composer');
+}
+
+
+sub write_comps {
+ my($self) = shift;
+ my($fh) = shift;
+ my($creator) = shift;
+ my($crlf) = $self->crlf();
+
+ foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
+ print $fh "$project$crlf";
+ $self->add_dependencies($creator, $project);
+ }
+}
+
+
+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 '.');
+
+ if (open($fh, "$outdir/$proj")) {
+ my($write) = 0;
+ my(@read) = ();
+ while(<$fh>) {
+ if (/MPC\s+ADD\s+DEPENDENCIES/) {
+ 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,
+ "$outdir/$proj",
+ $dep);
+ if (defined $relative) {
+ if (!$write) {
+ $write = 1;
+ push(@read, "[Project Dependencies]$crlf");
+ }
+ push(@read, "Source=\"$relative\"$crlf");
+ push(@projs, $relative);
+ }
+ }
+ if ($write) {
+ push(@read, $crlf);
+ foreach my $proj (@projs) {
+ push(@read, "[\"$proj\" Settings]$crlf",
+ "MatchConfigName=true$crlf",
+ $crlf);
+ }
+ }
+ else {
+ last;
+ }
+ }
+ else {
+ push(@read, $_);
+ }
+ }
+ close($fh);
+
+ if ($write && open($fh, ">$outdir/$proj")) {
+ foreach my $line (@read) {
+ print $fh $line;
+ }
+ close($fh);
+ }
+ }
+}
+
+1;