1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Better preference for setting warnings level. See 61592d78fa (commitcomment-10668365)

This commit is contained in:
Federico Fissore
2015-04-13 12:22:37 +02:00
parent c740f251f4
commit b42c6667e1
4 changed files with 73 additions and 27 deletions

View File

@ -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 {