1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

New preference: enable all compiler warnings, off by default. Fixes #1728 and #2415. Also affects #2634 and #2207

This commit is contained in:
Federico Fissore 2015-04-10 15:27:25 +02:00
parent 37e2a1994a
commit 61592d78fa
3 changed files with 27 additions and 3 deletions

View File

@ -203,10 +203,9 @@ public class Preferences {
JCheckBox verboseCompilationBox; JCheckBox verboseCompilationBox;
JCheckBox verboseUploadBox; JCheckBox verboseUploadBox;
JCheckBox displayLineNumbersBox; JCheckBox displayLineNumbersBox;
JCheckBox enableCompilerWarningsBox;
JCheckBox verifyUploadBox; JCheckBox verifyUploadBox;
JCheckBox externalEditorBox; JCheckBox externalEditorBox;
JCheckBox memoryOverrideBox;
JTextField memoryField;
JCheckBox checkUpdatesBox; JCheckBox checkUpdatesBox;
JTextField fontSizeField; JTextField fontSizeField;
JCheckBox updateExtensionBox; JCheckBox updateExtensionBox;
@ -352,6 +351,15 @@ public class Preferences {
pane.add(box); pane.add(box);
d = box.getPreferredSize(); d = box.getPreferredSize();
box.setBounds(left, top, d.width, d.height); box.setBounds(left, top, d.width, d.height);
top += d.height + GUI_BETWEEN;
// [ ] Enable all compiler warnings
enableCompilerWarningsBox = new JCheckBox(_("Enable all compiler warnings"));
pane.add(enableCompilerWarningsBox);
d = enableCompilerWarningsBox.getPreferredSize();
enableCompilerWarningsBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN; top += d.height + GUI_BETWEEN;
// [ ] Display line numbers // [ ] Display line numbers
@ -674,6 +682,7 @@ public class Preferences {
PreferencesData.setBoolean("editor.linenumbers", displayLineNumbersBox.isSelected()); PreferencesData.setBoolean("editor.linenumbers", displayLineNumbersBox.isSelected());
PreferencesData.setBoolean("upload.verify", verifyUploadBox.isSelected()); PreferencesData.setBoolean("upload.verify", verifyUploadBox.isSelected());
PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected()); PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected());
PreferencesData.setBoolean("build.allwarnings", enableCompilerWarningsBox.isSelected());
// setBoolean("sketchbook.closing_last_window_quits", // setBoolean("sketchbook.closing_last_window_quits",
// closingLastQuitsBox.isSelected()); // closingLastQuitsBox.isSelected());
@ -758,6 +767,7 @@ public class Preferences {
verboseUploadBox.setSelected(PreferencesData.getBoolean("upload.verbose")); verboseUploadBox.setSelected(PreferencesData.getBoolean("upload.verbose"));
displayLineNumbersBox.setSelected(PreferencesData.getBoolean("editor.linenumbers")); displayLineNumbersBox.setSelected(PreferencesData.getBoolean("editor.linenumbers"));
verifyUploadBox.setSelected(PreferencesData.getBoolean("upload.verify")); verifyUploadBox.setSelected(PreferencesData.getBoolean("upload.verify"));
enableCompilerWarningsBox.setSelected(PreferencesData.getBoolean("build.allwarnings"));
//closingLastQuitsBox. //closingLastQuitsBox.
// setSelected(getBoolean("sketchbook.closing_last_window_quits")); // setSelected(getBoolean("sketchbook.closing_last_window_quits"));

View File

@ -559,6 +559,7 @@ public class Compiler implements MessageConsumer {
File objectFile = new File(outputPath, file.getName() + ".o"); File objectFile = new File(outputPath, file.getName() + ".o");
objectPaths.add(objectFile); objectPaths.add(objectFile);
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.S.o.pattern"); String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.S.o.pattern");
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
execAsynchronously(cmd); execAsynchronously(cmd);
} }
@ -569,6 +570,7 @@ public class Compiler implements MessageConsumer {
if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.c.o.pattern"); String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.c.o.pattern");
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
execAsynchronously(cmd); execAsynchronously(cmd);
} }
@ -579,12 +581,24 @@ public class Compiler implements MessageConsumer {
if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.cpp.o.pattern"); String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.cpp.o.pattern");
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
execAsynchronously(cmd); execAsynchronously(cmd);
} }
return objectPaths; return objectPaths;
} }
private String[] enableWarnings(String[] cmd, boolean enable) {
if (!enable) {
return cmd;
}
List<String> cmdList = new ArrayList<String>(Arrays.asList(cmd));
cmdList.remove("-w");
return cmdList.toArray(new String[cmdList.size()]);
}
/** /**
* Strip escape sequences used in makefile dependency files (.d) * Strip escape sequences used in makefile dependency files (.d)
* https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845 * https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845

View File

@ -311,7 +311,7 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
* insensitive compared), <b>false</b> in any other case * insensitive compared), <b>false</b> in any other case
*/ */
public boolean getBoolean(String key) { public boolean getBoolean(String key) {
return new Boolean(get(key)); return Boolean.valueOf(get(key));
} }
/** /**