1 package CDT6WorkspaceCreator
;
3 # ************************************************************
4 # Description : Eclipse CDT 6 generator
5 # Author : Chris Cleeland, Object Computing, Inc.
6 # Create Date : 23-Apr-2010
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
15 use CDT6ProjectCreator
;
19 @ISA = qw(WorkspaceCreator);
21 # ************************************************************
23 # ************************************************************
25 sub requires_make_coexistence
{
30 sub supports_make_coexistence
{
35 sub workspace_file_name
{
37 my $wsn = $self->get_workspace_name();
38 return $self->get_modified_workspace_name("cdt_workspace_$wsn", '.txt');
43 my $crlf = $self->crlf();
45 ## Optionally print the workspace comment
46 $self->print_workspace_comment($fh,
47 '#----------------------------------------------------------------------------', $crlf,
48 '# Eclipse CDT ', $self->get_cdt_version(), ' generator', $crlf,
50 '# This file was generated by MPC. Any changes made directly to', $crlf,
51 '# this file will be lost the next time it is generated.', $crlf,
52 '# Listed below are the Eclipse projects created for this MPC workspace.', $crlf,
53 '# These should be imported into an existing Eclipse workspace.', $crlf,
54 '# Each project is listed on a line consisting of the project name and the full', $crlf,
55 '# path to its .project file (space-separated).', $crlf,
56 '# The projects are listed in dependency order.', $crlf,
58 '# MPC Command:', $crlf,
59 '# ', $self->create_command_line_string($0, @ARGV), $crlf,
60 '#----------------------------------------------------------------------------', $crlf);
68 my($self, $fh, $creator) = @_;
69 my $info = $self->get_project_info();
70 my $crlf = $self->crlf();
71 $self->{'seen_deps'} = {};
73 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
74 print $fh $$info{$project}->[ProjectCreator
::PROJECT_NAME
], ' ',
75 $self->abs_path($self->mpc_dirname($project)), '/.project', $crlf;
76 $self->add_dependencies($creator, $project);
80 sub add_dependencies
{
81 my($self, $creator, $proj) = @_;
82 my $outdir = $self->mpc_dirname($proj);
83 my $into = $self->get_outdir();
84 $outdir = "$into/$outdir" if $into ne '.';
86 my $pre = ' <project>';
87 my $post = '</project>';
88 my $outfile = $outdir . '/.project';
90 my $fh = new FileHandle
();
91 if (open($fh, $outfile)) {
92 ## Get the dependencies and store them based on the directory of
93 ## the project file. We will check them later.
94 my $deps = $self->get_validated_ordering($proj);
95 my $key = $self->mpc_basename($self->mpc_dirname($proj));
96 $self->{'seen_deps'}->{$key} = {};
97 foreach my $dep (@
$deps) {
98 $self->{'seen_deps'}->{$key}->{$dep} = 1;
102 my $cwd = $self->getcwd();
104 ## This is a comment found in cdt6project.mpd.
105 if (/MPC\s+ADD\s+DEPENDENCIES/) {
106 my $crlf = $self->crlf();
109 foreach my $dep (reverse @
$deps) {
110 ## If we've seen this dependency, we don't need to add it
111 ## again. The build tool will handle it correctly.
113 my $relative = $self->get_relative_dep_file($creator,
115 ## Since we're looking at the dependencies in reverse order
116 ## now, we need to unshift them into another array to keep
117 ## the correct order.
118 unshift(@lines, "$pre$dep$post$crlf") if (defined $relative);
120 ## We've now seen this dependency and all of the
121 ## projects upon which this one depends.
123 foreach my $key (keys %{$self->{'seen_deps'}->{$dep}}) {
129 ## Add the dependency lines to the project file
138 ## We will always rewrite the project file (with or without dependencies)
139 if (open($fh, ">$outfile")) {
140 foreach my $line (@read) {