1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Now give error if code is too big for sketch; maximum size determined by upload.maximum_size preference.

This commit is contained in:
David A. Mellis
2006-03-20 23:14:10 +00:00
parent 74c0a80359
commit 518812a1e9
4 changed files with 119 additions and 0 deletions

View File

@ -1547,6 +1547,24 @@ public class Sketch {
//System.out.println("success = " + success + " ... " + primaryClassName);
return success ? primaryClassName : null;
}
protected void size(String buildPath, String suggestedClassName)
throws RunnerException {
long size = 0;
Sizer sizer = new Sizer(buildPath, suggestedClassName);
try {
size = sizer.computeSize();
System.out.println("Binary sketch size: " + size + " bytes (of a " +
Preferences.get("upload.maximum_size") + " byte maximum)");
} catch (RunnerException e) {
System.err.println("Couldn't determine program size: " + e.getMessage());
}
if (size > Preferences.getInteger("upload.maximum_size"))
throw new RunnerException(
"Sketch too big; try deleting code, removing floats, or see " +
"http://www.arduino.cc/en/Main/FAQ for more advice.");
}
protected String upload(String buildPath, String suggestedClassName)
throws RunnerException {
@ -1628,6 +1646,7 @@ public class Sketch {
// build the sketch
String foundName = build(target, appletFolder.getPath(), name);
size(appletFolder.getPath(), name);
foundName = upload(appletFolder.getPath(), name);
// (already reported) error during export, exit this function
if (foundName == null) return false;