Skip to content

Commit 0e62027

Browse files
author
jantje
committed
#1489 stop splitting the recipe patterns and add ar to build
Sloeber used to split the recipes to reassemble them on the command line so CDT can find the needed environment variables In this change I remove the splitting fields and add them at the end of the command line This will probably make some platform fail (due to the move of the fields on the command line) I need to look to modify the CDT provided command when the board/platform is selected/changed.
1 parent a4ffb72 commit 0e62027

File tree

3 files changed

+67
-59
lines changed

3 files changed

+67
-59
lines changed

io.sloeber.core/plugin.xml

+22-11
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<tool
163163
announcement="%tool.Arduino.CPP.announcement"
164164
command="${recipe.cpp.o.pattern}"
165-
commandLinePattern="${recipe.cpp.o.pattern.1} ${FLAGS} -D__IN_ECLIPSE__=1 -x c++ ${INPUTS} ${recipe.cpp.o.pattern.2} -o ${OUTPUT} ${recipe.cpp.o.pattern.3} ${sloeber.extra.compile} ${sloeber.extra.cpp.compile} ${sloeber.extra.all}"
165+
commandLinePattern="${recipe.cpp.o.pattern} ${FLAGS} -D__IN_ECLIPSE__=1 ${INPUTS} -o ${OUTPUT} ${sloeber.extra.compile} ${sloeber.extra.cpp.compile} ${sloeber.extra.all}"
166166
errorParsers="org.eclipse.cdt.core.GCCErrorParser"
167167
id="io.sloeber.tool.sketch.compiler.cpp"
168168
name="%tool.Arduino.CPP2O.name"
@@ -209,7 +209,7 @@
209209
<tool
210210
announcement="%tool.Arduino.C.announcement"
211211
command="${recipe.c.o.pattern}"
212-
commandLinePattern="${recipe.c.o.pattern.1} ${FLAGS} -D__IN_ECLIPSE__=1 ${INPUTS} ${recipe.c.o.pattern.2} -o ${OUTPUT} ${recipe.c.o.pattern.3} ${sloeber.extra.compile} ${sloeber.extra.c.compile} ${sloeber.extra.all}"
212+
commandLinePattern="${recipe.c.o.pattern} ${FLAGS} -D__IN_ECLIPSE__=1 ${INPUTS} -o ${OUTPUT} ${sloeber.extra.compile} ${sloeber.extra.c.compile} ${sloeber.extra.all}"
213213
errorParsers="org.eclipse.cdt.core.GCCErrorParser"
214214
id="io.sloeber.tool.compiler.c"
215215
name="%tool.Arduino.C2O.name"
@@ -242,7 +242,7 @@
242242
id="io.sloeber.compiler.c.link.output"
243243
name="%outputType.C.link.name"
244244
nameProvider="io.sloeber.core.toolchain.LinkNameProvider"
245-
outputs="o"
245+
outputs="O"
246246
primaryOutput="true">
247247
</outputType>
248248
<outputType
@@ -257,7 +257,7 @@
257257
<tool
258258
announcement="%tool.Arduino.S.announcement"
259259
command="${recipe.S.o.pattern}"
260-
commandLinePattern="${recipe.S.o.pattern.1} ${FLAGS} ${INPUTS} ${recipe.S.o.pattern.2} -o ${OUTPUT} ${recipe.S.o.pattern.3} ${sloeber.extra.assembly} ${sloeber.extra.all}"
260+
commandLinePattern="${recipe.S.o.pattern} ${FLAGS} ${INPUTS} -o ${OUTPUT} ${sloeber.extra.assembly} ${sloeber.extra.all}"
261261
errorParsers="org.eclipse.cdt.core.GCCErrorParser"
262262
id="io.sloeber.tool.sketch.compiler.s"
263263
name="%tool.Arduino.S20.name"
@@ -304,7 +304,7 @@
304304
<tool
305305
announcement="%tool.Arduino.archiver.announcement"
306306
command="${recipe.ar.pattern}"
307-
commandLinePattern="${recipe.ar.pattern.1} ${FLAGS} ${archive_file_path} ${INPUTS} ${recipe.ar.pattern.2} ${recipe.ar.pattern.3} ${sloeber.extra_archive} ${sloeber.extra_all}"
307+
commandLinePattern="${recipe.ar.pattern} ${FLAGS} ${archive_file_path} ${INPUTS} ${sloeber.extra_archive} ${sloeber.extra_all}"
308308
errorParsers="org.eclipse.cdt.core.GLDErrorParser"
309309
id="io.sloeber.tool.ar"
310310
name="%tool.archiver.name">
@@ -329,7 +329,7 @@
329329
<tool
330330
announcement="%tool.Arduino.combiner.announcement"
331331
command="${recipe.c.combine.pattern}"
332-
commandLinePattern="${sloeber.pre.link}${recipe.c.combine.pattern.1} ${FLAGS} ${INPUTS} ${recipe.c.combine.pattern.2} ${archive_file_path} ${recipe.c.combine.pattern.3} ${sloeber.extra_all} ${sloeber.extra.link}${sloeber.post.link}"
332+
commandLinePattern="${sloeber.pre.link}${recipe.c.combine.pattern} ${FLAGS} ${INPUTS} ${AR} ${sloeber.extra_all} ${sloeber.extra.link}${sloeber.post.link}"
333333
errorParsers="org.eclipse.cdt.core.GLDErrorParser"
334334
id="io.sloeber.tool.combine"
335335
name="%tool.combiner.name"
@@ -342,17 +342,28 @@
342342
outputs="elf"
343343
primaryOutput="true">
344344
</outputType>
345-
<inputType
345+
<inputType
346346
buildVariable="LINK_OBJ"
347347
id="io.sloeber.tool.combiner.ob.input"
348348
multipleOfType="true"
349349
name="%inputType.linker.name"
350350
primaryInput="true"
351351
sources="O">
352-
<additionalInput
353-
kind="additionaldependency"
354-
paths="$(AR)">
355-
</additionalInput>
352+
</inputType>
353+
<inputType
354+
buildVariable="AR"
355+
id="io.sloeber.tool.combiner.ar.input"
356+
multipleOfType="true"
357+
name="Build Archives"
358+
primaryInput="false"
359+
sources="ar">
360+
</inputType>
361+
<inputType
362+
id="io.sloeber.tool.combiner.fixed.ar.input"
363+
multipleOfType="true"
364+
name="provided archives"
365+
primaryInput="false"
366+
sources="ar">
356367
</inputType>
357368
</tool>
358369
<tool

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

-41
Original file line numberDiff line numberDiff line change
@@ -960,47 +960,6 @@ private Map<String, String> getEnvVarsPostProcessing(Map<String, String> vars) {
960960

961961
Map<String, String> extraVars = new HashMap<>();
962962

963-
// split the recipes so we can add the input and output markers as cdt needs
964-
// them
965-
String recipeKeys[] = { RECIPE_C_to_O, RECIPE_CPP_to_O, RECIPE_S_to_O, RECIPE_SIZE, RECIPE_AR,
966-
RECIPE_C_COMBINE };
967-
for (String recipeKey : recipeKeys) {
968-
String recipe = vars.get(recipeKey);
969-
if (null == recipe) {
970-
continue;
971-
}
972-
973-
// Sloeber should split o, -o {output} but to be safe that needs a regex so I
974-
// simply delete the -o
975-
if (!RECIPE_C_COMBINE.equals(recipeKey)) {
976-
recipe = recipe.replace(" -o ", " "); //$NON-NLS-1$ //$NON-NLS-2$
977-
}
978-
String recipeParts[] = recipe.split(
979-
"(\"\\$\\{object_file}\")|(\\$\\{object_files})|(\"\\$\\{source_file}\")|(\"[^\"]*\\$\\{archive_file}\")|(\"[^\"]*\\$\\{archive_file_path}\")", //$NON-NLS-1$
980-
3);
981-
982-
switch (recipeParts.length) {
983-
case 0:
984-
extraVars.put(recipeKey + DOT + '1', "echo no command for \"{KEY}\".".replace(KEY_TAG, recipeKey)); //$NON-NLS-1$
985-
break;
986-
case 1:
987-
extraVars.put(recipeKey + DOT + '1', recipeParts[0]);
988-
break;
989-
case 2:
990-
extraVars.put(recipeKey + DOT + '1', recipeParts[0]);
991-
extraVars.put(recipeKey + DOT + '2', recipeParts[1]);
992-
break;
993-
case 3:
994-
extraVars.put(recipeKey + DOT + '1', recipeParts[0]);
995-
extraVars.put(recipeKey + DOT + '2', recipeParts[1]);
996-
extraVars.put(recipeKey + DOT + '3', recipeParts[2]);
997-
998-
break;
999-
default:
1000-
// this should never happen as the split is limited to 3
1001-
}
1002-
}
1003-
1004963
ArrayList<String> objcopyCommand = new ArrayList<>();
1005964
for (Entry<String, String> curVariable : vars.entrySet()) {
1006965
String name = curVariable.getKey();

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

+45-7
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 workaound file V1.04.test 04 ";
48+
private static final String FIRST_SLOEBER_WORKAROUND_LINE = "#Sloeber created workaound file V1.05.test 05 ";
4949

5050
/**
5151
* workarounds done at installation time. I try to keep those at a minimum but
@@ -318,12 +318,50 @@ private static String platformApplyStandardWorkArounds(String inPlatformTxt) {
318318
String platformTXT = inPlatformTxt;
319319
String searchPlatformTXT = "\n" + inPlatformTxt;
320320

321-
// the fix below seems no longer needed but is still on august 2021
322-
// Arduino treats core differently so we need to change the location of directly
323-
// referenced files this manifests only in the combine recipe
324-
String inCombineRecipe = findLineStartingWith(platformTXT, "recipe.c.combine.pattern");
325-
if (null != inCombineRecipe) {
321+
//C o need the input and output file stuff removed as CDT wants thes at the command level
322+
String inCORecipe = findLineStartingWith(platformTXT, RECIPE_C_to_O);
323+
if (null != inCORecipe) {
324+
String outCORecipe = inCORecipe.replace(" -o ", " ");
325+
outCORecipe = outCORecipe.replace(" \"{source_file}\"", " ");
326+
outCORecipe = outCORecipe.replace(" \"{object_file}\"", " ");
327+
platformTXT = platformTXT.replace(inCORecipe, outCORecipe);
328+
}
329+
330+
//Cpp o need the input and output file stuff removed as CDT wants thes at the command level
331+
String inCppORecipe = findLineStartingWith(platformTXT, RECIPE_CPP_to_O);
332+
if (null != inCppORecipe) {
333+
String outCppORecipe = inCppORecipe.replace(" -o ", " ");
334+
outCppORecipe = outCppORecipe.replace(" \"{source_file}\"", " ");
335+
outCppORecipe = outCppORecipe.replace(" \"{object_file}\"", " ");
336+
platformTXT = platformTXT.replace(inCppORecipe, outCppORecipe);
337+
}
338+
339+
//S o need the input and output file stuff removed as CDT wants thes at the command level
340+
String inSORecipe = findLineStartingWith(platformTXT, RECIPE_S_to_O);
341+
if (null != inSORecipe) {
342+
String outSORecipe = inSORecipe.replace(" -o ", " ");
343+
outSORecipe = outSORecipe.replace(" \"{source_file}\"", " ");
344+
outSORecipe = outSORecipe.replace(" \"{object_file}\"", " ");
345+
platformTXT = platformTXT.replace(inSORecipe, outSORecipe);
346+
}
347+
348+
//Archiver needs the "{archive_file_path}" "{object_file}" file stuff removed as CDT wants thes at the command level
349+
String inArRecipe = findLineStartingWith(platformTXT, RECIPE_AR);
350+
if (null != inArRecipe) {
351+
String outArRecipe = inArRecipe.replace(" {archive_file_path} ", " ");
352+
outArRecipe = outArRecipe.replace(" {object_file}", " ");
353+
platformTXT = platformTXT.replace(inArRecipe, outArRecipe);
354+
}
355+
356+
String inCombineRecipe = findLineStartingWith(platformTXT, RECIPE_C_COMBINE);
357+
if (null != inArRecipe) {
358+
// the fix below seems no longer needed but is still on august 2021
359+
// Arduino treats core differently so we need to change the location of directly
360+
// referenced files this manifests only in the combine recipe
326361
String outCombineRecipe = inCombineRecipe.replaceAll("(\\{build\\.path})(/core)?/sys", "$1/core/core/sys");
362+
363+
outCombineRecipe = outCombineRecipe.replace(" \"{build.path}/{archive_file}\"", " ");
364+
outCombineRecipe = outCombineRecipe.replace(" {object_files}", " ");
327365
platformTXT = platformTXT.replace(inCombineRecipe, outCombineRecipe);
328366
}
329367

@@ -411,7 +449,7 @@ private static String platformApplyStandardWorkArounds(String inPlatformTxt) {
411449
private static String findLineStartingWith(String text, String startOfLine) {
412450
int lineStartIndex = text.indexOf("\n" + startOfLine) + 1;
413451
if (lineStartIndex > 0) {
414-
int lineEndIndex = text.indexOf("\n", lineStartIndex) - 1;
452+
int lineEndIndex = text.indexOf("\n", lineStartIndex);
415453
if (lineEndIndex > 0) {
416454
return text.substring(lineStartIndex, lineEndIndex);
417455
}

0 commit comments

Comments
 (0)