Skip to content

Commit 385106b

Browse files
author
jantje
committed
#661 gui and backbone part
We still need to install awk and point to the correct awk location. We also still need to workaround the ?: problem as this "ignore" method causes issues in awk I also only tested avr. The current solution assumes the interesting data is in the second column. This may not be the case for other "architectures". I have no clue yet how I will handle this.
1 parent 123d643 commit 385106b

File tree

4 files changed

+113
-50
lines changed

4 files changed

+113
-50
lines changed

io.sloeber.core/config/pre_processing_platform_default.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ recipe.objcopy.hex.pattern=${recipe.objcopy.bin.pattern}
44
archive_file=arduino.ar
55
archive_file_path=${build.path}/${archive_file}
66
sloeber.size_command.avr="${compiler.path}${compiler.size.cmd}" --format=avr --mcu=${build.mcu} "${build.path}/${build.project_name}.elf"
7-
sloeber.size_command.orig=${recipe.size.pattern} | C:\test\awk\awk -f size.awk
7+
sloeber.size_command.awk=${recipe.size.pattern} | C:\test\awk\awk -f size.awk
88
runtime.ide.version=10812
99
build.system.path=${referenced.core.path}${DirectoryDelimiter}system
1010
serial.port=${com_port}

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

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,67 @@ public String getEnvValue() {
6565
return "${compiler.warning_flags.none}"; //$NON-NLS-1$
6666
}
6767

68+
}
69+
70+
public enum SizeCommands {
71+
72+
ARDUINO_WAY, AVR_ALTERANATIVE, RAW_RESULT, CUSTOM;
73+
74+
private String myCustomSizeCommand = EMPTY;
75+
76+
/**
77+
* Set the custom command but only if the warning level is CUSTOM
78+
*
79+
* @param customCommand
80+
* the command that needs to be used
81+
*/
82+
public void setCustomSizeCommand(String customWarningLevel) {
83+
if (this == CUSTOM) {
84+
myCustomSizeCommand = customWarningLevel;
85+
}
86+
}
87+
88+
public void setCustomSizeCommand(String customWarningLevel, boolean force) {
89+
if (force) {
90+
myCustomSizeCommand = customWarningLevel;
91+
} else {
92+
setCustomSizeCommand(customWarningLevel);
93+
}
94+
95+
}
96+
97+
public String getCustomSizeCommand() {
98+
return myCustomSizeCommand;
99+
}
100+
101+
/**
102+
* Get the string that should be put in the environment variable that places the
103+
* warning part in the command string This is a non expanded string for Arduino
104+
* IDE supported options This is what the user typed in the GUI in the CUSTOM
105+
* case
106+
*
107+
* @return
108+
*/
109+
public String getEnvValue() {
110+
switch (this) {
111+
case ARDUINO_WAY:
112+
return "${sloeber.size_command.awk}"; //$NON-NLS-1$
113+
case AVR_ALTERANATIVE:
114+
return "${sloeber.size_command.avr}"; //$NON-NLS-1$
115+
case RAW_RESULT:
116+
return "${recipe.size.pattern}"; //$NON-NLS-1$
117+
case CUSTOM:
118+
return myCustomSizeCommand;
119+
120+
}
121+
return "${recipe.size.pattern}"; //$NON-NLS-1$
122+
}
68123

69124
}
70125

71126
private WarningLevels myWarningLevel = WarningLevels.NONE;
127+
private SizeCommands mySizeCommand = SizeCommands.RAW_RESULT;
72128

73-
private boolean myAlternativeSizeCommand = false;
74129
private boolean myEnableParallelBuild = false;
75130
private String my_CPP_CompileOptions = new String();
76131
private String my_C_CompileOptions = new String();
@@ -82,15 +137,16 @@ public String getEnvValue() {
82137

83138
private static final String ENV_KEY_WARNING_LEVEL = "compiler.warning_flags"; //$NON-NLS-1$
84139

85-
private static final String SLOEBER_ADDITIONAL_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START
86-
+ "extra.compile"; //$NON-NLS-1$
87-
private static final String SLOEBER_ADDITIONAL_C_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START
88-
+ "extra.c.compile"; //$NON-NLS-1$
89-
private static final String SLOEBER_ADDITIONAL_CPP_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START
90-
+ "extra.cpp.compile"; //$NON-NLS-1$
140+
private static final String SLOEBER_ADDITIONAL_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.compile"; //$NON-NLS-1$
141+
private static final String SLOEBER_ADDITIONAL_C_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.c.compile"; //$NON-NLS-1$
142+
private static final String SLOEBER_ADDITIONAL_CPP_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.cpp.compile"; //$NON-NLS-1$
91143
private static final String SLOEBER_WARNING_LEVEL = ENV_KEY_SLOEBER_START + "warning_level"; //$NON-NLS-1$
144+
private static final String SLOEBER_SIZE_TYPE = ENV_KEY_SLOEBER_START + "size.type"; //$NON-NLS-1$
145+
private static final String SLOEBER_SIZE_CUSTOM = ENV_KEY_SLOEBER_START + "size.custom"; //$NON-NLS-1$
146+
92147
private static final String SLOEBER_WARNING_LEVEL_CUSTOM = SLOEBER_WARNING_LEVEL + DOT + "custom"; //$NON-NLS-1$
93-
private static final String SLOEBER_SIZE_COMMAND = ENV_KEY_SLOEBER_START + "alt_size_command"; //$NON-NLS-1$
148+
// private static final String SLOEBER_SIZE_COMMAND = ENV_KEY_SLOEBER_START +
149+
// "alt_size_command"; //$NON-NLS-1$
94150
private static final String SLOEBER_SIZE_SWITCH = ENV_KEY_SLOEBER_START + "size.switch"; //$NON-NLS-1$
95151
private static final String SLOEBER_ASSEMBLY_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.assembly"; //$NON-NLS-1$
96152
private static final String SLOEBER_ARCHIVE_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.archive"; //$NON-NLS-1$
@@ -113,12 +169,12 @@ public void setEnableParallelBuild(boolean parrallelBuild) {
113169
this.myEnableParallelBuild = parrallelBuild;
114170
}
115171

116-
public boolean isAlternativeSizeCommand() {
117-
return this.myAlternativeSizeCommand;
172+
public void setSizeCommand(SizeCommands sizeCommand) {
173+
this.mySizeCommand = sizeCommand;
118174
}
119175

120-
public void setAlternativeSizeCommand(boolean alternativeSizeCommand) {
121-
this.myAlternativeSizeCommand = alternativeSizeCommand;
176+
public SizeCommands getSizeCommand() {
177+
return mySizeCommand;
122178
}
123179

124180
public String get_CPP_CompileOptions() {
@@ -193,11 +249,7 @@ public Map<String, String> getEnvVars() {
193249
ret.put(SLOEBER_LINK_COMPILE_OPTIONS, this.my_Link_CompileOptions);
194250
ret.put(SLOEBER_ALL_COMPILE_OPTIONS, this.my_All_CompileOptions);
195251
ret.put(ENV_KEY_WARNING_LEVEL, myWarningLevel.getEnvValue());
196-
if (this.myAlternativeSizeCommand) {
197-
ret.put(SLOEBER_SIZE_SWITCH, makeEnvironmentVar(SLOEBER_SIZE_COMMAND));
198-
} else {
199-
ret.put(SLOEBER_SIZE_SWITCH, makeEnvironmentVar(RECIPE_SIZE));
200-
}
252+
ret.put(SLOEBER_SIZE_SWITCH, mySizeCommand.getEnvValue());
201253

202254
return ret;
203255
}
@@ -238,7 +290,8 @@ public Map<String, String> getEnvVarsConfig(String prefix) {
238290
ret.put(prefix + SLOEBER_ALL_COMPILE_OPTIONS, this.my_All_CompileOptions);
239291
ret.put(prefix + SLOEBER_WARNING_LEVEL, myWarningLevel.toString());
240292
ret.put(prefix + SLOEBER_WARNING_LEVEL_CUSTOM, myWarningLevel.myCustomWarningLevel);
241-
ret.put(prefix + SLOEBER_SIZE_SWITCH, Boolean.valueOf(myAlternativeSizeCommand).toString());
293+
ret.put(prefix + SLOEBER_SIZE_TYPE, mySizeCommand.toString());
294+
ret.put(prefix + SLOEBER_SIZE_CUSTOM, mySizeCommand.myCustomSizeCommand);
242295

243296
return ret;
244297
}
@@ -259,13 +312,19 @@ public CompileDescription(TxtFile configFile, String prefix) {
259312
my_Archive_CompileOptions = section.getValue(SLOEBER_ARCHIVE_COMPILE_OPTIONS);
260313
my_Link_CompileOptions = section.getValue(SLOEBER_LINK_COMPILE_OPTIONS);
261314
my_All_CompileOptions = section.getValue(SLOEBER_ALL_COMPILE_OPTIONS);
262-
myAlternativeSizeCommand = TRUE.equalsIgnoreCase(section.getValue(SLOEBER_SIZE_SWITCH));
315+
263316
try {
264317
myWarningLevel = WarningLevels.valueOf(section.getValue(SLOEBER_WARNING_LEVEL));
265318
myWarningLevel.setCustomWarningLevel(section.getValue(SLOEBER_WARNING_LEVEL_CUSTOM));
266319
} catch (@SuppressWarnings("unused") Exception e) {
267320
// ignore as this will be default
268321
}
322+
try {
323+
mySizeCommand = SizeCommands.valueOf(section.getValue(SLOEBER_SIZE_TYPE));
324+
mySizeCommand.setCustomSizeCommand(section.getValue(SLOEBER_SIZE_CUSTOM));
325+
} catch (@SuppressWarnings("unused") Exception e) {
326+
// ignore as this will be default
327+
}
269328

270329
}
271330

@@ -278,7 +337,7 @@ public CompileDescription() {
278337

279338
public CompileDescription(CompileDescription compileDescription) {
280339
myWarningLevel = compileDescription.myWarningLevel;
281-
myAlternativeSizeCommand = compileDescription.myAlternativeSizeCommand;
340+
mySizeCommand = compileDescription.mySizeCommand;
282341
myEnableParallelBuild = compileDescription.myEnableParallelBuild;
283342
my_CPP_CompileOptions = compileDescription.my_CPP_CompileOptions;
284343
my_C_CompileOptions = compileDescription.my_C_CompileOptions;
@@ -296,7 +355,7 @@ public CompileDescription(CompileDescription compileDescription) {
296355
* @return true if the 2 are equal else false
297356
*/
298357
public boolean equals(CompileDescription other) {
299-
return (myWarningLevel == other.myWarningLevel) && (myAlternativeSizeCommand == other.myAlternativeSizeCommand)
358+
return (myWarningLevel == other.myWarningLevel) && (mySizeCommand == other.mySizeCommand)
300359
&& equalCompileOptions(other);
301360
}
302361

@@ -330,7 +389,7 @@ public static CompileDescription getFromCDT(ICConfigurationDescription confDesc)
330389
if (TRUE.equalsIgnoreCase(getOldWayEnvVar(confDesc, "JANTJE.warning_level"))) {
331390
ret.myWarningLevel = WarningLevels.ALL;
332391
}
333-
ret.myAlternativeSizeCommand = TRUE.equalsIgnoreCase(getOldWayEnvVar(confDesc, "JANTJE.size.switch"));
392+
ret.mySizeCommand = SizeCommands.RAW_RESULT;
334393
return ret;
335394
}
336395
}

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.sloeber.core.api.BoardDescription;
2626
import io.sloeber.core.api.CodeDescription;
2727
import io.sloeber.core.api.CompileDescription;
28+
import io.sloeber.core.api.CompileDescription.SizeCommands;
2829
import io.sloeber.core.api.CompileDescription.WarningLevels;
2930
import io.sloeber.core.api.OtherDescription;
3031
import io.sloeber.core.api.PackageManager;
@@ -368,6 +369,7 @@ public void rename_Configuration() throws Exception {
368369
fail("Failed to compile the project after config rename");
369370
}
370371
}
372+
371373
/**
372374
* open and close a project should keep the compileDescription and
373375
* BoardDescriotion
@@ -429,7 +431,6 @@ public void openAndClosePreservesSettings() throws Exception {
429431
fail("Failed to compile the project:" + projectName);
430432
}
431433

432-
433434
}
434435

435436
@Test
@@ -459,9 +460,6 @@ public void closeProjectRemovesPropertiesSloeber() throws Exception {
459460
}
460461
}
461462

462-
463-
464-
465463
/**
466464
* open and close a project should keep the compileDescription and
467465
* BoardDescriotion
@@ -565,7 +563,7 @@ static CompileDescription getBunkersCompileDescription() {
565563
inCompileDescription.set_C_CompileOptions("-Dvijf=5");
566564
inCompileDescription.set_Link_CompileOptions("-Dzes=6");
567565
inCompileDescription.set_CPP_CompileOptions("-Dzeven=7");
568-
inCompileDescription.setAlternativeSizeCommand(true);
566+
inCompileDescription.setSizeCommand(SizeCommands.ARDUINO_WAY);
569567
inCompileDescription.setEnableParallelBuild(true);
570568
inCompileDescription.setWarningLevel(WarningLevels.NONE);
571569
return inCompileDescription;

io.sloeber.ui/src/io/sloeber/ui/project/properties/CompileProperties.java

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
import org.eclipse.swt.events.FocusListener;
1010
import org.eclipse.swt.layout.GridData;
1111
import org.eclipse.swt.layout.GridLayout;
12-
import org.eclipse.swt.widgets.Button;
1312
import org.eclipse.swt.widgets.Composite;
1413
import org.eclipse.swt.widgets.Event;
1514
import org.eclipse.swt.widgets.Label;
1615
import org.eclipse.swt.widgets.Listener;
1716
import org.eclipse.swt.widgets.Text;
1817

1918
import io.sloeber.core.api.CompileDescription;
19+
import io.sloeber.core.api.CompileDescription.SizeCommands;
2020
import io.sloeber.core.api.CompileDescription.WarningLevels;
2121
import io.sloeber.ui.LabelCombo;
2222
import io.sloeber.ui.Messages;
2323

2424
public class CompileProperties extends SloeberCpropertyTab {
2525
private LabelCombo myWarningLevel;
2626
private Text myCustomWarningLevel;
27-
private Button mySizeCommand;
27+
private LabelCombo mySizeCommand;
28+
private Text myCustomSizeCommand;
2829
private Text myCAndCppCommand;
2930
private Text myCppCommand;
3031
private Text myCCommand;
@@ -35,18 +36,6 @@ public class CompileProperties extends SloeberCpropertyTab {
3536

3637
private boolean disableListeners = false;
3738

38-
private Listener buttonListener = new Listener() {
39-
@Override
40-
public void handleEvent(Event e) {
41-
if (disableListeners)
42-
return;
43-
switch (e.type) {
44-
case SWT.Selection:
45-
getFromScreen();
46-
break;
47-
}
48-
}
49-
};
5039
protected Listener myLabelComboListener = new Listener() {
5140
@Override
5241
public void handleEvent(Event e) {
@@ -55,6 +44,7 @@ public void handleEvent(Event e) {
5544
getFromScreen();
5645
CompileDescription compDesc = (CompileDescription) getDescription(getConfdesc());
5746
myCustomWarningLevel.setEnabled(compDesc.getWarningLevel() == WarningLevels.CUSTOM);
47+
myCustomSizeCommand.setEnabled(compDesc.getSizeCommand() == SizeCommands.CUSTOM);
5848
}
5949
};
6050
private FocusListener foucusListener = new FocusListener() {
@@ -116,18 +106,26 @@ public void createControls(Composite parent, ICPropertyProvider provider) {
116106
myWarningLevel.setItems(getNames(WarningLevels.class));
117107
myWarningLevel.addListener(myLabelComboListener);
118108

119-
120109
myCustomWarningLevel = new Text(usercomp, SWT.BORDER | SWT.LEFT);
121110
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
122111
myCustomWarningLevel.setLayoutData(gridData);
123112
myCustomWarningLevel.addFocusListener(foucusListener);
124113

125114
// checkbox show alternative size
126-
this.mySizeCommand = new Button(this.usercomp, SWT.CHECK);
127-
this.mySizeCommand.setText(Messages.ui_Alternative_size);
128-
this.mySizeCommand.setEnabled(true);
129-
this.mySizeCommand.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 3, 1));
130-
mySizeCommand.addListener(SWT.Selection, buttonListener);
115+
mySizeCommand = new LabelCombo(usercomp, Messages.ui_Alternative_size, 1, true);
116+
mySizeCommand.setItems(getNames(SizeCommands.class));
117+
mySizeCommand.addListener(myLabelComboListener);
118+
119+
myCustomSizeCommand = new Text(usercomp, SWT.BORDER | SWT.LEFT);
120+
gridData = new GridData(GridData.FILL_HORIZONTAL);
121+
myCustomSizeCommand.setLayoutData(gridData);
122+
myCustomSizeCommand.addFocusListener(foucusListener);
123+
124+
// this.mySizeCommand = new Button(this.usercomp, SWT.CHECK);
125+
// this.mySizeCommand.setText(Messages.ui_Alternative_size);
126+
// this.mySizeCommand.setEnabled(true);
127+
// this.mySizeCommand.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 3, 1));
128+
// mySizeCommand.addListener(SWT.Selection, buttonListener);
131129

132130
createLine(this.usercomp, 3);
133131
this.myCAndCppCommand = makeOptionField(Messages.ui_append_c_cpp, Messages.ui_append_c_cpp_text);
@@ -153,7 +151,11 @@ protected void updateScreen() {
153151
myWarningLevel.setText(compDesc.getWarningLevel().toString());
154152
myCustomWarningLevel.setEnabled(compDesc.getWarningLevel() == WarningLevels.CUSTOM);
155153
myCustomWarningLevel.setText(compDesc.getWarningLevel().getCustomWarningLevel());
156-
mySizeCommand.setSelection(compDesc.isAlternativeSizeCommand());
154+
155+
mySizeCommand.setText(compDesc.getSizeCommand().toString());
156+
myCustomSizeCommand.setEnabled(compDesc.getSizeCommand() == SizeCommands.CUSTOM);
157+
myCustomSizeCommand.setText(compDesc.getSizeCommand().getCustomSizeCommand());
158+
157159
myCAndCppCommand.setText(compDesc.get_C_andCPP_CompileOptions());
158160
myCCommand.setText(compDesc.get_C_CompileOptions());
159161
myCppCommand.setText(compDesc.get_CPP_CompileOptions());
@@ -169,8 +171,12 @@ protected Object getFromScreen() {
169171
CompileDescription compDesc = (CompileDescription) getDescription(getConfdesc());
170172
WarningLevels warningLevel = WarningLevels.valueOf(myWarningLevel.getText());
171173
warningLevel.setCustomWarningLevel(myCustomWarningLevel.getText());
174+
175+
SizeCommands sizeCommand = SizeCommands.valueOf(mySizeCommand.getText());
176+
sizeCommand.setCustomSizeCommand(myCustomSizeCommand.getText());
177+
172178
compDesc.setWarningLevel(warningLevel);
173-
compDesc.setAlternativeSizeCommand(this.mySizeCommand.getSelection());
179+
compDesc.setSizeCommand(sizeCommand);
174180
compDesc.set_C_andCPP_CompileOptions(this.myCAndCppCommand.getText());
175181
compDesc.set_C_CompileOptions(this.myCCommand.getText());
176182
compDesc.set_CPP_CompileOptions(this.myCppCommand.getText());

0 commit comments

Comments
 (0)