1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

Compiler: missing mandatory key now blocks compilation

This commit is contained in:
Federico Fissore 2015-01-08 13:45:17 +01:00
parent 20ac20f629
commit 980709f6f7
3 changed files with 36 additions and 30 deletions

View File

@ -1924,6 +1924,10 @@ public class Editor extends JFrame implements RunnerListener {
sketch.prepare();
sketch.build(false);
statusNotice(_("Done compiling."));
} catch (PreferencesMapException e) {
statusError(I18n.format(
_("Error while compiling: missing '{0}' configuration parameter"),
e.getMessage()));
} catch (Exception e) {
status.unprogress();
statusError(e);
@ -1941,6 +1945,10 @@ public class Editor extends JFrame implements RunnerListener {
sketch.prepare();
sketch.build(true);
statusNotice(_("Done compiling."));
} catch (PreferencesMapException e) {
statusError(I18n.format(
_("Error while compiling: missing '{0}' configuration parameter"),
e.getMessage()));
} catch (Exception e) {
status.unprogress();
statusError(e);

View File

@ -29,6 +29,7 @@ import processing.app.debug.Compiler.ProgressListener;
import processing.app.debug.RunnerException;
import processing.app.forms.PasswordAuthorizationDialog;
import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMapException;
import processing.app.packages.Library;
import static processing.app.I18n._;
@ -1129,7 +1130,7 @@ public class Sketch {
* @return null if compilation failed, main class name if not
* @throws RunnerException
*/
public String build(boolean verbose) throws RunnerException {
public String build(boolean verbose) throws RunnerException, PreferencesMapException {
return build(tempBuildFolder.getAbsolutePath(), verbose);
}
@ -1142,7 +1143,7 @@ public class Sketch {
*
* @return null if compilation failed, main class name if not
*/
public String build(String buildPath, boolean verbose) throws RunnerException {
public String build(String buildPath, boolean verbose) throws RunnerException, PreferencesMapException {
// run the preprocessor
editor.status.progressUpdate(20);

View File

@ -49,10 +49,7 @@ import processing.app.I18n;
import processing.app.PreferencesData;
import processing.app.SketchCode;
import processing.app.SketchData;
import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringReplacer;
import processing.app.helpers.*;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.packages.Library;
import processing.app.packages.LibraryList;
@ -86,7 +83,7 @@ public class Compiler implements MessageConsumer {
private ProgressListener progressListener;
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException, PreferencesMapException {
if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
BaseNoGui.showError(_("Bad file selected"),
_("Bad sketch primary file or bad sketck directory structure"), null);
@ -338,12 +335,12 @@ public class Compiler implements MessageConsumer {
/**
* Compile sketch.
* @param buildPath
* @param _verbose
*
* @return true if successful.
* @throws RunnerException Only if there's a problem. Only then.
*/
public boolean compile(boolean _verbose) throws RunnerException {
public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapException {
preprocess(prefs.get("build.path"));
verbose = _verbose || PreferencesData.getBoolean("build.verbose");
@ -505,7 +502,7 @@ public class Compiler implements MessageConsumer {
private List<File> compileFiles(File outputPath, File sourcePath,
boolean recurse, List<File> includeFolders)
throws RunnerException {
throws RunnerException, PreferencesMapException {
List<File> sSources = findFilesInFolder(sourcePath, "S", recurse);
List<File> cSources = findFilesInFolder(sourcePath, "c", recurse);
List<File> cppSources = findFilesInFolder(sourcePath, "cpp", recurse);
@ -545,7 +542,7 @@ public class Compiler implements MessageConsumer {
* Strip escape sequences used in makefile dependency files (.d)
* https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845
*
* @param dep
* @param line
* @return
*/
protected static String unescapeDepFile(String line) {
@ -816,7 +813,7 @@ public class Compiler implements MessageConsumer {
private String[] getCommandCompilerS(List<File> includeFolders,
File sourceFile, File objectFile)
throws RunnerException {
throws RunnerException, PreferencesMapException {
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);
@ -824,8 +821,8 @@ public class Compiler implements MessageConsumer {
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
String cmd = prefs.getOrExcept("recipe.S.o.pattern");
try {
String cmd = prefs.get("recipe.S.o.pattern");
return StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
throw new RunnerException(e);
@ -834,7 +831,7 @@ public class Compiler implements MessageConsumer {
private String[] getCommandCompilerC(List<File> includeFolders,
File sourceFile, File objectFile)
throws RunnerException {
throws RunnerException, PreferencesMapException {
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
@ -843,7 +840,7 @@ public class Compiler implements MessageConsumer {
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
String cmd = prefs.get("recipe.c.o.pattern");
String cmd = prefs.getOrExcept("recipe.c.o.pattern");
try {
return StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
@ -853,7 +850,7 @@ public class Compiler implements MessageConsumer {
private String[] getCommandCompilerCPP(List<File> includeFolders,
File sourceFile, File objectFile)
throws RunnerException {
throws RunnerException, PreferencesMapException {
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
@ -862,7 +859,7 @@ public class Compiler implements MessageConsumer {
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
String cmd = prefs.get("recipe.cpp.o.pattern");
String cmd = prefs.getOrExcept("recipe.cpp.o.pattern");
try {
return StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
@ -909,21 +906,21 @@ public class Compiler implements MessageConsumer {
}
// 1. compile the sketch (already in the buildPath)
void compileSketch(List<File> includeFolders) throws RunnerException {
void compileSketch(List<File> includeFolders) throws RunnerException, PreferencesMapException {
File buildPath = prefs.getFile("build.path");
objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders));
}
// 2. compile the libraries, outputting .o files to:
// <buildPath>/<library>/
void compileLibraries(List<File> includeFolders) throws RunnerException {
void compileLibraries(List<File> includeFolders) throws RunnerException, PreferencesMapException {
for (Library lib : importedLibraries) {
compileLibrary(lib, includeFolders);
}
}
private void compileLibrary(Library lib, List<File> includeFolders)
throws RunnerException {
throws RunnerException, PreferencesMapException {
File libFolder = lib.getSrcFolder();
File libBuildFolder = prefs.getFile(("build.path"), lib.getName());
@ -949,7 +946,7 @@ public class Compiler implements MessageConsumer {
}
}
private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List<File> includeFolders) throws RunnerException, PreferencesMapException {
compileFilesInFolder(srcBuildFolder, srcFolder, includeFolders);
for (File subFolder : srcFolder.listFiles(new OnlyDirs())) {
File subBuildFolder = new File(srcBuildFolder, subFolder.getName());
@ -957,7 +954,7 @@ public class Compiler implements MessageConsumer {
}
}
private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> includeFolders) throws RunnerException, PreferencesMapException {
createFolder(buildFolder);
List<File> objects = compileFiles(buildFolder, srcFolder, false, includeFolders);
objectFiles.addAll(objects);
@ -968,7 +965,7 @@ public class Compiler implements MessageConsumer {
// Also compiles the variant (if it supplies actual source files),
// which are included in the link directly (not through core.a)
void compileCore()
throws RunnerException {
throws RunnerException, PreferencesMapException {
File coreFolder = prefs.getFile("build.core.path");
File variantFolder = prefs.getFile("build.variant.path");
@ -1024,8 +1021,8 @@ public class Compiler implements MessageConsumer {
dict.put("object_file", file.getAbsolutePath());
String[] cmdArray;
String cmd = prefs.getOrExcept("recipe.ar.pattern");
try {
String cmd = prefs.get("recipe.ar.pattern");
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
throw new RunnerException(e);
@ -1040,7 +1037,7 @@ public class Compiler implements MessageConsumer {
// 4. link it all together into the .elf file
void compileLink()
throws RunnerException {
throws RunnerException, PreferencesMapException {
// TODO: Make the --relax thing in configuration files.
@ -1063,8 +1060,8 @@ public class Compiler implements MessageConsumer {
dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
String cmd = prefs.getOrExcept("recipe.c.combine.pattern");
try {
String cmd = prefs.get("recipe.c.combine.pattern");
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
throw new RunnerException(e);
@ -1073,13 +1070,13 @@ public class Compiler implements MessageConsumer {
}
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
void compileEep() throws RunnerException {
void compileEep() throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
String cmd = prefs.getOrExcept("recipe.objcopy.eep.pattern");
try {
String cmd = prefs.get("recipe.objcopy.eep.pattern");
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
throw new RunnerException(e);
@ -1088,13 +1085,13 @@ public class Compiler implements MessageConsumer {
}
// 6. build the .hex file
void compileHex() throws RunnerException {
void compileHex() throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
String cmd = prefs.getOrExcept("recipe.objcopy.hex.pattern");
try {
String cmd = prefs.get("recipe.objcopy.hex.pattern");
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
} catch (Exception e) {
throw new RunnerException(e);