21
21
import org .eclipse .cdt .managedbuilder .core .ITool ;
22
22
import org .eclipse .cdt .managedbuilder .core .ManagedBuildManager ;
23
23
import org .eclipse .cdt .managedbuilder .internal .macros .BuildMacroProvider ;
24
- import org .eclipse .cdt .managedbuilder .internal .macros .FileContextData ;
25
24
import org .eclipse .cdt .managedbuilder .macros .BuildMacroException ;
26
25
import org .eclipse .cdt .managedbuilder .macros .IBuildMacroProvider ;
27
26
import org .eclipse .cdt .managedbuilder .makegen .IManagedDependencyCalculator ;
@@ -249,7 +248,7 @@ private String enumPrerequisites(IFile buildFolder) {
249
248
}
250
249
251
250
public StringBuffer getRule (IProject project , IFile niceBuildFolder , IConfiguration config ) {
252
-
251
+ ICConfigurationDescription confDesc = ManagedBuildManager . getDescriptionForConfiguration ( config );
253
252
String cmd = myTool .getToolCommand ();
254
253
//For now assume 1 target with 1 or more prerequisites
255
254
// if there is more than 1 prerequisite we take the flags of the first prerequisite only
@@ -283,9 +282,8 @@ public StringBuffer getRule(IProject project, IFile niceBuildFolder, IConfigurat
283
282
boolean resourceNameRequiresExplicitRule = containsSpecialCharacters (sourceLocation .getLocation ().toOSString ());
284
283
needExplicitRuleForFile = resourceNameRequiresExplicitRule
285
284
|| BuildMacroProvider .getReferencedExplitFileMacros (myTool ).length > 0
286
- || BuildMacroProvider .getReferencedExplitFileMacros (cmd , IBuildMacroProvider .CONTEXT_FILE ,
287
- new FileContextData (sourceLocation .getFullPath (), outputLocation .getFullPath (), null ,
288
- myTool )).length > 0 ;
285
+ || BuildMacroProvider .getReferencedExplitFileMacros (cmd , IBuildMacroProvider .CONTEXT_CONFIGURATION ,
286
+ confDesc ).length > 0 ;
289
287
290
288
String outflag = myTool .getOutputFlag ();
291
289
String buildCmd = cmd + WHITESPACE + flags .toString ().trim () + WHITESPACE + outflag + WHITESPACE
@@ -304,19 +302,17 @@ public StringBuffer getRule(IProject project, IFile niceBuildFolder, IConfigurat
304
302
IBuildMacroProvider provider = ManagedBuildManager .getBuildMacroProvider ();
305
303
if (!needExplicitRuleForFile ) {
306
304
resolvedCommand = provider .resolveValueToMakefileFormat (buildCmd , EMPTY_STRING , WHITESPACE ,
307
- IBuildMacroProvider .CONTEXT_FILE ,
308
- new FileContextData (sourceLocation .getFullPath (), outputLocation .getFullPath (), null , myTool ));
305
+ IBuildMacroProvider .CONTEXT_CONFIGURATION , confDesc );
309
306
} else {
310
307
// if we need an explicit rule then don't use any builder
311
308
// variables, resolve everything to explicit strings
312
309
resolvedCommand = provider .resolveValue (buildCmd , EMPTY_STRING , WHITESPACE ,
313
- IBuildMacroProvider .CONTEXT_FILE ,
314
- new FileContextData (sourceLocation .getFullPath (), outputLocation .getFullPath (), null , myTool ));
310
+ IBuildMacroProvider .CONTEXT_CONFIGURATION , confDesc );
315
311
}
316
- if (!resolvedCommand .isBlank ())
312
+ if (resolvedCommand != null && !resolvedCommand .isBlank ())
317
313
buildCmd = resolvedCommand .trim ();
318
314
} catch (BuildMacroException e ) {
319
- /* JABA is not going to write this code */
315
+ //Continue using the default buildCmd value
320
316
}
321
317
322
318
StringBuffer buffer = new StringBuffer ();
@@ -328,7 +324,7 @@ public StringBuffer getRule(IProject project, IFile niceBuildFolder, IConfigurat
328
324
// JABA add sketch.prebuild and postbouild if needed
329
325
//TOFIX this should not be here
330
326
if ("sloeber.ino" .equals (fileName )) { //$NON-NLS-1$
331
- ICConfigurationDescription confDesc = ManagedBuildManager . getDescriptionForConfiguration ( config );
327
+
332
328
String sketchPrebuild = io .sloeber .core .common .Common .getBuildEnvironmentVariable (confDesc ,
333
329
"sloeber.sketch.prebuild" , new String (), true ); //$NON-NLS-1$
334
330
String sketchPostBuild = io .sloeber .core .common .Common .getBuildEnvironmentVariable (confDesc ,
@@ -386,21 +382,20 @@ private Set<String> getBuildFlags(IFile buildFolder, IConfiguration config, IFil
386
382
private String expandCommandLinePattern (IConfiguration config , String sourceExtension , Set <String > flags ,
387
383
String outputFlag , String outputName , Set <String > inputResources , IFile inputLocation ,
388
384
IFile outputLocation ) {
385
+ ICConfigurationDescription confDesc = ManagedBuildManager .getDescriptionForConfiguration (config );
389
386
String cmd = myTool .getToolCommand ();
390
387
// try to resolve the build macros in the tool command
391
388
try {
392
389
String resolvedCommand = null ;
393
390
if ((inputLocation != null && inputLocation .toString ().indexOf (WHITESPACE ) != -1 )
394
391
|| (outputLocation != null && outputLocation .toString ().indexOf (WHITESPACE ) != -1 )) {
395
392
resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValue (cmd , EMPTY_STRING ,
396
- WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
397
- new FileContextData (inputLocation .getFullPath (), outputLocation .getFullPath (), null , myTool ));
393
+ WHITESPACE , IBuildMacroProvider .CONTEXT_CONFIGURATION , confDesc );
398
394
} else {
399
395
resolvedCommand = ManagedBuildManager .getBuildMacroProvider ().resolveValueToMakefileFormat (cmd ,
400
- EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_FILE ,
401
- new FileContextData (inputLocation .getFullPath (), outputLocation .getFullPath (), null , myTool ));
396
+ EMPTY_STRING , WHITESPACE , IBuildMacroProvider .CONTEXT_CONFIGURATION , confDesc );
402
397
}
403
- if ((resolvedCommand = resolvedCommand .trim ()).length () > 0 )
398
+ if (resolvedCommand != null && (resolvedCommand = resolvedCommand .trim ()).length () > 0 )
404
399
cmd = resolvedCommand ;
405
400
} catch (BuildMacroException e ) {
406
401
/* JABA is not going to write this code */
@@ -461,27 +456,29 @@ public void addPrerequisites(IInputType inputType, Set<IFile> files) {
461
456
}
462
457
463
458
/**
464
- * A simple rule is a rule that takes exactly 1 input type containing exactly
465
- * one file
459
+ * A simple rule is a rule that takes exactly 1 input type
466
460
* and exactly 1 output type containing exactly 1 file
467
461
*
468
462
* @return true if this rule is a simple rule
469
463
* otherwise false
470
464
*/
471
465
472
466
public boolean isSimpleRule () {
473
- int counter = 0 ;
474
- for (Set <IFile > files : myTargets .values ()) {
475
- if ((++counter > 1 ) || (files .size () != 1 )) {
476
- return false ;
477
- }
478
- }
479
- counter = 0 ;
480
- for (Set <IFile > files : myPrerequisites .values ()) {
481
- if ((++counter > 1 ) || (files .size () != 1 )) {
482
- return false ;
483
- }
467
+ if ((myTargets .size () != 1 ) || (myTargets .size () != 1 )) {
468
+ return false ;
484
469
}
470
+ // int counter = 0;
471
+ // for (Set<IFile> files : myTargets.values()) {
472
+ // if ((++counter > 1) || (files.size() != 1)) {
473
+ // return false;
474
+ // }
475
+ // }
476
+ // counter = 0;
477
+ // for (Set<IFile> files : myPrerequisites.values()) {
478
+ // if ((++counter > 1)) {
479
+ // return false;
480
+ // }
481
+ // }
485
482
return true ;
486
483
487
484
}
0 commit comments