mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
Better preference for setting warnings level. See 61592d78fa (commitcomment-10668365)
This commit is contained in:
parent
c740f251f4
commit
b42c6667e1
@ -165,6 +165,25 @@ public class Preferences {
|
||||
new Language(_("Western Frisian"), "Western Frisian", "fy"),
|
||||
};
|
||||
|
||||
private static class WarningItem {
|
||||
private final String value;
|
||||
private final String translation;
|
||||
|
||||
public WarningItem(String value, String translation) {
|
||||
this.value = value;
|
||||
this.translation = translation;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
|
||||
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
|
||||
@ -203,7 +222,6 @@ public class Preferences {
|
||||
JCheckBox verboseCompilationBox;
|
||||
JCheckBox verboseUploadBox;
|
||||
JCheckBox displayLineNumbersBox;
|
||||
JCheckBox enableCompilerWarningsBox;
|
||||
JCheckBox verifyUploadBox;
|
||||
JCheckBox externalEditorBox;
|
||||
JCheckBox checkUpdatesBox;
|
||||
@ -211,6 +229,7 @@ public class Preferences {
|
||||
JCheckBox updateExtensionBox;
|
||||
JCheckBox autoAssociateBox;
|
||||
JComboBox comboLanguage;
|
||||
JComboBox comboWarnings;
|
||||
JCheckBox saveVerifyUploadBox;
|
||||
JTextField proxyHTTPServer;
|
||||
JTextField proxyHTTPPort;
|
||||
@ -355,10 +374,22 @@ public class Preferences {
|
||||
|
||||
// [ ] 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);
|
||||
box = Box.createHorizontalBox();
|
||||
label = new JLabel(_("Compiler warnings: "));
|
||||
box.add(label);
|
||||
WarningItem[] warningItems = new WarningItem[]{new WarningItem("none", _("none")), new WarningItem("normal", _("normal")), new WarningItem("all", _("all")), new WarningItem("extra", _("extra")), };
|
||||
comboWarnings = new JComboBox(warningItems);
|
||||
String currentWarningLevel = PreferencesData.get("compiler.warning_flags", "none");
|
||||
for (WarningItem item : warningItems) {
|
||||
if (currentWarningLevel.equals(item.getValue())) {
|
||||
comboWarnings.setSelectedItem(item);
|
||||
}
|
||||
}
|
||||
box.add(comboWarnings);
|
||||
pane.add(box);
|
||||
d = box.getPreferredSize();
|
||||
box.setForeground(Color.gray);
|
||||
box.setBounds(left, top, d.width, d.height);
|
||||
right = Math.max(right, left + d.width);
|
||||
top += d.height + GUI_BETWEEN;
|
||||
|
||||
@ -682,7 +713,6 @@ public class Preferences {
|
||||
PreferencesData.setBoolean("editor.linenumbers", displayLineNumbersBox.isSelected());
|
||||
PreferencesData.setBoolean("upload.verify", verifyUploadBox.isSelected());
|
||||
PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected());
|
||||
PreferencesData.setBoolean("build.allwarnings", enableCompilerWarningsBox.isSelected());
|
||||
|
||||
// setBoolean("sketchbook.closing_last_window_quits",
|
||||
// closingLastQuitsBox.isSelected());
|
||||
@ -740,6 +770,9 @@ public class Preferences {
|
||||
Language newLanguage = (Language) comboLanguage.getSelectedItem();
|
||||
PreferencesData.set("editor.languages.current", newLanguage.isoCode);
|
||||
|
||||
WarningItem warningItem = (WarningItem) comboWarnings.getSelectedItem();
|
||||
PreferencesData.set("compiler.warning_flags", warningItem.getValue());
|
||||
|
||||
Preferences.set("proxy.http.server", proxyHTTPServer.getText());
|
||||
try {
|
||||
Preferences.set("proxy.http.port", Integer.valueOf(proxyHTTPPort.getText()).toString());
|
||||
@ -767,7 +800,6 @@ public class Preferences {
|
||||
verboseUploadBox.setSelected(PreferencesData.getBoolean("upload.verbose"));
|
||||
displayLineNumbersBox.setSelected(PreferencesData.getBoolean("editor.linenumbers"));
|
||||
verifyUploadBox.setSelected(PreferencesData.getBoolean("upload.verify"));
|
||||
enableCompilerWarningsBox.setSelected(PreferencesData.getBoolean("build.allwarnings"));
|
||||
|
||||
//closingLastQuitsBox.
|
||||
// setSelected(getBoolean("sketchbook.closing_last_window_quits"));
|
||||
|
@ -557,7 +557,6 @@ public class Compiler implements MessageConsumer {
|
||||
File objectFile = new File(outputPath, file.getName() + ".o");
|
||||
objectPaths.add(objectFile);
|
||||
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.S.o.pattern");
|
||||
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
|
||||
execAsynchronously(cmd);
|
||||
}
|
||||
|
||||
@ -568,7 +567,6 @@ public class Compiler implements MessageConsumer {
|
||||
if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
|
||||
continue;
|
||||
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.c.o.pattern");
|
||||
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
|
||||
execAsynchronously(cmd);
|
||||
}
|
||||
|
||||
@ -579,24 +577,12 @@ public class Compiler implements MessageConsumer {
|
||||
if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
|
||||
continue;
|
||||
String[] cmd = getCommandCompilerByRecipe(includeFolders, file, objectFile, "recipe.cpp.o.pattern");
|
||||
cmd = enableWarnings(cmd, prefs.getBoolean("build.allwarnings"));
|
||||
execAsynchronously(cmd);
|
||||
}
|
||||
|
||||
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)
|
||||
* https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845
|
||||
@ -906,6 +892,8 @@ public class Compiler implements MessageConsumer {
|
||||
dict.put("source_file", sourceFile.getAbsolutePath());
|
||||
dict.put("object_file", objectFile.getAbsolutePath());
|
||||
|
||||
setupWarningFlags(dict);
|
||||
|
||||
String cmd = prefs.getOrExcept(recipe);
|
||||
try {
|
||||
return StringReplacer.formatAndSplit(cmd, dict, true);
|
||||
@ -914,6 +902,19 @@ public class Compiler implements MessageConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWarningFlags(PreferencesMap dict) {
|
||||
if (dict.containsKey("compiler.warning_flags")) {
|
||||
String key = "compiler.warning_flags." + dict.get("compiler.warning_flags");
|
||||
dict.put("compiler.warning_flags", dict.get(key));
|
||||
} else {
|
||||
dict.put("compiler.warning_flags", dict.get("compiler.warning_flags.none"));
|
||||
}
|
||||
|
||||
if (dict.get("compiler.warning_flags") == null) {
|
||||
dict.remove("compiler.warning_flags");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createFolder(File folder) throws RunnerException {
|
||||
@ -1106,6 +1107,8 @@ public class Compiler implements MessageConsumer {
|
||||
dict.put("object_files", objectFileList);
|
||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||
|
||||
setupWarningFlags(dict);
|
||||
|
||||
String[] cmdArray;
|
||||
String cmd = prefs.getOrExcept("recipe.c.combine.pattern");
|
||||
try {
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Arduino AVR Core and platform.
|
||||
# ------------------------------
|
||||
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
@ -11,17 +11,22 @@ version=1.6.3
|
||||
# AVR compile variables
|
||||
# ---------------------
|
||||
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.normal=
|
||||
compiler.warning_flags.all=-Wall
|
||||
compiler.warning_flags.extra=-Wall -Wextra
|
||||
|
||||
# Default "compiler.path" is correct, change only if you want to overidde the initial value
|
||||
compiler.path={runtime.tools.avr-gcc.path}/bin/
|
||||
compiler.c.cmd=avr-gcc
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
|
||||
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD
|
||||
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
|
||||
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
|
||||
compiler.c.elf.flags=-w -Os -Wl,--gc-sections
|
||||
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
|
||||
compiler.c.elf.cmd=avr-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=avr-g++
|
||||
compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.ar.cmd=avr-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=avr-objcopy
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
# Arduino SAM Core and platform.
|
||||
# ------------------------------
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
@ -10,14 +11,19 @@ version=1.6.3
|
||||
# SAM3 compile variables
|
||||
# ----------------------
|
||||
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.normal=
|
||||
compiler.warning_flags.all=-Wall
|
||||
compiler.warning_flags.extra=-Wall -Wextra
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
|
||||
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
|
||||
compiler.c.elf.cmd=arm-none-eabi-gcc
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
|
||||
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
|
Loading…
x
Reference in New Issue
Block a user