Skip to content

Commit 3e31777

Browse files
committed
Merge branch 'master' into new-extension
2 parents f0925c7 + 53f3e8e commit 3e31777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6940
-424
lines changed

app/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
excludes="**/tools/format/**"
4444
encoding="UTF-8"
4545
includeAntRuntime="false"
46+
debug="true"
4647
classpath="../core/core.jar; ${env.JAVA_HOME}/lib/tools.jar; lib/ant.jar; lib/ant-launcher.jar; lib/apple.jar; lib/ecj.jar; lib/jna.jar; lib/RXTXcomm.jar" />
4748
</target>
4849

app/src/processing/app/Base.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
* files and images, etc) that comes from that.
4242
*/
4343
public class Base {
44-
public static final int REVISION = 21;
44+
public static final int REVISION = 22;
4545
/** This might be replaced by main() if there's a lib/version.txt file. */
46-
static String VERSION_NAME = "0021";
46+
static String VERSION_NAME = "0022";
4747
/** Set true if this a proper release rather than a numbered revision. */
4848
static public boolean RELEASE = false;
4949

app/src/processing/app/Editor.java

+58-18
Original file line numberDiff line numberDiff line change
@@ -898,23 +898,7 @@ class SerialMenuListener implements ActionListener {
898898
//public SerialMenuListener() { }
899899

900900
public void actionPerformed(ActionEvent e) {
901-
if(serialMenu == null) {
902-
System.out.println("serialMenu is null");
903-
return;
904-
}
905-
int count = serialMenu.getItemCount();
906-
for (int i = 0; i < count; i++) {
907-
((JCheckBoxMenuItem)serialMenu.getItem(i)).setState(false);
908-
}
909-
JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource();
910-
item.setState(true);
911-
String name = item.getText();
912-
//System.out.println(item.getLabel());
913-
Preferences.set("serial.port", name);
914-
serialMonitor.closeSerialPort();
915-
serialMonitor.setVisible(false);
916-
serialMonitor = new SerialMonitor(Preferences.get("serial.port"));
917-
//System.out.println("set to " + get("serial.port"));
901+
selectSerialPort(((JCheckBoxMenuItem)e.getSource()).getText());
918902
}
919903

920904
/*
@@ -929,7 +913,35 @@ public void actionPerformed(ActionEvent e) {
929913
*/
930914
}
931915

932-
916+
protected void selectSerialPort(String name) {
917+
if(serialMenu == null) {
918+
System.out.println("serialMenu is null");
919+
return;
920+
}
921+
if (name == null) {
922+
System.out.println("name is null");
923+
return;
924+
}
925+
JCheckBoxMenuItem selection = null;
926+
for (int i = 0; i < serialMenu.getItemCount(); i++) {
927+
JCheckBoxMenuItem item = ((JCheckBoxMenuItem)serialMenu.getItem(i));
928+
if (item == null) {
929+
System.out.println("name is null");
930+
continue;
931+
}
932+
item.setState(false);
933+
if (name.equals(item.getText())) selection = item;
934+
}
935+
if (selection != null) selection.setState(true);
936+
//System.out.println(item.getLabel());
937+
Preferences.set("serial.port", name);
938+
serialMonitor.closeSerialPort();
939+
serialMonitor.setVisible(false);
940+
serialMonitor = new SerialMonitor(Preferences.get("serial.port"));
941+
//System.out.println("set to " + get("serial.port"));
942+
}
943+
944+
933945
protected void populateSerialMenu() {
934946
// getting list of ports
935947

@@ -2269,6 +2281,31 @@ public boolean handleSaveAs() {
22692281

22702282
return true;
22712283
}
2284+
2285+
2286+
public boolean serialPrompt() {
2287+
populateSerialMenu();
2288+
int count = serialMenu.getItemCount();
2289+
Object[] names = new Object[count];
2290+
for (int i = 0; i < count; i++) {
2291+
names[i] = ((JCheckBoxMenuItem)serialMenu.getItem(i)).getText();
2292+
}
2293+
2294+
String result = (String)
2295+
JOptionPane.showInputDialog(this,
2296+
"Serial port " +
2297+
Preferences.get("serial.port") +
2298+
" not found.\n" +
2299+
"Retry the upload with another serial port?",
2300+
"Serial port not found",
2301+
JOptionPane.PLAIN_MESSAGE,
2302+
null,
2303+
names,
2304+
0);
2305+
if (result == null) return false;
2306+
selectSerialPort(result);
2307+
return true;
2308+
}
22722309

22732310

22742311
/**
@@ -2311,6 +2348,9 @@ public void run() {
23112348
} else {
23122349
// error message will already be visible
23132350
}
2351+
} catch (SerialNotFoundException e) {
2352+
if (serialPrompt()) run();
2353+
else statusNotice("Upload canceled.");
23142354
} catch (RunnerException e) {
23152355
//statusError("Error during upload.");
23162356
//e.printStackTrace();

app/src/processing/app/Serial.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public Serial(String iname, int irate,
150150
}
151151

152152
if (port == null) {
153-
throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?");
153+
throw new SerialNotFoundException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?");
154154
}
155155
}
156156

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Copyright (c) 2007 David A. Mellis
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation,
18+
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+
*/
20+
21+
package processing.app;
22+
23+
public class SerialNotFoundException extends SerialException {
24+
public SerialNotFoundException() {
25+
super();
26+
}
27+
28+
public SerialNotFoundException(String message) {
29+
super(message);
30+
}
31+
32+
public SerialNotFoundException(String message, Throwable cause) {
33+
super(message, cause);
34+
}
35+
36+
public SerialNotFoundException(Throwable cause) {
37+
super(cause);
38+
}
39+
}

app/src/processing/app/Sketch.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1518,8 +1518,8 @@ public String build(String buildPath, boolean verbose)
15181518
}
15191519
return null;
15201520
}
1521-
1522-
1521+
1522+
15231523
protected boolean exportApplet(boolean verbose) throws Exception {
15241524
return exportApplet(tempBuildFolder.getAbsolutePath(), verbose);
15251525
}
@@ -1529,7 +1529,7 @@ protected boolean exportApplet(boolean verbose) throws Exception {
15291529
* Handle export to applet.
15301530
*/
15311531
public boolean exportApplet(String appletPath, boolean verbose)
1532-
throws RunnerException, IOException {
1532+
throws RunnerException, IOException, SerialException {
15331533

15341534
// Make sure the user didn't hide the sketch folder
15351535
ensureExistence();
@@ -1566,7 +1566,7 @@ public boolean exportApplet(String appletPath, boolean verbose)
15661566
// }
15671567

15681568
upload(appletFolder.getPath(), foundName, verbose);
1569-
1569+
15701570
return true;
15711571
}
15721572

@@ -1593,7 +1593,7 @@ protected void size(String buildPath, String suggestedClassName)
15931593

15941594

15951595
protected String upload(String buildPath, String suggestedClassName, boolean verbose)
1596-
throws RunnerException {
1596+
throws RunnerException, SerialException {
15971597

15981598
Uploader uploader;
15991599

app/src/processing/app/debug/AvrdudeUploader.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import processing.app.Base;
3030
import processing.app.Preferences;
3131
import processing.app.Serial;
32+
import processing.app.SerialException;
3233

3334
import java.io.*;
3435
import java.util.*;
@@ -43,7 +44,7 @@ public AvrdudeUploader() {
4344

4445
// XXX: add support for uploading sketches using a programmer
4546
public boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
46-
throws RunnerException {
47+
throws RunnerException, SerialException {
4748
this.verbose = verbose;
4849
Map<String, String> boardPreferences = Base.getBoardPreferences();
4950
String uploadUsing = boardPreferences.get("upload.using");
@@ -71,7 +72,7 @@ public boolean uploadUsingPreferences(String buildPath, String className, boolea
7172
}
7273

7374
private boolean uploadViaBootloader(String buildPath, String className)
74-
throws RunnerException {
75+
throws RunnerException, SerialException {
7576
Map<String, String> boardPreferences = Base.getBoardPreferences();
7677
List commandDownloader = new ArrayList();
7778
String protocol = boardPreferences.get("upload.protocol");

app/src/processing/app/debug/Compiler.java

+66-66
Original file line numberDiff line numberDiff line change
@@ -93,72 +93,72 @@ public boolean compile(Sketch sketch,
9393

9494
List<File> objectFiles = new ArrayList<File>();
9595

96-
List includePaths = new ArrayList();
97-
includePaths.add(corePath);
98-
99-
String runtimeLibraryName = buildPath + File.separator + "core.a";
100-
101-
// 1. compile the core, outputting .o files to <buildPath> and then
102-
// collecting them into the core.a library file.
103-
104-
List<File> coreObjectFiles =
105-
compileFiles(avrBasePath, buildPath, includePaths,
106-
findFilesInPath(corePath, "S", true),
107-
findFilesInPath(corePath, "c", true),
108-
findFilesInPath(corePath, "cpp", true),
109-
boardPreferences);
110-
111-
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
112-
avrBasePath + "avr-ar",
113-
"rcs",
114-
runtimeLibraryName
115-
}));
116-
117-
for(File file : coreObjectFiles) {
118-
List commandAR = new ArrayList(baseCommandAR);
119-
commandAR.add(file.getAbsolutePath());
120-
execAsynchronously(commandAR);
121-
}
122-
123-
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
124-
125-
// use library directories as include paths for all libraries
126-
for (File file : sketch.getImportedLibraries()) {
127-
includePaths.add(file.getPath());
128-
}
129-
130-
for (File libraryFolder : sketch.getImportedLibraries()) {
131-
File outputFolder = new File(buildPath, libraryFolder.getName());
132-
File utilityFolder = new File(libraryFolder, "utility");
133-
createFolder(outputFolder);
134-
// this library can use includes in its utility/ folder
135-
includePaths.add(utilityFolder.getAbsolutePath());
136-
objectFiles.addAll(
137-
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
138-
findFilesInFolder(libraryFolder, "S", false),
139-
findFilesInFolder(libraryFolder, "c", false),
140-
findFilesInFolder(libraryFolder, "cpp", false),
141-
boardPreferences));
142-
outputFolder = new File(outputFolder, "utility");
143-
createFolder(outputFolder);
144-
objectFiles.addAll(
145-
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
146-
findFilesInFolder(utilityFolder, "S", false),
147-
findFilesInFolder(utilityFolder, "c", false),
148-
findFilesInFolder(utilityFolder, "cpp", false),
149-
boardPreferences));
150-
// other libraries should not see this library's utility/ folder
151-
includePaths.remove(includePaths.size() - 1);
152-
}
153-
154-
// 3. compile the sketch (already in the buildPath)
155-
156-
objectFiles.addAll(
157-
compileFiles(avrBasePath, buildPath, includePaths,
158-
findFilesInPath(buildPath, "S", false),
159-
findFilesInPath(buildPath, "c", false),
160-
findFilesInPath(buildPath, "cpp", false),
161-
boardPreferences));
96+
// 0. include paths for core + all libraries
97+
98+
List includePaths = new ArrayList();
99+
includePaths.add(corePath);
100+
for (File file : sketch.getImportedLibraries()) {
101+
includePaths.add(file.getPath());
102+
}
103+
104+
// 1. compile the sketch (already in the buildPath)
105+
106+
objectFiles.addAll(
107+
compileFiles(avrBasePath, buildPath, includePaths,
108+
findFilesInPath(buildPath, "S", false),
109+
findFilesInPath(buildPath, "c", false),
110+
findFilesInPath(buildPath, "cpp", false),
111+
boardPreferences));
112+
113+
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
114+
115+
for (File libraryFolder : sketch.getImportedLibraries()) {
116+
File outputFolder = new File(buildPath, libraryFolder.getName());
117+
File utilityFolder = new File(libraryFolder, "utility");
118+
createFolder(outputFolder);
119+
// this library can use includes in its utility/ folder
120+
includePaths.add(utilityFolder.getAbsolutePath());
121+
objectFiles.addAll(
122+
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
123+
findFilesInFolder(libraryFolder, "S", false),
124+
findFilesInFolder(libraryFolder, "c", false),
125+
findFilesInFolder(libraryFolder, "cpp", false),
126+
boardPreferences));
127+
outputFolder = new File(outputFolder, "utility");
128+
createFolder(outputFolder);
129+
objectFiles.addAll(
130+
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
131+
findFilesInFolder(utilityFolder, "S", false),
132+
findFilesInFolder(utilityFolder, "c", false),
133+
findFilesInFolder(utilityFolder, "cpp", false),
134+
boardPreferences));
135+
// other libraries should not see this library's utility/ folder
136+
includePaths.remove(includePaths.size() - 1);
137+
}
138+
139+
// 3. compile the core, outputting .o files to <buildPath> and then
140+
// collecting them into the core.a library file.
141+
142+
includePaths.clear();
143+
includePaths.add(corePath); // include path for core only
144+
List<File> coreObjectFiles =
145+
compileFiles(avrBasePath, buildPath, includePaths,
146+
findFilesInPath(corePath, "S", true),
147+
findFilesInPath(corePath, "c", true),
148+
findFilesInPath(corePath, "cpp", true),
149+
boardPreferences);
150+
151+
String runtimeLibraryName = buildPath + File.separator + "core.a";
152+
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
153+
avrBasePath + "avr-ar",
154+
"rcs",
155+
runtimeLibraryName
156+
}));
157+
for(File file : coreObjectFiles) {
158+
List commandAR = new ArrayList(baseCommandAR);
159+
commandAR.add(file.getAbsolutePath());
160+
execAsynchronously(commandAR);
161+
}
162162

163163
// 4. link it all together into the .elf file
164164

0 commit comments

Comments
 (0)