1
1
package it .baeyens .arduino .toolchain ;
2
2
3
- import it .baeyens .arduino .common .ArduinoConst ;
4
- import it .baeyens .arduino .common .Common ;
5
-
6
3
import java .io .ByteArrayInputStream ;
7
4
import java .io .IOException ;
8
5
import java .io .InputStream ;
85
82
import org .eclipse .core .runtime .Status ;
86
83
import org .eclipse .core .runtime .SubProgressMonitor ;
87
84
85
+ import it .baeyens .arduino .common .ArduinoConst ;
86
+ import it .baeyens .arduino .common .Common ;
87
+
88
88
/**
89
89
* This is a specialized makefile generator that takes advantage of the extensions present in Gnu Make.
90
90
*
@@ -251,9 +251,9 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
251
251
if (rcInfo instanceof IFolderInfo ) {
252
252
String ext = resource .getFileExtension ();
253
253
if (((IFolderInfo ) rcInfo ).buildsFileType (ext ) &&
254
- // If this file resource is a generated resource, then
255
- // it is uninteresting
256
- !generator .isGeneratedResource (resource )) {
254
+ // If this file resource is a generated resource, then
255
+ // it is uninteresting
256
+ !generator .isGeneratedResource (resource )) {
257
257
willBuild = true ;
258
258
}
259
259
} else {
@@ -284,11 +284,11 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
284
284
285
285
// String constants for makefile contents and messages
286
286
private static final String COMMENT = "MakefileGenerator.comment" ; //$NON-NLS-1$
287
- //private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
288
- //private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
289
- //private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
287
+ // private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
288
+ // private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
289
+ // private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
290
290
291
- //private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
291
+ // private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
292
292
private static final String HEADER = COMMENT + ".header" ; //$NON-NLS-1$
293
293
294
294
protected static final String MESSAGE_FINISH_BUILD = ManagedMakeMessages .getResourceString ("MakefileGenerator.message.finish.build" ); //$NON-NLS-1$
@@ -297,7 +297,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
297
297
protected static final String MESSAGE_START_FILE = ManagedMakeMessages .getResourceString ("MakefileGenerator.message.start.file" ); //$NON-NLS-1$
298
298
protected static final String MESSAGE_START_DEPENDENCY = ManagedMakeMessages .getResourceString ("MakefileGenerator.message.start.dependency" ); //$NON-NLS-1$
299
299
protected static final String MESSAGE_NO_TARGET_TOOL = ManagedMakeMessages .getResourceString ("MakefileGenerator.message.no.target" ); //$NON-NLS-1$
300
- //private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
300
+ // private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
301
301
private static final String MOD_LIST = COMMENT + ".module.list" ; //$NON-NLS-1$
302
302
private static final String MOD_VARS = COMMENT + ".module.variables" ; //$NON-NLS-1$
303
303
private static final String MOD_RULES = COMMENT + ".build.rule" ; //$NON-NLS-1$
@@ -775,8 +775,8 @@ public MultiStatus generateMakefiles(IResourceDelta delta) throws CoreException
775
775
// TODO: fix error message
776
776
for (IResource res : getInvalidDirList ()) {
777
777
IContainer subDir = (IContainer ) res ;
778
- status .add (new Status (IStatus .WARNING , ManagedBuilderCorePlugin .getUniqueIdentifier (), SPACES_IN_PATH , subDir . getFullPath ()
779
- .toString (), null ));
778
+ status .add (new Status (IStatus .WARNING , ManagedBuilderCorePlugin .getUniqueIdentifier (), SPACES_IN_PATH ,
779
+ subDir . getFullPath () .toString (), null ));
780
780
}
781
781
} else {
782
782
status = new MultiStatus (ManagedBuilderCorePlugin .getUniqueIdentifier (), IStatus .OK , new String (), null );
@@ -1220,12 +1220,12 @@ protected StringBuffer addTopHeader() {
1220
1220
}
1221
1221
1222
1222
/**
1223
- */
1223
+ */
1224
1224
private StringBuffer addMacros () {
1225
1225
StringBuffer buffer = new StringBuffer ();
1226
1226
1227
1227
// Add the ROOT macro
1228
- //buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$
1228
+ // buffer.append("ROOT := .." + NEWLINE); //$NON-NLS-1$
1229
1229
// buffer.append(NEWLINE);
1230
1230
1231
1231
// include makefile.init supplementary makefile
@@ -1236,8 +1236,8 @@ private StringBuffer addMacros() {
1236
1236
buffer .append ("RM := " ); //$NON-NLS-1$
1237
1237
1238
1238
// support macros in the clean command
1239
- String cleanCommand = "rm -rf " ; // config.getCleanCommand(); Modded by
1240
- // JABA
1239
+ String cleanCommand = "rm -f " ; // config.getCleanCommand(); Modded by
1240
+ // JABA
1241
1241
1242
1242
// try {
1243
1243
// cleanCommand =
@@ -1274,7 +1274,7 @@ private StringBuffer addMacros() {
1274
1274
}
1275
1275
1276
1276
// Change the include of the "root" (our sketch) folder to be before libraries and other files
1277
- //buffer.append("-include subdir.mk" + NEWLINE); //$NON-NLS-1$
1277
+ // buffer.append("-include subdir.mk" + NEWLINE); //$NON-NLS-1$
1278
1278
1279
1279
buffer .append ("-include objects.mk" + NEWLINE + NEWLINE ); //$NON-NLS-1$
1280
1280
@@ -1474,8 +1474,8 @@ private StringBuffer addTargets(List<String> outputVarsAdditionsList, boolean re
1474
1474
dependency = escapeWhitespaces (dependency );
1475
1475
managedProjectOutputs .add (dependency );
1476
1476
// }
1477
- buffer .append (TAB
1478
- + "-cd" + WHITESPACE + escapeWhitespaces ( buildDir ) + WHITESPACE + LOGICAL_AND + WHITESPACE + "$(MAKE) " + depTargets + NEWLINE ); //$NON-NLS-1$ //$NON-NLS-2$
1477
+ buffer .append (TAB + "-cd" + WHITESPACE + escapeWhitespaces ( buildDir ) + WHITESPACE + LOGICAL_AND + WHITESPACE + "$(MAKE) " + depTargets //$NON-NLS-1$ //$NON-NLS-2$
1478
+ + NEWLINE );
1479
1479
}
1480
1480
// }
1481
1481
buffer .append (NEWLINE );
@@ -1601,7 +1601,7 @@ private StringBuffer addTargetsRules(ITool targetTool, List<String> outputVarsAd
1601
1601
buffer .append (TAB + "-$(RM)" + WHITESPACE ); //$NON-NLS-1$
1602
1602
for (Entry <String , List <IPath >> entry : buildOutVars .entrySet ()) {
1603
1603
String macroName = entry .getKey ();
1604
- buffer .append ("$(" + macroName + ")" ); //$NON-NLS-1$ //$NON-NLS-2$
1604
+ buffer .append ("$(" + macroName + ")" ); //$NON-NLS-1$ //$NON-NLS-2$
1605
1605
}
1606
1606
String outputPrefix = EMPTY_STRING ;
1607
1607
if (targetTool != null ) {
@@ -1612,7 +1612,7 @@ private StringBuffer addTargetsRules(ITool targetTool, List<String> outputVarsAd
1612
1612
completeBuildTargetName = completeBuildTargetName + DOT + buildTargetExt ;
1613
1613
}
1614
1614
if (completeBuildTargetName .contains (" " )) { //$NON-NLS-1$
1615
- buffer .append (WHITESPACE + "\" " + completeBuildTargetName + "\" " ); //$NON-NLS-1$ //$NON-NLS-2$
1615
+ buffer .append (WHITESPACE + "\" " + completeBuildTargetName + "\" " ); //$NON-NLS-1$ //$NON-NLS-2$
1616
1616
} else {
1617
1617
buffer .append (WHITESPACE + completeBuildTargetName );
1618
1618
}
@@ -1721,10 +1721,8 @@ protected boolean addRuleForTool(ITool tool, StringBuffer buffer, boolean bTarge
1721
1721
String command = tool .getToolCommand ();
1722
1722
try {
1723
1723
// try to resolve the build macros in the tool command
1724
- String resolvedCommand = ManagedBuildManager
1725
- .getBuildMacroProvider ()
1726
- .resolveValueToMakefileFormat (command , EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
1727
- new FileContextData (null , null , null , tool )).replaceFirst (" -w " , " " );
1724
+ String resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValueToMakefileFormat (command , EMPTY_STRING , WHITESPACE ,
1725
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (null , null , null , tool )).replaceFirst (" -w " , " " );
1728
1726
if ((resolvedCommand = resolvedCommand .trim ()).length () > 0 )
1729
1727
command = resolvedCommand ;
1730
1728
@@ -1754,10 +1752,8 @@ protected boolean addRuleForTool(ITool tool, StringBuffer buffer, boolean bTarge
1754
1752
// resolve any remaining macros in the command after it has been
1755
1753
// generated
1756
1754
try {
1757
- String resolvedCommand = ManagedBuildManager
1758
- .getBuildMacroProvider ()
1759
- .resolveValueToMakefileFormat (buildCmd , EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
1760
- new FileContextData (null , null , null , tool )).replaceFirst (" -w " , " " );
1755
+ String resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValueToMakefileFormat (buildCmd , EMPTY_STRING , WHITESPACE ,
1756
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (null , null , null , tool )).replaceFirst (" -w " , " " );
1761
1757
if ((resolvedCommand = resolvedCommand .trim ()).length () > 0 )
1762
1758
buildCmd = resolvedCommand ;
1763
1759
@@ -1963,8 +1959,8 @@ private StringBuffer addSubdirectories() {
1963
1959
1964
1960
// Get all the module names
1965
1961
for (IResource container : getSubdirList ()) {
1966
- updateMonitor (ManagedMakeMessages
1967
- .getFormattedString ("MakefileGenerator.message.adding.source.folder" , container .getFullPath ().toString ())); //$NON-NLS-1$
1962
+ updateMonitor (
1963
+ ManagedMakeMessages .getFormattedString ("MakefileGenerator.message.adding.source.folder" , container .getFullPath ().toString ())); //$NON-NLS-1$
1968
1964
// Check the special case where the module is the project root
1969
1965
if (container .getFullPath () == project .getFullPath ()) {
1970
1966
buffer .append (DOT + WHITESPACE + LINEBREAK );
@@ -2042,8 +2038,8 @@ protected StringBuffer addSources(IContainer module) throws CoreException {
2042
2038
rcInfo = config .getResourceInfo (rcProjRelPath , false );
2043
2039
// if( (rcInfo.isExcluded()) )
2044
2040
// continue;
2045
- addFragmentMakefileEntriesForSource (buildVarToRuleStringMap , ruleBuffer , folder , relativePath , resource ,
2046
- getPathForResource ( resource ), rcInfo , null , false );
2041
+ addFragmentMakefileEntriesForSource (buildVarToRuleStringMap , ruleBuffer , folder , relativePath , resource , getPathForResource ( resource ),
2042
+ rcInfo , null , false );
2047
2043
}
2048
2044
}
2049
2045
@@ -2073,9 +2069,8 @@ protected StringBuffer addSources(IContainer module) throws CoreException {
2073
2069
*
2074
2070
* @param generatedSource if <code>true</code>, this file was generated by another tool in the tool-chain
2075
2071
*/
2076
- protected void addFragmentMakefileEntriesForSource (LinkedHashMap <String , String > buildVarToRuleStringMap , StringBuffer ruleBuffer ,
2077
- IFolder folder , String relativePath , IResource resource , IPath sourceLocation , IResourceInfo rcInfo , String varName ,
2078
- boolean generatedSource ) {
2072
+ protected void addFragmentMakefileEntriesForSource (LinkedHashMap <String , String > buildVarToRuleStringMap , StringBuffer ruleBuffer , IFolder folder ,
2073
+ String relativePath , IResource resource , IPath sourceLocation , IResourceInfo rcInfo , String varName , boolean generatedSource ) {
2079
2074
2080
2075
// Determine which tool, if any, builds files with this extension
2081
2076
String ext = sourceLocation .getFileExtension ();
@@ -2320,15 +2315,19 @@ private IManagedCommandLineInfo generateToolCommandLineInfo(ITool tool, String s
2320
2315
if ((inputLocation != null && inputLocation .toString ().indexOf (" " ) != -1 ) || //$NON-NLS-1$
2321
2316
(outputLocation != null && outputLocation .toString ().indexOf (" " ) != -1 )) //$NON-NLS-1$
2322
2317
{
2323
- resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValue (cmd , "" , //$NON-NLS-1$
2324
- " " , //$NON-NLS-1$
2325
- IBuildMacroProvider .CONTEXT_FILE , new FileContextData (inputLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2318
+ resolvedCommand = ManagedBuildManager .getBuildMacroProvider ()
2319
+ .resolveValue (cmd , "" , //$NON-NLS-1$
2320
+ " " , //$NON-NLS-1$
2321
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (inputLocation , outputLocation , null , tool ))
2322
+ .replaceFirst (" -w " , " " );
2326
2323
}
2327
2324
2328
2325
else {
2329
- resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValueToMakefileFormat (cmd , "" , //$NON-NLS-1$
2330
- " " , //$NON-NLS-1$
2331
- IBuildMacroProvider .CONTEXT_FILE , new FileContextData (inputLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2326
+ resolvedCommand = ManagedBuildManager .getBuildMacroProvider ()
2327
+ .resolveValueToMakefileFormat (cmd , "" , //$NON-NLS-1$
2328
+ " " , //$NON-NLS-1$
2329
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (inputLocation , outputLocation , null , tool ))
2330
+ .replaceFirst (" -w " , " " );
2332
2331
}
2333
2332
if ((resolvedCommand = resolvedCommand .trim ()).length () > 0 )
2334
2333
cmd = resolvedCommand ;
@@ -2351,18 +2350,18 @@ private IManagedCommandLineInfo generateToolCommandLineInfo(ITool tool, String s
2351
2350
* @echo Building file: $<
2352
2351
* @echo Invoking tool xxx
2353
2352
* @echo <tool> <flags> <output_flag><output_prefix>$@ $<
2354
- * @<tool> <flags> <output_flag><output_prefix>$@ $< && \ echo -n $(@:%.o=%.d) ' <relative_path>/' >> $(@:%.o=%.d) && \ <tool> -P -MM -MG <flags>
2355
- * $< >> $(@:%.o=%.d)
2353
+ * @<tool> <flags> <output_flag><output_prefix>$@ $< && \ echo -n $(@:%.o=%.d) ' <relative_path>/' >> $(@:%.o=%.d) && \ <tool> -P -MM -MG
2354
+ * <flags> $< >> $(@:%.o=%.d)
2356
2355
* @echo Finished building: $<
2357
2356
* @echo ' '
2358
2357
*
2359
2358
* Note that the macros all come from the build model and are resolved to a real command before writing to the module makefile, so a real
2360
2359
* command might look something like: source1/%.o: ../source1/%.cpp
2361
2360
* @echo Building file: $<
2362
2361
* @echo Invoking tool xxx
2363
- * @echo g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@ $<
2364
- * @g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@ $< && \ echo -n $(@:%.o=%.d) ' source1/' >> $(@:%.o=%.d) && \ g++ -P -MM
2365
- * -MG -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers $< >> $(@:%.o=%.d)
2362
+ * @echo g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@ $< @g++ -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers -o$@
2363
+ * $< && \ echo -n $(@:%.o=%.d) ' source1/' >> $(@:%.o=%.d) && \ g++ -P -MM -MG -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers $<
2364
+ * >> $(@:%.o=%.d)
2366
2365
* @echo Finished building: $<
2367
2366
* @echo ' '
2368
2367
*
@@ -2518,29 +2517,24 @@ protected void addRuleForSource(String relativePath, StringBuffer buffer, IResou
2518
2517
boolean resourceNameRequiresExplicitRule = (resource .isLinked () && containsSpecialCharacters (sourceLocation .toString ()))
2519
2518
|| (!resource .isLinked () && containsSpecialCharacters (resource .getProjectRelativePath ().toString ()));
2520
2519
2521
- boolean needExplicitRuleForFile = resourceNameRequiresExplicitRule
2522
- || BuildMacroProvider .getReferencedExplitFileMacros (tool ).length > 0
2523
- || BuildMacroProvider .getReferencedExplitFileMacros (tool .getToolCommand (), IBuildMacroProvider .CONTEXT_FILE , new FileContextData (
2524
- sourceLocation , outputLocation , null , tool )).length > 0 ;
2520
+ boolean needExplicitRuleForFile = resourceNameRequiresExplicitRule || BuildMacroProvider .getReferencedExplitFileMacros (tool ).length > 0
2521
+ || BuildMacroProvider .getReferencedExplitFileMacros (tool .getToolCommand (), IBuildMacroProvider .CONTEXT_FILE ,
2522
+ new FileContextData (sourceLocation , outputLocation , null , tool )).length > 0 ;
2525
2523
2526
2524
// Get and resolve the command
2527
2525
String cmd = tool .getToolCommand ();
2528
2526
2529
2527
try {
2530
2528
String resolvedCommand = null ;
2531
2529
if (!needExplicitRuleForFile ) {
2532
- resolvedCommand = ManagedBuildManager
2533
- .getBuildMacroProvider ()
2534
- .resolveValueToMakefileFormat (cmd , EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
2535
- new FileContextData (sourceLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2530
+ resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValueToMakefileFormat (cmd , EMPTY_STRING , WHITESPACE ,
2531
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (sourceLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2536
2532
} else {
2537
2533
// if we need an explicit rule then don't use any builder
2538
2534
// variables, resolve everything
2539
2535
// to explicit strings
2540
- resolvedCommand = ManagedBuildManager
2541
- .getBuildMacroProvider ()
2542
- .resolveValue (cmd , EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
2543
- new FileContextData (sourceLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2536
+ resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValue (cmd , EMPTY_STRING , WHITESPACE ,
2537
+ IBuildMacroProvider .CONTEXT_FILE , new FileContextData (sourceLocation , outputLocation , null , tool )).replaceFirst (" -w " , " " );
2544
2538
}
2545
2539
2546
2540
if ((resolvedCommand = resolvedCommand .trim ()).length () > 0 )
@@ -3327,7 +3321,7 @@ protected void calculateOutputsForSource(ITool tool, String relativePath, IResou
3327
3321
enumeratedSecondaryOutputs .add (resolvePercent (outPath , sourceLocation ));
3328
3322
}
3329
3323
}
3330
- }// MODDED BY JABA ADDED
3324
+ } // MODDED BY JABA ADDED
3331
3325
} else
3332
3326
// 4. If outputNames is specified, use it
3333
3327
if (outputNames != null ) {
0 commit comments