1 package MakeWorkspaceBase
;
3 # ************************************************************
4 # Description : A Make Workspace base module
5 # Author : Chad Elliott
6 # Create Date : 11/21/2006
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
17 @ISA = qw(MakePropertyBase);
19 # ************************************************************
21 # ************************************************************
24 return $_[0]->{'make_targets'};
27 sub workspace_file_prefix
{
33 sub workspace_file_extension
{
39 sub supports_make_coexistence
{
40 return ($_[0]->workspace_file_extension() ne '');
44 sub workspace_file_name
{
46 return $self->get_modified_workspace_name(
47 $self->workspace_file_prefix(),
48 $self->make_coexistence() ?
49 $self->workspace_file_extension() : '');
53 sub workspace_per_project
{
59 sub workspace_preamble
{
60 my($self, $fh, $crlf, $name, $id) = @_;
62 ## Optionally print the workspace comment
63 $self->print_workspace_comment($fh,
64 '# -*-Makefile-*-', $crlf,
65 '#----------------------------------------------------------------------------', $crlf,
70 '# This file was generated by MPC. Any changes made directly to', $crlf,
71 '# this file will be lost the next time it is generated.', $crlf,
73 '# MPC Command:', $crlf,
74 '# ', $self->create_command_line_string($0, @ARGV), $crlf,
76 '#----------------------------------------------------------------------------', $crlf,
80 sub write_top_level_rule
{
81 my($self, $fh, $crlf, $list, $remain, $trans, $maxline, $target, $suffix) = @_;
83 if (defined $maxline) {
84 my $line = $target . ':';
85 foreach my $project (@
$list) {
86 $line .= " $$trans{$project}$suffix";
88 if (length($line) < $maxline) {
89 print $fh $crlf, $line;
91 elsif (length($suffix) > 0) {
92 $$remain .= ' ' . $target;
95 $$remain = $target . ' ' . $$remain;
99 print $fh $crlf . $target . ':';
100 foreach my $project (@
$list) {
101 print $fh " $$trans{$project}$suffix";
106 sub write_named_targets
{
107 my($self, $fh, $crlf, $targnum, $list, $remain, $targpre, $allpre, $trans, $phony, $andsym, $maxline) = @_;
109 ## Save the targets for later
110 $self->{'make_targets'} = $remain;
112 ## Print out the "all" target
113 $self->write_top_level_rule($fh, $crlf, $list, \
$remain,
114 $trans, $maxline, 'all', '');
117 ## Print out the "depend" target
118 $self->write_top_level_rule($fh, $crlf, $list, \
$remain,
119 $trans, $maxline, 'depend', '-depend');
121 ## Print out all other targets here
122 print $fh "$crlf$crlf$remain:$crlf";
123 $self->write_project_targets($fh, $crlf,
124 $targpre . '$(@)', $list, $andsym);
126 ## Print out each target separately
127 foreach my $project (@
$list) {
128 print $fh ($phony ?
"$crlf.PHONY: $$trans{$project}" : ''),
129 $crlf, $$trans{$project}, ':';
130 if (defined $$targnum{$project}) {
131 foreach my $number (@
{$$targnum{$project}}) {
132 print $fh " $$trans{$$list[$number]}";
136 $self->write_project_targets($fh, $crlf,
137 $targpre . $allpre . 'all',
138 [ $project ], $andsym);
139 print $fh ($phony ?
"$crlf.PHONY: $$trans{$project}-depend" : ''),
140 $crlf, $$trans{$project}, '-depend:', $crlf;
141 $self->write_project_targets($fh, $crlf,
142 $targpre . $allpre . 'depend',
143 [ $project ], $andsym);
146 ## Print out the project_name_list target
147 print $fh $crlf, "project_name_list:$crlf";
148 foreach my $project (sort @
$list) {
149 print $fh "\t\@echo $$trans{$project}$crlf";
155 my($self, $wsfh, $creator, $toplevel) = @_;
157 if ($toplevel && $self->{'for_eclipse'}) {
158 my $crlf = $self->crlf();
159 my $outdir = $self->get_outdir();
160 my $fh = new FileHandle
();
161 my $outfile = "$outdir/.cdtproject";
162 my $pjt = $self->get_eclipse_cdtproject();
164 if (open($fh, ">$outfile")) {
165 ## We want to set the make command to nmake for the nmake project
166 ## type. As far as stopping on an error, I don't remember why this
167 ## is true only for Borland make.
168 my $cmd = ("$self" =~ /^nmake/i ?
'nmake' : 'make');
169 my $stop = ("$self" =~ /^bmake/i ?
'true' : 'false');
171 foreach my $target ('all',
172 grep(/^[\w\-]+$/, split(/\s+/, $self->targets()))) {
173 print $fh ' <target name="', $target, '" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">', $crlf,
174 ' <buildCommand>', $cmd, '</buildCommand>', $crlf,
175 ' <buildArguments></buildArguments>', $crlf,
176 ' <buildTarget>', $target, '</buildTarget> ', $crlf,
177 ' <stopOnError>', $stop, '</stopOnError>', $crlf,
178 ' <useDefaultCommand>false</useDefaultCommand>', $crlf,
185 $self->warning("Unable to create $outfile");
188 ## Create the eclipse project which is unchanging except for the name
189 ## of the starting makefile.
190 $pjt = $self->get_eclipse_project();
191 $outfile = "$outdir/.project";
192 if (open($fh, ">$outfile")) {
193 print $fh $$pjt[0], $self->get_workspace_name(), $$pjt[1];
197 $self->warning("Unable to create $outfile");
203 sub get_eclipse_cdtproject
{
205 if (!defined $self->{'eclipse_cdtproject'}) {
206 $self->{'eclipse_cdtproject'} = [
207 '<?xml version="1.0" encoding="UTF-8"?>
208 <?eclipse-cdt version="2.0"?>
209 <cdtproject id="org.eclipse.cdt.make.core.make">
210 <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
211 <extension id="org.eclipse.cdt.core.nullindexer" point="org.eclipse.cdt.core.CIndexer"/>
213 <item id="scannerConfiguration">
214 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
215 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
216 <buildOutputProvider>
217 <openAction enabled="true" filePath=""/>
218 <parser enabled="true"/>
219 </buildOutputProvider>
221 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
222 <buildOutputProvider>
223 <openAction enabled="false" filePath=""/>
224 <parser enabled="false"/>
225 </buildOutputProvider>
226 <scannerInfoProvider id="specsFile">
227 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
228 <parser enabled="false"/>
229 </scannerInfoProvider>
231 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
232 <buildOutputProvider>
233 <openAction enabled="false" filePath=""/>
234 <parser enabled="false"/>
235 </buildOutputProvider>
236 <scannerInfoProvider id="specsFile">
237 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
238 <parser enabled="false"/>
239 </scannerInfoProvider>
241 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
242 <buildOutputProvider>
243 <openAction enabled="false" filePath=""/>
244 <parser enabled="false"/>
245 </buildOutputProvider>
246 <scannerInfoProvider id="makefileGenerator">
247 <runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
248 <parser enabled="false"/>
249 </scannerInfoProvider>
252 <item id="org.eclipse.cdt.core.pathentry">
253 <pathentry kind="src" path=""/>
254 <pathentry kind="out" path=""/>
255 <pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
257 <item id="org.eclipse.cdt.make.core.buildtargets">
267 return $self->{'eclipse_cdtproject'};
271 sub get_eclipse_project
{
273 if (!defined $self->{'eclipse_project'}) {
274 $self->{'eclipse_project'} = [
275 '<?xml version="1.0" encoding="UTF-8"?>
284 <name>org.eclipse.cdt.make.core.makeBuilder</name>
285 <triggers>clean,full,incremental,</triggers>
288 <key>org.eclipse.cdt.make.core.build.arguments</key>
292 <key>org.eclipse.cdt.core.errorOutputParser</key>
293 <value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
296 <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
300 <key>org.eclipse.cdt.make.core.environment</key>
304 <key>org.eclipse.cdt.make.core.enableFullBuild</key>
308 <key>org.eclipse.cdt.make.core.build.target.inc</key>
312 <key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
316 <key>org.eclipse.cdt.make.core.build.target.clean</key>
320 <key>org.eclipse.cdt.make.core.build.command</key>
324 <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
328 <key>org.eclipse.cdt.make.core.append_environment</key>
332 <key>org.eclipse.cdt.make.core.build.target.full</key>
333 <value>clean all</value>
336 <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
340 <key>org.eclipse.cdt.make.core.build.target.auto</key>
344 <key>org.eclipse.cdt.make.core.stopOnError</key>
350 <name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
356 <nature>org.eclipse.cdt.core.cnature</nature>
357 <nature>org.eclipse.cdt.make.core.makeNature</nature>
358 <nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
359 <nature>org.eclipse.cdt.core.ccnature</nature>
361 </projectDescription>
364 return $self->{'eclipse_project'};