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';
40 sub get_project_prefix
{
46 my $crlf = $self->crlf();
48 ## Optionally print the workspace comment
49 $self->print_workspace_comment($fh,
50 '#----------------------------------------------------------------------------', $crlf,
51 '# WindRiver Workbench generator', $crlf,
53 '# This file was generated by MPC. Any changes made directly to', $crlf,
54 '# this file will be lost the next time it is generated.', $crlf,
55 '# This file should be placed in the .metadata/.plugins/org.eclipse.core.runtime/.settings directory', $crlf,
57 '# MPC Command:', $crlf,
58 "# ", $self->create_command_line_string($0, @ARGV), $crlf,
59 '#----------------------------------------------------------------------------', $crlf);
61 ## Unchanging initial settings
62 print $fh 'version=1', $crlf,
63 'eclipse.preferences.version=1', $crlf,
64 'description.defaultbuildorder=false', $crlf;
69 my $pjs = $self->get_project_info();
70 my @list = $self->sort_dependencies($self->get_projects(), 0);
71 my $pre = $self->get_project_prefix();
73 ## Print out the target
74 print $fh 'description.buildorder=';
75 foreach my $project (@list) {
76 print $fh $pre, $$pjs{$project}->[ProjectCreator
::PROJECT_NAME
], '/';
78 print $fh $self->crlf();
82 my($self, $fh, $creator) = @_;
83 my $crlf = $self->crlf();
85 ## Clear out the seen dependency hash for use within the
86 ## add_dependencies method.
87 $self->{'seen_deps'} = {};
89 ## Print out the project dependencies
90 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
91 print $fh "$project$crlf";
92 $self->add_dependencies($creator, $project);
96 sub get_additional_output
{
97 ## Create the accompanying list file. It always goes in the same
98 ## directory as the first workspace output file. See
99 ## WorkspaceCreator.pm for a description of the array elements.
100 return [[undef, 'wb26projects.lst', \
&list_file_body
]];
105 my $crlf = $self->crlf();
107 ## Optionally print the workspace comment
108 $self->print_workspace_comment($fh,
109 '#----------------------------------------------------------------------------', $crlf,
110 '# WindRiver Workbench generator', $crlf,
112 '# This file was generated by MPC. Any changes made directly to', $crlf,
113 '# this file will be lost the next time it is generated.', $crlf,
114 '# MPC Command:', $crlf,
115 "# ", $self->create_command_line_string($0, @ARGV), $crlf,
116 '#----------------------------------------------------------------------------', $crlf);
118 ## Print out each target separately
119 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
120 print $fh $self->mpc_dirname($project), '/.project', $crlf;
124 sub add_dependencies
{
125 my($self, $creator, $proj) = @_;
126 my $outdir = $self->mpc_dirname($proj);
127 my $into = $self->get_outdir();
128 $outdir = "$into/$outdir" if $into ne '.';
129 my $proj_pre = $self->get_project_prefix();
131 ## These values will be changed after the first time through the for
133 my $pre = "\t\t" . '<project>';
134 my $post = '</project>';
135 my $outfile = $outdir . '/.project';
137 ## Go through twice to edit both the .project and .wrproject files
138 for(my $i = 0; $i < 2; $i++) {
139 my $fh = new FileHandle
();
140 if (open($fh, $outfile)) {
141 ## Get the dependencies and store them based on the directory of
142 ## the project file. We will check them later.
143 my $deps = $self->get_validated_ordering($proj);
144 my $key = $self->mpc_basename($self->mpc_dirname($proj));
145 $self->{'seen_deps'}->{$key} = {};
146 foreach my $dep (@
$deps) {
147 $self->{'seen_deps'}->{$key}->{$dep} = 1;
151 my $cwd = $self->getcwd();
153 ## This is a comment found in wb26.mpd and wb26wrproject.mpd if
154 ## the project is an executable, contains the 'after' keyword
155 ## setting, and the 'enable_subprojects' template variable.
156 if (/MPC\s+ADD\s+DEPENDENCIES/) {
157 my $crlf = $self->crlf();
160 foreach my $dep (reverse @
$deps) {
161 ## If we've seen this dependency, we don't need to add it
162 ## again. The build tool will handle it correctly.
164 my $relative = $self->get_relative_dep_file($creator,
166 ## Since we're looking at the dependencies in reverse order
167 ## now, we need to unshift them into another array to keep
168 ## the correct order.
169 if (defined $relative) {
170 unshift(@lines, "$pre$proj_pre$dep$post$crlf");
173 ## We've now seen this dependency and all of the
174 ## projects upon which this one depends.
176 foreach my $key (keys %{$self->{'seen_deps'}->{$dep}}) {
182 ## Add the dependency lines to the project file
191 ## We will always rewrite the project file (with or without
193 if (open($fh, ">$outfile")) {
194 foreach my $line (@read) {
201 ## The dependencies need to go into the .wrproject too, so transform
202 ## the name and the pre and post values.
203 $outfile = $outdir . '/.wrproject';
204 $pre = ' <subproject project="/';