@@ -65,12 +65,67 @@ public String getEnvValue() {
65
65
return "${compiler.warning_flags.none}" ; //$NON-NLS-1$
66
66
}
67
67
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
+ }
68
123
69
124
}
70
125
71
126
private WarningLevels myWarningLevel = WarningLevels .NONE ;
127
+ private SizeCommands mySizeCommand = SizeCommands .RAW_RESULT ;
72
128
73
- private boolean myAlternativeSizeCommand = false ;
74
129
private boolean myEnableParallelBuild = false ;
75
130
private String my_CPP_CompileOptions = new String ();
76
131
private String my_C_CompileOptions = new String ();
@@ -82,15 +137,16 @@ public String getEnvValue() {
82
137
83
138
private static final String ENV_KEY_WARNING_LEVEL = "compiler.warning_flags" ; //$NON-NLS-1$
84
139
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$
91
143
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
+
92
147
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$
94
150
private static final String SLOEBER_SIZE_SWITCH = ENV_KEY_SLOEBER_START + "size.switch" ; //$NON-NLS-1$
95
151
private static final String SLOEBER_ASSEMBLY_COMPILE_OPTIONS = ENV_KEY_SLOEBER_START + "extra.assembly" ; //$NON-NLS-1$
96
152
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) {
113
169
this .myEnableParallelBuild = parrallelBuild ;
114
170
}
115
171
116
- public boolean isAlternativeSizeCommand ( ) {
117
- return this .myAlternativeSizeCommand ;
172
+ public void setSizeCommand ( SizeCommands sizeCommand ) {
173
+ this .mySizeCommand = sizeCommand ;
118
174
}
119
175
120
- public void setAlternativeSizeCommand ( boolean alternativeSizeCommand ) {
121
- this . myAlternativeSizeCommand = alternativeSizeCommand ;
176
+ public SizeCommands getSizeCommand ( ) {
177
+ return mySizeCommand ;
122
178
}
123
179
124
180
public String get_CPP_CompileOptions () {
@@ -193,11 +249,7 @@ public Map<String, String> getEnvVars() {
193
249
ret .put (SLOEBER_LINK_COMPILE_OPTIONS , this .my_Link_CompileOptions );
194
250
ret .put (SLOEBER_ALL_COMPILE_OPTIONS , this .my_All_CompileOptions );
195
251
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 ());
201
253
202
254
return ret ;
203
255
}
@@ -238,7 +290,8 @@ public Map<String, String> getEnvVarsConfig(String prefix) {
238
290
ret .put (prefix + SLOEBER_ALL_COMPILE_OPTIONS , this .my_All_CompileOptions );
239
291
ret .put (prefix + SLOEBER_WARNING_LEVEL , myWarningLevel .toString ());
240
292
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 );
242
295
243
296
return ret ;
244
297
}
@@ -259,13 +312,19 @@ public CompileDescription(TxtFile configFile, String prefix) {
259
312
my_Archive_CompileOptions = section .getValue (SLOEBER_ARCHIVE_COMPILE_OPTIONS );
260
313
my_Link_CompileOptions = section .getValue (SLOEBER_LINK_COMPILE_OPTIONS );
261
314
my_All_CompileOptions = section .getValue (SLOEBER_ALL_COMPILE_OPTIONS );
262
- myAlternativeSizeCommand = TRUE . equalsIgnoreCase ( section . getValue ( SLOEBER_SIZE_SWITCH ));
315
+
263
316
try {
264
317
myWarningLevel = WarningLevels .valueOf (section .getValue (SLOEBER_WARNING_LEVEL ));
265
318
myWarningLevel .setCustomWarningLevel (section .getValue (SLOEBER_WARNING_LEVEL_CUSTOM ));
266
319
} catch (@ SuppressWarnings ("unused" ) Exception e ) {
267
320
// ignore as this will be default
268
321
}
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
+ }
269
328
270
329
}
271
330
@@ -278,7 +337,7 @@ public CompileDescription() {
278
337
279
338
public CompileDescription (CompileDescription compileDescription ) {
280
339
myWarningLevel = compileDescription .myWarningLevel ;
281
- myAlternativeSizeCommand = compileDescription .myAlternativeSizeCommand ;
340
+ mySizeCommand = compileDescription .mySizeCommand ;
282
341
myEnableParallelBuild = compileDescription .myEnableParallelBuild ;
283
342
my_CPP_CompileOptions = compileDescription .my_CPP_CompileOptions ;
284
343
my_C_CompileOptions = compileDescription .my_C_CompileOptions ;
@@ -296,7 +355,7 @@ public CompileDescription(CompileDescription compileDescription) {
296
355
* @return true if the 2 are equal else false
297
356
*/
298
357
public boolean equals (CompileDescription other ) {
299
- return (myWarningLevel == other .myWarningLevel ) && (myAlternativeSizeCommand == other .myAlternativeSizeCommand )
358
+ return (myWarningLevel == other .myWarningLevel ) && (mySizeCommand == other .mySizeCommand )
300
359
&& equalCompileOptions (other );
301
360
}
302
361
@@ -330,7 +389,7 @@ public static CompileDescription getFromCDT(ICConfigurationDescription confDesc)
330
389
if (TRUE .equalsIgnoreCase (getOldWayEnvVar (confDesc , "JANTJE.warning_level" ))) {
331
390
ret .myWarningLevel = WarningLevels .ALL ;
332
391
}
333
- ret .myAlternativeSizeCommand = TRUE . equalsIgnoreCase ( getOldWayEnvVar ( confDesc , "JANTJE.size.switch" )) ;
392
+ ret .mySizeCommand = SizeCommands . RAW_RESULT ;
334
393
return ret ;
335
394
}
336
395
}
0 commit comments