Skip to content

Commit 980709f

Browse files
author
Federico Fissore
committed
Compiler: missing mandatory key now blocks compilation
1 parent 20ac20f commit 980709f

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

app/src/processing/app/Editor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,10 @@ public void run() {
19241924
sketch.prepare();
19251925
sketch.build(false);
19261926
statusNotice(_("Done compiling."));
1927+
} catch (PreferencesMapException e) {
1928+
statusError(I18n.format(
1929+
_("Error while compiling: missing '{0}' configuration parameter"),
1930+
e.getMessage()));
19271931
} catch (Exception e) {
19281932
status.unprogress();
19291933
statusError(e);
@@ -1941,6 +1945,10 @@ public void run() {
19411945
sketch.prepare();
19421946
sketch.build(true);
19431947
statusNotice(_("Done compiling."));
1948+
} catch (PreferencesMapException e) {
1949+
statusError(I18n.format(
1950+
_("Error while compiling: missing '{0}' configuration parameter"),
1951+
e.getMessage()));
19441952
} catch (Exception e) {
19451953
status.unprogress();
19461954
statusError(e);

app/src/processing/app/Sketch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import processing.app.debug.RunnerException;
3030
import processing.app.forms.PasswordAuthorizationDialog;
3131
import processing.app.helpers.OSUtils;
32+
import processing.app.helpers.PreferencesMapException;
3233
import processing.app.packages.Library;
3334
import static processing.app.I18n._;
3435

@@ -1129,7 +1130,7 @@ public void prepare() throws IOException {
11291130
* @return null if compilation failed, main class name if not
11301131
* @throws RunnerException
11311132
*/
1132-
public String build(boolean verbose) throws RunnerException {
1133+
public String build(boolean verbose) throws RunnerException, PreferencesMapException {
11331134
return build(tempBuildFolder.getAbsolutePath(), verbose);
11341135
}
11351136

@@ -1142,7 +1143,7 @@ public String build(boolean verbose) throws RunnerException {
11421143
*
11431144
* @return null if compilation failed, main class name if not
11441145
*/
1145-
public String build(String buildPath, boolean verbose) throws RunnerException {
1146+
public String build(String buildPath, boolean verbose) throws RunnerException, PreferencesMapException {
11461147
// run the preprocessor
11471148
editor.status.progressUpdate(20);
11481149

arduino-core/src/processing/app/debug/Compiler.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@
4949
import processing.app.PreferencesData;
5050
import processing.app.SketchCode;
5151
import processing.app.SketchData;
52-
import processing.app.helpers.FileUtils;
53-
import processing.app.helpers.PreferencesMap;
54-
import processing.app.helpers.ProcessUtils;
55-
import processing.app.helpers.StringReplacer;
52+
import processing.app.helpers.*;
5653
import processing.app.helpers.filefilters.OnlyDirs;
5754
import processing.app.packages.Library;
5855
import processing.app.packages.LibraryList;
@@ -86,7 +83,7 @@ public interface ProgressListener {
8683

8784
private ProgressListener progressListener;
8885

89-
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
86+
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException, PreferencesMapException {
9087
if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
9188
BaseNoGui.showError(_("Bad file selected"),
9289
_("Bad sketch primary file or bad sketck directory structure"), null);
@@ -338,12 +335,12 @@ protected void size(PreferencesMap prefs) throws RunnerException {
338335

339336
/**
340337
* Compile sketch.
341-
* @param buildPath
338+
* @param _verbose
342339
*
343340
* @return true if successful.
344341
* @throws RunnerException Only if there's a problem. Only then.
345342
*/
346-
public boolean compile(boolean _verbose) throws RunnerException {
343+
public boolean compile(boolean _verbose) throws RunnerException, PreferencesMapException {
347344
preprocess(prefs.get("build.path"));
348345

349346
verbose = _verbose || PreferencesData.getBoolean("build.verbose");
@@ -505,7 +502,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
505502

506503
private List<File> compileFiles(File outputPath, File sourcePath,
507504
boolean recurse, List<File> includeFolders)
508-
throws RunnerException {
505+
throws RunnerException, PreferencesMapException {
509506
List<File> sSources = findFilesInFolder(sourcePath, "S", recurse);
510507
List<File> cSources = findFilesInFolder(sourcePath, "c", recurse);
511508
List<File> cppSources = findFilesInFolder(sourcePath, "cpp", recurse);
@@ -545,7 +542,7 @@ private List<File> compileFiles(File outputPath, File sourcePath,
545542
* Strip escape sequences used in makefile dependency files (.d)
546543
* https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845
547544
*
548-
* @param dep
545+
* @param line
549546
* @return
550547
*/
551548
protected static String unescapeDepFile(String line) {
@@ -816,16 +813,16 @@ public void message(String s) {
816813

817814
private String[] getCommandCompilerS(List<File> includeFolders,
818815
File sourceFile, File objectFile)
819-
throws RunnerException {
816+
throws RunnerException, PreferencesMapException {
820817
String includes = prepareIncludes(includeFolders);
821818
PreferencesMap dict = new PreferencesMap(prefs);
822819
dict.put("ide_version", "" + BaseNoGui.REVISION);
823820
dict.put("includes", includes);
824821
dict.put("source_file", sourceFile.getAbsolutePath());
825822
dict.put("object_file", objectFile.getAbsolutePath());
826823

824+
String cmd = prefs.getOrExcept("recipe.S.o.pattern");
827825
try {
828-
String cmd = prefs.get("recipe.S.o.pattern");
829826
return StringReplacer.formatAndSplit(cmd, dict, true);
830827
} catch (Exception e) {
831828
throw new RunnerException(e);
@@ -834,7 +831,7 @@ private String[] getCommandCompilerS(List<File> includeFolders,
834831

835832
private String[] getCommandCompilerC(List<File> includeFolders,
836833
File sourceFile, File objectFile)
837-
throws RunnerException {
834+
throws RunnerException, PreferencesMapException {
838835
String includes = prepareIncludes(includeFolders);
839836

840837
PreferencesMap dict = new PreferencesMap(prefs);
@@ -843,7 +840,7 @@ private String[] getCommandCompilerC(List<File> includeFolders,
843840
dict.put("source_file", sourceFile.getAbsolutePath());
844841
dict.put("object_file", objectFile.getAbsolutePath());
845842

846-
String cmd = prefs.get("recipe.c.o.pattern");
843+
String cmd = prefs.getOrExcept("recipe.c.o.pattern");
847844
try {
848845
return StringReplacer.formatAndSplit(cmd, dict, true);
849846
} catch (Exception e) {
@@ -853,7 +850,7 @@ private String[] getCommandCompilerC(List<File> includeFolders,
853850

854851
private String[] getCommandCompilerCPP(List<File> includeFolders,
855852
File sourceFile, File objectFile)
856-
throws RunnerException {
853+
throws RunnerException, PreferencesMapException {
857854
String includes = prepareIncludes(includeFolders);
858855

859856
PreferencesMap dict = new PreferencesMap(prefs);
@@ -862,7 +859,7 @@ private String[] getCommandCompilerCPP(List<File> includeFolders,
862859
dict.put("source_file", sourceFile.getAbsolutePath());
863860
dict.put("object_file", objectFile.getAbsolutePath());
864861

865-
String cmd = prefs.get("recipe.cpp.o.pattern");
862+
String cmd = prefs.getOrExcept("recipe.cpp.o.pattern");
866863
try {
867864
return StringReplacer.formatAndSplit(cmd, dict, true);
868865
} catch (Exception e) {
@@ -909,21 +906,21 @@ static public List<File> findFilesInFolder(File folder, String extension,
909906
}
910907

911908
// 1. compile the sketch (already in the buildPath)
912-
void compileSketch(List<File> includeFolders) throws RunnerException {
909+
void compileSketch(List<File> includeFolders) throws RunnerException, PreferencesMapException {
913910
File buildPath = prefs.getFile("build.path");
914911
objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders));
915912
}
916913

917914
// 2. compile the libraries, outputting .o files to:
918915
// <buildPath>/<library>/
919-
void compileLibraries(List<File> includeFolders) throws RunnerException {
916+
void compileLibraries(List<File> includeFolders) throws RunnerException, PreferencesMapException {
920917
for (Library lib : importedLibraries) {
921918
compileLibrary(lib, includeFolders);
922919
}
923920
}
924921

925922
private void compileLibrary(Library lib, List<File> includeFolders)
926-
throws RunnerException {
923+
throws RunnerException, PreferencesMapException {
927924
File libFolder = lib.getSrcFolder();
928925
File libBuildFolder = prefs.getFile(("build.path"), lib.getName());
929926

@@ -949,15 +946,15 @@ private void compileLibrary(Library lib, List<File> includeFolders)
949946
}
950947
}
951948

952-
private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
949+
private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List<File> includeFolders) throws RunnerException, PreferencesMapException {
953950
compileFilesInFolder(srcBuildFolder, srcFolder, includeFolders);
954951
for (File subFolder : srcFolder.listFiles(new OnlyDirs())) {
955952
File subBuildFolder = new File(srcBuildFolder, subFolder.getName());
956953
recursiveCompileFilesInFolder(subBuildFolder, subFolder, includeFolders);
957954
}
958955
}
959956

960-
private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
957+
private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> includeFolders) throws RunnerException, PreferencesMapException {
961958
createFolder(buildFolder);
962959
List<File> objects = compileFiles(buildFolder, srcFolder, false, includeFolders);
963960
objectFiles.addAll(objects);
@@ -968,7 +965,7 @@ private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> i
968965
// Also compiles the variant (if it supplies actual source files),
969966
// which are included in the link directly (not through core.a)
970967
void compileCore()
971-
throws RunnerException {
968+
throws RunnerException, PreferencesMapException {
972969

973970
File coreFolder = prefs.getFile("build.core.path");
974971
File variantFolder = prefs.getFile("build.variant.path");
@@ -1024,8 +1021,8 @@ void compileCore()
10241021
dict.put("object_file", file.getAbsolutePath());
10251022

10261023
String[] cmdArray;
1024+
String cmd = prefs.getOrExcept("recipe.ar.pattern");
10271025
try {
1028-
String cmd = prefs.get("recipe.ar.pattern");
10291026
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
10301027
} catch (Exception e) {
10311028
throw new RunnerException(e);
@@ -1040,7 +1037,7 @@ void compileCore()
10401037

10411038
// 4. link it all together into the .elf file
10421039
void compileLink()
1043-
throws RunnerException {
1040+
throws RunnerException, PreferencesMapException {
10441041

10451042
// TODO: Make the --relax thing in configuration files.
10461043

@@ -1063,8 +1060,8 @@ void compileLink()
10631060
dict.put("ide_version", "" + BaseNoGui.REVISION);
10641061

10651062
String[] cmdArray;
1063+
String cmd = prefs.getOrExcept("recipe.c.combine.pattern");
10661064
try {
1067-
String cmd = prefs.get("recipe.c.combine.pattern");
10681065
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
10691066
} catch (Exception e) {
10701067
throw new RunnerException(e);
@@ -1073,13 +1070,13 @@ void compileLink()
10731070
}
10741071

10751072
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
1076-
void compileEep() throws RunnerException {
1073+
void compileEep() throws RunnerException, PreferencesMapException {
10771074
PreferencesMap dict = new PreferencesMap(prefs);
10781075
dict.put("ide_version", "" + BaseNoGui.REVISION);
10791076

10801077
String[] cmdArray;
1078+
String cmd = prefs.getOrExcept("recipe.objcopy.eep.pattern");
10811079
try {
1082-
String cmd = prefs.get("recipe.objcopy.eep.pattern");
10831080
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
10841081
} catch (Exception e) {
10851082
throw new RunnerException(e);
@@ -1088,13 +1085,13 @@ void compileEep() throws RunnerException {
10881085
}
10891086

10901087
// 6. build the .hex file
1091-
void compileHex() throws RunnerException {
1088+
void compileHex() throws RunnerException, PreferencesMapException {
10921089
PreferencesMap dict = new PreferencesMap(prefs);
10931090
dict.put("ide_version", "" + BaseNoGui.REVISION);
10941091

10951092
String[] cmdArray;
1093+
String cmd = prefs.getOrExcept("recipe.objcopy.hex.pattern");
10961094
try {
1097-
String cmd = prefs.get("recipe.objcopy.hex.pattern");
10981095
cmdArray = StringReplacer.formatAndSplit(cmd, dict, true);
10991096
} catch (Exception e) {
11001097
throw new RunnerException(e);

0 commit comments

Comments
 (0)