mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-01 03:47:23 +03:00
Compiler: missing mandatory key now blocks compilation
This commit is contained in:
@ -1924,6 +1924,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
sketch.prepare();
|
sketch.prepare();
|
||||||
sketch.build(false);
|
sketch.build(false);
|
||||||
statusNotice(_("Done compiling."));
|
statusNotice(_("Done compiling."));
|
||||||
|
} catch (PreferencesMapException e) {
|
||||||
|
statusError(I18n.format(
|
||||||
|
_("Error while compiling: missing '{0}' configuration parameter"),
|
||||||
|
e.getMessage()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
status.unprogress();
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
@ -1941,6 +1945,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
sketch.prepare();
|
sketch.prepare();
|
||||||
sketch.build(true);
|
sketch.build(true);
|
||||||
statusNotice(_("Done compiling."));
|
statusNotice(_("Done compiling."));
|
||||||
|
} catch (PreferencesMapException e) {
|
||||||
|
statusError(I18n.format(
|
||||||
|
_("Error while compiling: missing '{0}' configuration parameter"),
|
||||||
|
e.getMessage()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
status.unprogress();
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
|
@ -29,6 +29,7 @@ import processing.app.debug.Compiler.ProgressListener;
|
|||||||
import processing.app.debug.RunnerException;
|
import processing.app.debug.RunnerException;
|
||||||
import processing.app.forms.PasswordAuthorizationDialog;
|
import processing.app.forms.PasswordAuthorizationDialog;
|
||||||
import processing.app.helpers.OSUtils;
|
import processing.app.helpers.OSUtils;
|
||||||
|
import processing.app.helpers.PreferencesMapException;
|
||||||
import processing.app.packages.Library;
|
import processing.app.packages.Library;
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
@ -1129,7 +1130,7 @@ public class Sketch {
|
|||||||
* @return null if compilation failed, main class name if not
|
* @return null if compilation failed, main class name if not
|
||||||
* @throws RunnerException
|
* @throws RunnerException
|
||||||
*/
|
*/
|
||||||
public String build(boolean verbose) throws RunnerException {
|
public String build(boolean verbose) throws RunnerException, PreferencesMapException {
|
||||||
return build(tempBuildFolder.getAbsolutePath(), verbose);
|
return build(tempBuildFolder.getAbsolutePath(), verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1142,7 +1143,7 @@ public class Sketch {
|
|||||||
*
|
*
|
||||||
* @return null if compilation failed, main class name if not
|
* @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
|
// run the preprocessor
|
||||||
editor.status.progressUpdate(20);
|
editor.status.progressUpdate(20);
|
||||||
|
|
||||||
|
@ -49,10 +49,7 @@ import processing.app.I18n;
|
|||||||
import processing.app.PreferencesData;
|
import processing.app.PreferencesData;
|
||||||
import processing.app.SketchCode;
|
import processing.app.SketchCode;
|
||||||
import processing.app.SketchData;
|
import processing.app.SketchData;
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.*;
|
||||||
import processing.app.helpers.PreferencesMap;
|
|
||||||
import processing.app.helpers.ProcessUtils;
|
|
||||||
import processing.app.helpers.StringReplacer;
|
|
||||||
import processing.app.helpers.filefilters.OnlyDirs;
|
import processing.app.helpers.filefilters.OnlyDirs;
|
||||||
import processing.app.packages.Library;
|
import processing.app.packages.Library;
|
||||||
import processing.app.packages.LibraryList;
|
import processing.app.packages.LibraryList;
|
||||||
@ -86,7 +83,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
private ProgressListener progressListener;
|
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)
|
if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
|
||||||
BaseNoGui.showError(_("Bad file selected"),
|
BaseNoGui.showError(_("Bad file selected"),
|
||||||
_("Bad sketch primary file or bad sketck directory structure"), null);
|
_("Bad sketch primary file or bad sketck directory structure"), null);
|
||||||
@ -338,12 +335,12 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile sketch.
|
* Compile sketch.
|
||||||
* @param buildPath
|
* @param _verbose
|
||||||
*
|
*
|
||||||
* @return true if successful.
|
* @return true if successful.
|
||||||
* @throws RunnerException Only if there's a problem. Only then.
|
* @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"));
|
preprocess(prefs.get("build.path"));
|
||||||
|
|
||||||
verbose = _verbose || PreferencesData.getBoolean("build.verbose");
|
verbose = _verbose || PreferencesData.getBoolean("build.verbose");
|
||||||
@ -505,7 +502,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
private List<File> compileFiles(File outputPath, File sourcePath,
|
private List<File> compileFiles(File outputPath, File sourcePath,
|
||||||
boolean recurse, List<File> includeFolders)
|
boolean recurse, List<File> includeFolders)
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
List<File> sSources = findFilesInFolder(sourcePath, "S", recurse);
|
List<File> sSources = findFilesInFolder(sourcePath, "S", recurse);
|
||||||
List<File> cSources = findFilesInFolder(sourcePath, "c", recurse);
|
List<File> cSources = findFilesInFolder(sourcePath, "c", recurse);
|
||||||
List<File> cppSources = findFilesInFolder(sourcePath, "cpp", 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)
|
* 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
|
||||||
*
|
*
|
||||||
* @param dep
|
* @param line
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected static String unescapeDepFile(String line) {
|
protected static String unescapeDepFile(String line) {
|
||||||
@ -816,7 +813,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
private String[] getCommandCompilerS(List<File> includeFolders,
|
private String[] getCommandCompilerS(List<File> includeFolders,
|
||||||
File sourceFile, File objectFile)
|
File sourceFile, File objectFile)
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
String includes = prepareIncludes(includeFolders);
|
String includes = prepareIncludes(includeFolders);
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||||
@ -824,8 +821,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
dict.put("source_file", sourceFile.getAbsolutePath());
|
dict.put("source_file", sourceFile.getAbsolutePath());
|
||||||
dict.put("object_file", objectFile.getAbsolutePath());
|
dict.put("object_file", objectFile.getAbsolutePath());
|
||||||
|
|
||||||
|
String cmd = prefs.getOrExcept("recipe.S.o.pattern");
|
||||||
try {
|
try {
|
||||||
String cmd = prefs.get("recipe.S.o.pattern");
|
|
||||||
return StringReplacer.formatAndSplit(cmd, dict, true);
|
return StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RunnerException(e);
|
throw new RunnerException(e);
|
||||||
@ -834,7 +831,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
private String[] getCommandCompilerC(List<File> includeFolders,
|
private String[] getCommandCompilerC(List<File> includeFolders,
|
||||||
File sourceFile, File objectFile)
|
File sourceFile, File objectFile)
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
String includes = prepareIncludes(includeFolders);
|
String includes = prepareIncludes(includeFolders);
|
||||||
|
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
@ -843,7 +840,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
dict.put("source_file", sourceFile.getAbsolutePath());
|
dict.put("source_file", sourceFile.getAbsolutePath());
|
||||||
dict.put("object_file", objectFile.getAbsolutePath());
|
dict.put("object_file", objectFile.getAbsolutePath());
|
||||||
|
|
||||||
String cmd = prefs.get("recipe.c.o.pattern");
|
String cmd = prefs.getOrExcept("recipe.c.o.pattern");
|
||||||
try {
|
try {
|
||||||
return StringReplacer.formatAndSplit(cmd, dict, true);
|
return StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -853,7 +850,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
private String[] getCommandCompilerCPP(List<File> includeFolders,
|
private String[] getCommandCompilerCPP(List<File> includeFolders,
|
||||||
File sourceFile, File objectFile)
|
File sourceFile, File objectFile)
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
String includes = prepareIncludes(includeFolders);
|
String includes = prepareIncludes(includeFolders);
|
||||||
|
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
@ -862,7 +859,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
dict.put("source_file", sourceFile.getAbsolutePath());
|
dict.put("source_file", sourceFile.getAbsolutePath());
|
||||||
dict.put("object_file", objectFile.getAbsolutePath());
|
dict.put("object_file", objectFile.getAbsolutePath());
|
||||||
|
|
||||||
String cmd = prefs.get("recipe.cpp.o.pattern");
|
String cmd = prefs.getOrExcept("recipe.cpp.o.pattern");
|
||||||
try {
|
try {
|
||||||
return StringReplacer.formatAndSplit(cmd, dict, true);
|
return StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -909,21 +906,21 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 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");
|
File buildPath = prefs.getFile("build.path");
|
||||||
objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders));
|
objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to:
|
// 2. compile the libraries, outputting .o files to:
|
||||||
// <buildPath>/<library>/
|
// <buildPath>/<library>/
|
||||||
void compileLibraries(List<File> includeFolders) throws RunnerException {
|
void compileLibraries(List<File> includeFolders) throws RunnerException, PreferencesMapException {
|
||||||
for (Library lib : importedLibraries) {
|
for (Library lib : importedLibraries) {
|
||||||
compileLibrary(lib, includeFolders);
|
compileLibrary(lib, includeFolders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compileLibrary(Library lib, List<File> includeFolders)
|
private void compileLibrary(Library lib, List<File> includeFolders)
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
File libFolder = lib.getSrcFolder();
|
File libFolder = lib.getSrcFolder();
|
||||||
File libBuildFolder = prefs.getFile(("build.path"), lib.getName());
|
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);
|
compileFilesInFolder(srcBuildFolder, srcFolder, includeFolders);
|
||||||
for (File subFolder : srcFolder.listFiles(new OnlyDirs())) {
|
for (File subFolder : srcFolder.listFiles(new OnlyDirs())) {
|
||||||
File subBuildFolder = new File(srcBuildFolder, subFolder.getName());
|
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);
|
createFolder(buildFolder);
|
||||||
List<File> objects = compileFiles(buildFolder, srcFolder, false, includeFolders);
|
List<File> objects = compileFiles(buildFolder, srcFolder, false, includeFolders);
|
||||||
objectFiles.addAll(objects);
|
objectFiles.addAll(objects);
|
||||||
@ -968,7 +965,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
// Also compiles the variant (if it supplies actual source files),
|
// Also compiles the variant (if it supplies actual source files),
|
||||||
// which are included in the link directly (not through core.a)
|
// which are included in the link directly (not through core.a)
|
||||||
void compileCore()
|
void compileCore()
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
|
|
||||||
File coreFolder = prefs.getFile("build.core.path");
|
File coreFolder = prefs.getFile("build.core.path");
|
||||||
File variantFolder = prefs.getFile("build.variant.path");
|
File variantFolder = prefs.getFile("build.variant.path");
|
||||||
@ -1024,8 +1021,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
dict.put("object_file", file.getAbsolutePath());
|
dict.put("object_file", file.getAbsolutePath());
|
||||||
|
|
||||||
String[] cmdArray;
|
String[] cmdArray;
|
||||||
|
String cmd = prefs.getOrExcept("recipe.ar.pattern");
|
||||||
try {
|
try {
|
||||||
String cmd = prefs.get("recipe.ar.pattern");
|
|
||||||
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RunnerException(e);
|
throw new RunnerException(e);
|
||||||
@ -1040,7 +1037,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
void compileLink()
|
void compileLink()
|
||||||
throws RunnerException {
|
throws RunnerException, PreferencesMapException {
|
||||||
|
|
||||||
// TODO: Make the --relax thing in configuration files.
|
// TODO: Make the --relax thing in configuration files.
|
||||||
|
|
||||||
@ -1063,8 +1060,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||||
|
|
||||||
String[] cmdArray;
|
String[] cmdArray;
|
||||||
|
String cmd = prefs.getOrExcept("recipe.c.combine.pattern");
|
||||||
try {
|
try {
|
||||||
String cmd = prefs.get("recipe.c.combine.pattern");
|
|
||||||
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RunnerException(e);
|
throw new RunnerException(e);
|
||||||
@ -1073,13 +1070,13 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
||||||
void compileEep() throws RunnerException {
|
void compileEep() throws RunnerException, PreferencesMapException {
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||||
|
|
||||||
String[] cmdArray;
|
String[] cmdArray;
|
||||||
|
String cmd = prefs.getOrExcept("recipe.objcopy.eep.pattern");
|
||||||
try {
|
try {
|
||||||
String cmd = prefs.get("recipe.objcopy.eep.pattern");
|
|
||||||
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RunnerException(e);
|
throw new RunnerException(e);
|
||||||
@ -1088,13 +1085,13 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 6. build the .hex file
|
// 6. build the .hex file
|
||||||
void compileHex() throws RunnerException {
|
void compileHex() throws RunnerException, PreferencesMapException {
|
||||||
PreferencesMap dict = new PreferencesMap(prefs);
|
PreferencesMap dict = new PreferencesMap(prefs);
|
||||||
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
dict.put("ide_version", "" + BaseNoGui.REVISION);
|
||||||
|
|
||||||
String[] cmdArray;
|
String[] cmdArray;
|
||||||
|
String cmd = prefs.getOrExcept("recipe.objcopy.hex.pattern");
|
||||||
try {
|
try {
|
||||||
String cmd = prefs.get("recipe.objcopy.hex.pattern");
|
|
||||||
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RunnerException(e);
|
throw new RunnerException(e);
|
||||||
|
Reference in New Issue
Block a user