1 package WB26WorkspaceCreator
;
3 # ************************************************************
4 # Description : Workbench 2.6 / VxWorks 6.4 generator
5 # Author : Johnny Willemsen
6 # Create Date : 07/01/2008
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
15 use WB26ProjectCreator
;
19 @ISA = qw(WorkspaceCreator);
21 # ************************************************************
23 # ************************************************************
25 sub requires_make_coexistence
{
30 sub supports_make_coexistence
{
35 sub workspace_file_name
{
37 return 'org.eclipse.core.resources.prefs';
42 my $crlf = $self->crlf();
44 ## Optionally print the workspace comment
45 $self->print_workspace_comment($fh,
46 '#----------------------------------------------------------------------------', $crlf,
47 '# WindRiver Workbench generator', $crlf,
51 '# This file was generated by MPC. Any changes made directly to', $crlf,
52 '# this file will be lost the next time it is generated.', $crlf,
53 '# This file should be placed in the .metadata\.plugins\org.eclipse.core.runtime\.settings directory', $crlf,
55 '# MPC Command:', $crlf,
57 '#----------------------------------------------------------------------------', $crlf);
59 ## Unchanging initial settings
60 print $fh 'version=1', $crlf,
61 'eclipse.preferences.version=1', $crlf,
62 'description.defaultbuildorder=false', $crlf;
67 my $pjs = $self->get_project_info();
68 my @list = $self->sort_dependencies($self->get_projects(), 0);
70 ## Print out the target
71 print $fh 'description.buildorder=';
72 foreach my $project (@list) {
73 print $fh "$$pjs{$project}->[0]/";
75 print $fh $self->crlf();
79 my($self, $fh, $creator) = @_;
80 my $crlf = $self->crlf();
82 ## Clear out the seen dependency hash for use within the
83 ## add_dependencies method.
84 $self->{'seen_deps'} = {};
86 ## Print out the project dependencies
87 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
88 print $fh "$project$crlf";
89 $self->add_dependencies($creator, $project);
93 sub get_additional_output
{
94 ## Create the accompanying list file. It always goes in the same
95 ## directory as the first workspace output file. See
96 ## WorkspaceCreator.pm for a description of the array elements.
97 return [[undef, 'wb26projects.lst', \
&list_file_body
]];
102 my $crlf = $self->crlf();
104 ## Optionally print the workspace comment
105 $self->print_workspace_comment($fh,
106 '#----------------------------------------------------------------------------', $crlf,
107 '# WindRiver Workbench generator', $crlf,
111 '# This file was generated by MPC. Any changes made directly to', $crlf,
112 '# this file will be lost the next time it is generated.', $crlf,
113 '# MPC Command:', $crlf,
115 '#----------------------------------------------------------------------------', $crlf);
117 ## Print out each target separately
118 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
119 print $fh Cwd
::abs_path
($self->mpc_dirname($project)), '/.project', $crlf;
123 sub add_dependencies
{
124 my($self, $creator, $proj) = @_;
125 my $outdir = $self->mpc_dirname($proj);
127 ## These values will be changed after the first time through the for
129 my $pre = "\t\t" . '<project>';
130 my $post = '</project>';
131 my $outfile = $outdir . '/.project';
133 ## Go through twice to edit both the .project and .wrproject files
134 for(my $i = 0; $i < 2; $i++) {
135 my $fh = new FileHandle
();
136 if (open($fh, $outfile)) {
137 ## Get the dependencies and store them based on the directory of
138 ## the project file. We will check them later.
139 my $deps = $self->get_validated_ordering($proj);
140 my $key = $self->mpc_basename($self->mpc_dirname($proj));
141 $self->{'seen_deps'}->{$key} = {};
142 foreach my $dep (@
$deps) {
143 $self->{'seen_deps'}->{$key}->{$dep} = 1;
147 my $cwd = $self->getcwd();
149 ## This is a comment found in wb26.mpd and wb26wrproject.mpd if
150 ## the project is an executable, contains the 'after' keyword
151 ## setting, and the 'enable_subprojects' template variable.
152 if (/MPC\s+ADD\s+DEPENDENCIES/) {
153 my $crlf = $self->crlf();
156 foreach my $dep (reverse @
$deps) {
157 ## If we've seen this dependency, we don't need to add it
158 ## again. The build tool will handle it correctly.
160 my $relative = $self->get_relative_dep_file($creator,
162 ## Since we're looking at the dependencies in reverse order
163 ## now, we need to unshift them into another array to keep
164 ## the correct order.
165 unshift(@lines, "$pre$dep$post$crlf") if (defined $relative);
167 ## We've now seen this dependency and all of the
168 ## projects upon which this one depends.
170 foreach my $key (keys %{$self->{'seen_deps'}->{$dep}}) {
176 ## Add the dependency lines to the project file
185 ## We will always rewrite the project file (with or without
187 if (open($fh, ">$outfile")) {
188 foreach my $line (@read) {
195 ## The dependencies need to go into the .wrproject too, so transform
196 ## the name and the pre and post values.
197 $outfile = $outdir . '/.wrproject';
198 $pre = ' <subproject project="/';