mirror of https://github.com/noisymime/Arduino.git
Moving libraries out of arduino platform / core directory and to top-level.
This commit is contained in:
parent
ff0336a3b6
commit
3075c8e4fd
|
@ -85,6 +85,8 @@ public class Base {
|
||||||
// found in the sketchbook)
|
// found in the sketchbook)
|
||||||
static public String librariesClassPath;
|
static public String librariesClassPath;
|
||||||
|
|
||||||
|
static HashMap<String, File> platformsTable;
|
||||||
|
|
||||||
// Location for untitled items
|
// Location for untitled items
|
||||||
static File untitledFolder;
|
static File untitledFolder;
|
||||||
|
|
||||||
|
@ -276,6 +278,9 @@ public class Base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadHardware(getHardwareFolder());
|
||||||
|
loadHardware(getSketchbookHardwareFolder());
|
||||||
|
|
||||||
// Check if there were previously opened sketches to be restored
|
// Check if there were previously opened sketches to be restored
|
||||||
boolean opened = restoreSketches();
|
boolean opened = restoreSketches();
|
||||||
|
|
||||||
|
@ -987,6 +992,31 @@ public class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void rebuildBoardsMenu(JMenu menu) {
|
||||||
|
//System.out.println("rebuilding boards menu");
|
||||||
|
try {
|
||||||
|
menu.removeAll();
|
||||||
|
ButtonGroup group = new ButtonGroup();
|
||||||
|
for (String board : Preferences.getSubKeys("boards")) {
|
||||||
|
JMenu item =
|
||||||
|
new JRadioButtonMenuItem(
|
||||||
|
new AbstractAction(Preferences.get("boards", "board", "name")) {
|
||||||
|
{ putValue("board", board); }
|
||||||
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
|
//System.out.println("Switching to " + board);
|
||||||
|
Preferences.set("board", getValue("board"));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
if (board.equals(Preferences.get("board"))) item.setSelected(true);
|
||||||
|
group.add(item);
|
||||||
|
menu.add(item);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan a folder recursively, and add any sketches found to the menu
|
* Scan a folder recursively, and add any sketches found to the menu
|
||||||
* specified. Set the openReplaces parameter to true when opening the sketch
|
* specified. Set the openReplaces parameter to true when opening the sketch
|
||||||
|
@ -1138,7 +1168,8 @@ public class Base {
|
||||||
// String packages[] =
|
// String packages[] =
|
||||||
// Compiler.packageListFromClassPath(libraryClassPath);
|
// Compiler.packageListFromClassPath(libraryClassPath);
|
||||||
libraries.add(subfolder);
|
libraries.add(subfolder);
|
||||||
String packages[] = Compiler.headerListFromIncludePath(subfolder.getAbsolutePath());
|
String packages[] =
|
||||||
|
Compiler.headerListFromIncludePath(subfolder.getAbsolutePath());
|
||||||
for (String pkg : packages) {
|
for (String pkg : packages) {
|
||||||
importToLibraryTable.put(pkg, subfolder);
|
importToLibraryTable.put(pkg, subfolder);
|
||||||
}
|
}
|
||||||
|
@ -1164,6 +1195,42 @@ public class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean loadHardware(File folder) {
|
||||||
|
if (!folder.isDirectory()) return false;
|
||||||
|
|
||||||
|
String list[] = folder.list(new FilenameFilter() {
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
// skip .DS_Store files, .svn folders, etc
|
||||||
|
if (name.charAt(0) == '.') return false;
|
||||||
|
if (name.equals("CVS")) return false;
|
||||||
|
return (new File(dir, name).isDirectory());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// if a bad folder or something like that, this might come back null
|
||||||
|
if (list == null) return false;
|
||||||
|
|
||||||
|
// alphabetize list, since it's not always alpha order
|
||||||
|
// replaced hella slow bubble sort with this feller for 0093
|
||||||
|
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
|
for (String platform : list) {
|
||||||
|
File subfolder = new File(folder, platform);
|
||||||
|
|
||||||
|
File boardsFile = new File(subfolder, "boards.txt");
|
||||||
|
if (boardsFile.exists()) {
|
||||||
|
Preferences.load(new FileInputStream(boardsFile), "boards");
|
||||||
|
}
|
||||||
|
|
||||||
|
File programmersFile = new File(subfolder, "programmers.txt");
|
||||||
|
if (programmersFile.exists()) {
|
||||||
|
Preferences.load(new FileInputStream(programmersFile), "programmers");
|
||||||
|
}
|
||||||
|
|
||||||
|
platformsTable.put(platform, subfolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// .................................................................
|
// .................................................................
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1842,10 +1842,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
sketch.compile(new Target(
|
sketch.compile(verbose);
|
||||||
Base.getHardwarePath() + File.separator + "cores",
|
|
||||||
Preferences.get("boards." + Preferences.get("board") + ".build.core")),
|
|
||||||
verbose);
|
|
||||||
statusNotice("Done compiling.");
|
statusNotice("Done compiling.");
|
||||||
} catch (RunnerException e) {
|
} catch (RunnerException e) {
|
||||||
//statusError("Error compiling...");
|
//statusError("Error compiling...");
|
||||||
|
@ -2257,10 +2254,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
|
|
||||||
uploading = true;
|
uploading = true;
|
||||||
|
|
||||||
boolean success = sketch.exportApplet(new Target(
|
boolean success = sketch.exportApplet(verbose);
|
||||||
Base.getHardwarePath() + File.separator + "cores",
|
|
||||||
Preferences.get("boards." + Preferences.get("board") + ".build.core")),
|
|
||||||
verbose);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
statusNotice("Done uploading.");
|
statusNotice("Done uploading.");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -199,25 +199,6 @@ public class Preferences {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
load(new FileInputStream(new File(Base.getHardwareFolder(), "boards.txt")),
|
|
||||||
"boards");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Base.showError("Error reading board definitions",
|
|
||||||
"Error reading the board definitions file (" +
|
|
||||||
new File(Base.getHardwareFolder(), "boards.txt").getAbsolutePath() + "). " +
|
|
||||||
"Please re-download or re-unzip Arduino.\n", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
load(new FileInputStream(new File(Base.getHardwareFolder(), "programmers.txt")),
|
|
||||||
"programmers");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Base.showError("Error reading programmers definitions",
|
|
||||||
"Error reading the programmers definitions file. " +
|
|
||||||
"Please re-download or re-unzip Arduino.\n", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -570,9 +551,8 @@ public class Preferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void load(InputStream input, String prefix) throws IOException {
|
static protected void load(InputStream input, String prefix) throws IOException {
|
||||||
LinkedHashMap table = new LinkedHashMap();
|
if (!prefixes.containsKey(prefix)) prefixes.put(prefix, new LinkedHashMap());
|
||||||
prefixes.put(prefix, table);
|
load(input, (Map) prefixes.get(prefix));
|
||||||
load(input, table);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void load(InputStream input, Map table) throws IOException {
|
static protected void load(InputStream input, Map table) throws IOException {
|
||||||
|
@ -629,6 +609,11 @@ public class Preferences {
|
||||||
//return get(attribute, null);
|
//return get(attribute, null);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
static public String get(String prefix, String selector, String suffix) {
|
||||||
|
if (get(selector) == null) return null;
|
||||||
|
return get(prefix + "." + get(selector) + "." + suffix);
|
||||||
|
}
|
||||||
|
|
||||||
static public String get(String attribute /*, String defaultValue */) {
|
static public String get(String attribute /*, String defaultValue */) {
|
||||||
// if the attribute starts with a prefix used by one of our subsidiary
|
// if the attribute starts with a prefix used by one of our subsidiary
|
||||||
// preference files, look up the attribute in that file's Hashtable
|
// preference files, look up the attribute in that file's Hashtable
|
||||||
|
|
|
@ -27,7 +27,6 @@ import processing.app.debug.AvrdudeUploader;
|
||||||
import processing.app.debug.Compiler;
|
import processing.app.debug.Compiler;
|
||||||
import processing.app.debug.RunnerException;
|
import processing.app.debug.RunnerException;
|
||||||
import processing.app.debug.Sizer;
|
import processing.app.debug.Sizer;
|
||||||
import processing.app.debug.Target;
|
|
||||||
import processing.app.debug.Uploader;
|
import processing.app.debug.Uploader;
|
||||||
import processing.app.preproc.*;
|
import processing.app.preproc.*;
|
||||||
import processing.core.*;
|
import processing.core.*;
|
||||||
|
@ -1142,7 +1141,7 @@ public class Sketch {
|
||||||
* X. afterwards, some of these steps need a cleanup function
|
* X. afterwards, some of these steps need a cleanup function
|
||||||
* </PRE>
|
* </PRE>
|
||||||
*/
|
*/
|
||||||
protected String compile(Target target, boolean verbose)
|
protected String compile(boolean verbose)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
@ -1177,7 +1176,7 @@ public class Sketch {
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
// handle preprocessing the main file's code
|
// handle preprocessing the main file's code
|
||||||
name = build(tempBuildFolder.getAbsolutePath(), target, verbose);
|
name = build(tempBuildFolder.getAbsolutePath(), verbose);
|
||||||
size(tempBuildFolder.getAbsolutePath(), name);
|
size(tempBuildFolder.getAbsolutePath(), name);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -1199,11 +1198,11 @@ public class Sketch {
|
||||||
* @param buildPath Location to copy all the .java files
|
* @param buildPath Location to copy all the .java files
|
||||||
* @return null if compilation failed, main class name if not
|
* @return null if compilation failed, main class name if not
|
||||||
*/
|
*/
|
||||||
public String preprocess(String buildPath, Target target) throws RunnerException {
|
public String preprocess(String buildPath) throws RunnerException {
|
||||||
return preprocess(buildPath, new PdePreprocessor(), target);
|
return preprocess(buildPath, new PdePreprocessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String preprocess(String buildPath, PdePreprocessor preprocessor, Target target) throws RunnerException {
|
public String preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
|
||||||
// make sure the user didn't hide the sketch folder
|
// make sure the user didn't hide the sketch folder
|
||||||
ensureExistence();
|
ensureExistence();
|
||||||
|
|
||||||
|
@ -1279,8 +1278,7 @@ public class Sketch {
|
||||||
headerOffset = preprocessor.writePrefix(bigCode.toString(),
|
headerOffset = preprocessor.writePrefix(bigCode.toString(),
|
||||||
buildPath,
|
buildPath,
|
||||||
name,
|
name,
|
||||||
codeFolderPackages,
|
codeFolderPackages);
|
||||||
target);
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
fnfe.printStackTrace();
|
fnfe.printStackTrace();
|
||||||
String msg = "Build folder disappeared or could not be written";
|
String msg = "Build folder disappeared or could not be written";
|
||||||
|
@ -1378,31 +1376,31 @@ 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, Target target, boolean verbose)
|
public String build(String buildPath, boolean verbose)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
|
||||||
// run the preprocessor
|
// run the preprocessor
|
||||||
String primaryClassName = preprocess(buildPath, target);
|
String primaryClassName = preprocess(buildPath);
|
||||||
|
|
||||||
// compile the program. errors will happen as a RunnerException
|
// compile the program. errors will happen as a RunnerException
|
||||||
// that will bubble up to whomever called build().
|
// that will bubble up to whomever called build().
|
||||||
Compiler compiler = new Compiler();
|
Compiler compiler = new Compiler();
|
||||||
if (compiler.compile(this, buildPath, primaryClassName, target, verbose)) {
|
if (compiler.compile(this, buildPath, primaryClassName, verbose)) {
|
||||||
return primaryClassName;
|
return primaryClassName;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean exportApplet(Target target, boolean verbose) throws Exception {
|
protected boolean exportApplet(boolean verbose) throws Exception {
|
||||||
return exportApplet(new File(folder, "applet").getAbsolutePath(), target, verbose);
|
return exportApplet(new File(folder, "applet").getAbsolutePath(), verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle export to applet.
|
* Handle export to applet.
|
||||||
*/
|
*/
|
||||||
public boolean exportApplet(String appletPath, Target target, boolean verbose)
|
public boolean exportApplet(String appletPath, boolean verbose)
|
||||||
throws RunnerException, IOException {
|
throws RunnerException, IOException {
|
||||||
|
|
||||||
// Make sure the user didn't hide the sketch folder
|
// Make sure the user didn't hide the sketch folder
|
||||||
|
@ -1426,7 +1424,7 @@ public class Sketch {
|
||||||
appletFolder.mkdirs();
|
appletFolder.mkdirs();
|
||||||
|
|
||||||
// build the sketch
|
// build the sketch
|
||||||
String foundName = build(appletFolder.getPath(), target, false);
|
String foundName = build(appletFolder.getPath(), false);
|
||||||
// (already reported) error during export, exit this function
|
// (already reported) error during export, exit this function
|
||||||
if (foundName == null) return false;
|
if (foundName == null) return false;
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,12 @@ public class Compiler implements MessageConsumer {
|
||||||
* @param sketch Sketch object to be compiled.
|
* @param sketch Sketch object to be compiled.
|
||||||
* @param buildPath Where the temporary files live and will be built from.
|
* @param buildPath Where the temporary files live and will be built from.
|
||||||
* @param primaryClassName the name of the combined sketch file w/ extension
|
* @param primaryClassName the name of the combined sketch file w/ extension
|
||||||
* @param target the target (core) to build against
|
|
||||||
* @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(Sketch sketch,
|
public boolean compile(Sketch sketch,
|
||||||
String buildPath,
|
String buildPath,
|
||||||
String primaryClassName,
|
String primaryClassName,
|
||||||
Target target,
|
|
||||||
boolean verbose) throws RunnerException {
|
boolean verbose) throws RunnerException {
|
||||||
this.sketch = sketch;
|
this.sketch = sketch;
|
||||||
this.buildPath = buildPath;
|
this.buildPath = buildPath;
|
||||||
|
@ -73,6 +71,7 @@ public class Compiler implements MessageConsumer {
|
||||||
MessageStream pms = new MessageStream(this);
|
MessageStream pms = new MessageStream(this);
|
||||||
|
|
||||||
String avrBasePath = Base.getAvrBasePath();
|
String avrBasePath = Base.getAvrBasePath();
|
||||||
|
String corePath = Preferences.get("boards", "board", "build.core");
|
||||||
|
|
||||||
List<File> objectFiles = new ArrayList<File>();
|
List<File> objectFiles = new ArrayList<File>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue