Skip to content

Commit 2cd4052

Browse files
author
jantje
committed
#1498 put the codan commands in the sloeber.txt file
1 parent 475e9d4 commit 2cd4052

File tree

3 files changed

+29
-47
lines changed

3 files changed

+29
-47
lines changed

io.sloeber.core/src/io/sloeber/core/api/SloeberProject.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,6 @@ private HashMap<String, String> getEnvVars(String configKey) {
403403
+ makeEnvironmentVar(ENV_KEY_BUILD_GENERIC_PATH) + pathDelimiter + makeEnvironmentVar("PATH")); //$NON-NLS-1$
404404
}
405405

406-
// Set the codeAnalyzer compile commands
407-
allVars.put(CODAN_C_to_O,
408-
"${recipe.c.o.pattern.1} -D__IN_ECLIPSE__=1 ${recipe.c.o.pattern.2} ${recipe.c.o.pattern.3} ${sloeber.extra.compile} ${sloeber.extra.c.compile} ${sloeber.extra.all}"); //$NON-NLS-1$
409-
allVars.put(CODAN_CPP_to_O,
410-
"${recipe.cpp.o.pattern.1} -D__IN_ECLIPSE__=1 -x c++ ${recipe.cpp.o.pattern.2} ${recipe.cpp.o.pattern.3} ${sloeber.extra.compile} ${sloeber.extra.cpp.compile} ${sloeber.extra.all}"); //$NON-NLS-1$
411-
412406
return allVars;
413407
}
414408

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
11
package io.sloeber.core.toolchain;
22

3-
import org.eclipse.cdt.core.CCorePlugin;
4-
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
5-
import org.eclipse.cdt.core.model.CoreModel;
6-
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
7-
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
3+
import static io.sloeber.core.common.Const.*;
4+
85
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
96
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
107

11-
import io.sloeber.core.common.Const;
12-
13-
@SuppressWarnings({"nls","unused"})
14-
public class ArduinoLanguageProvider extends GCCBuiltinSpecsDetector{
15-
16-
17-
18-
@Override
19-
protected String getCompilerCommand(String languageId) {
20-
String ret = new String();
21-
22-
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(currentProject);
23-
if (prjDesc == null)
24-
return ret;
25-
ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
26-
27-
String codanVarName = new String();
28-
if (languageId.equals("org.eclipse.cdt.core.gcc")) {
29-
codanVarName = Const.CODAN_C_to_O;
30-
} else if (languageId.equals("org.eclipse.cdt.core.g++")) {
31-
codanVarName = Const.CODAN_CPP_to_O;
32-
} else {
33-
ManagedBuilderCorePlugin.error(
34-
"Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId());
35-
}
8+
@SuppressWarnings({ "nls", "unused" })
9+
public class ArduinoLanguageProvider extends GCCBuiltinSpecsDetector {
3610

37-
try {
38-
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
39-
ret = envManager.getVariable(codanVarName, confDesc, false).getValue();
40-
} catch (Exception e) {
41-
ret = new String();
42-
}
11+
@Override
12+
protected String getCompilerCommand(String languageId) {
4313

14+
if (languageId.equals("org.eclipse.cdt.core.gcc")) {
15+
return "${" + CODAN_C_to_O + "}";
16+
} else if (languageId.equals("org.eclipse.cdt.core.g++")) {
17+
return "${" + CODAN_CPP_to_O + "}";
18+
} else {
19+
ManagedBuilderCorePlugin.error(
20+
"Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId());
21+
}
4422

45-
return ret;
46-
}
23+
return null;
24+
}
4725

4826
}

io.sloeber.core/src/io/sloeber/core/txt/WorkAround.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
public class WorkAround extends Const {
4646
// Each time this class is touched consider changing the String below to enforce
4747
// updates
48-
private static final String FIRST_SLOEBER_WORKAROUND_LINE = "#Sloeber created TXT file V2.00.test 07 ";
48+
private static final String FIRST_SLOEBER_WORKAROUND_LINE = "#Sloeber created TXT file V2.00.test 09 ";
4949

5050
/**
5151
* workarounds done at installation time. I try to keep those at a minimum but
@@ -325,7 +325,12 @@ private static String platformApplyStandardWorkArounds(String inPlatformTxt) {
325325
changed = changed.replace(" \"{object_file}\" ", " {OUTPUT} ");
326326
changed = changed.replace(" {includes} ", " {FLAGS} -D__IN_ECLIPSE__=1 ");
327327
changed = changed + "{sloeber.extra.compile} {sloeber.extra.c.compile} {sloeber.extra.all}";
328-
platformTXT = platformTXT.replace(origRecipe, changed);
328+
String codan = changed.replace(RECIPE_C_to_O, CODAN_C_to_O);
329+
codan = codan.replace(" -o ", " ");
330+
codan = codan.replace(" {FLAGS} ", " ");
331+
codan = codan.replace(" {OUTPUT} ", " ");
332+
333+
platformTXT = platformTXT.replace(origRecipe, changed + NEWLINE + codan);
329334
}
330335

331336
origRecipe = findLineStartingWith(platformTXT, RECIPE_CPP_to_O);
@@ -335,7 +340,12 @@ private static String platformApplyStandardWorkArounds(String inPlatformTxt) {
335340
changed = changed.replace(" \"{object_file}\" ", " {OUTPUT} ");
336341
changed = changed.replace(" {includes} ", " {FLAGS} -D__IN_ECLIPSE__=1 ");
337342
changed = changed + "{sloeber.extra.compile} {sloeber.extra.cpp.compile} {sloeber.extra.all}";
338-
platformTXT = platformTXT.replace(origRecipe, changed);
343+
String codan = changed.replace(RECIPE_CPP_to_O, CODAN_CPP_to_O);
344+
codan = codan.replace(" -o ", " ");
345+
codan = codan.replace(" {FLAGS} ", " ");
346+
codan = codan.replace(" {OUTPUT} ", " ");
347+
348+
platformTXT = platformTXT.replace(origRecipe, changed + NEWLINE + codan);
339349
}
340350

341351
origRecipe = findLineStartingWith(platformTXT, RECIPE_S_to_O);

0 commit comments

Comments
 (0)