mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Third-party cores seems to sort of work now, but burning bootloaders is probably broken.
Need to decide on the format for the boards.txt file.
This commit is contained in:
@ -85,7 +85,7 @@ public class Base {
|
|||||||
// found in the sketchbook)
|
// found in the sketchbook)
|
||||||
static public String librariesClassPath;
|
static public String librariesClassPath;
|
||||||
|
|
||||||
static HashMap<String, File> platformsTable;
|
static public HashMap<String, File> platformsTable;
|
||||||
|
|
||||||
// Location for untitled items
|
// Location for untitled items
|
||||||
static File untitledFolder;
|
static File untitledFolder;
|
||||||
@ -248,7 +248,7 @@ public class Base {
|
|||||||
// Get paths for the libraries and examples in the Processing folder
|
// Get paths for the libraries and examples in the Processing folder
|
||||||
//String workingDirectory = System.getProperty("user.dir");
|
//String workingDirectory = System.getProperty("user.dir");
|
||||||
examplesFolder = getContentFile("examples");
|
examplesFolder = getContentFile("examples");
|
||||||
librariesFolder = new File(getContentFile("hardware"), "libraries");
|
librariesFolder = getContentFile("libraries");
|
||||||
toolsFolder = getContentFile("tools");
|
toolsFolder = getContentFile("tools");
|
||||||
|
|
||||||
// Get the sketchbook path, and make sure it's set properly
|
// Get the sketchbook path, and make sure it's set properly
|
||||||
@ -278,6 +278,7 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platformsTable = new HashMap<String, File>();
|
||||||
loadHardware(getHardwareFolder());
|
loadHardware(getHardwareFolder());
|
||||||
loadHardware(getSketchbookHardwareFolder());
|
loadHardware(getSketchbookHardwareFolder());
|
||||||
|
|
||||||
@ -994,25 +995,39 @@ public class Base {
|
|||||||
|
|
||||||
public void rebuildBoardsMenu(JMenu menu) {
|
public void rebuildBoardsMenu(JMenu menu) {
|
||||||
//System.out.println("rebuilding boards menu");
|
//System.out.println("rebuilding boards menu");
|
||||||
try {
|
menu.removeAll();
|
||||||
menu.removeAll();
|
ButtonGroup group = new ButtonGroup();
|
||||||
ButtonGroup group = new ButtonGroup();
|
for (String board : Preferences.getSubKeys("boards")) {
|
||||||
for (String board : Preferences.getSubKeys("boards")) {
|
AbstractAction action =
|
||||||
JMenu item =
|
new AbstractAction(Preferences.get("boards." + board + ".name")) {
|
||||||
new JRadioButtonMenuItem(
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
new AbstractAction(Preferences.get("boards", "board", "name")) {
|
//System.out.println("Switching to " + board);
|
||||||
{ putValue("board", board); }
|
Preferences.set("board", (String) getValue("board"));
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
}
|
||||||
//System.out.println("Switching to " + board);
|
};
|
||||||
Preferences.set("board", getValue("board"));
|
action.putValue("board", board);
|
||||||
}
|
JMenuItem item = new JRadioButtonMenuItem(action);
|
||||||
}));
|
if (board.equals(Preferences.get("board"))) item.setSelected(true);
|
||||||
if (board.equals(Preferences.get("board"))) item.setSelected(true);
|
group.add(item);
|
||||||
group.add(item);
|
menu.add(item);
|
||||||
menu.add(item);
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
|
public void rebuildBurnBootloaderMenu(JMenu menu) {
|
||||||
|
//System.out.println("rebuilding burn bootloader menu");
|
||||||
|
menu.removeAll();
|
||||||
|
for (String programmer : Preferences.getSubKeys("programmers")) {
|
||||||
|
AbstractAction action =
|
||||||
|
new AbstractAction(
|
||||||
|
"w/ " + Preferences.get("programmers." + programmer + ".name")) {
|
||||||
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
|
activeEditor.handleBurnBootloader((String) getValue("programmer"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
action.putValue("programmer", programmer);
|
||||||
|
JMenuItem item = new JMenuItem(action);
|
||||||
|
menu.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,8 +1210,8 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean loadHardware(File folder) {
|
protected void loadHardware(File folder) {
|
||||||
if (!folder.isDirectory()) return false;
|
if (!folder.isDirectory()) return;
|
||||||
|
|
||||||
String list[] = folder.list(new FilenameFilter() {
|
String list[] = folder.list(new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
@ -1207,7 +1222,7 @@ public class Base {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if a bad folder or something like that, this might come back null
|
// if a bad folder or something like that, this might come back null
|
||||||
if (list == null) return false;
|
if (list == null) return;
|
||||||
|
|
||||||
// alphabetize list, since it's not always alpha order
|
// alphabetize list, since it's not always alpha order
|
||||||
// replaced hella slow bubble sort with this feller for 0093
|
// replaced hella slow bubble sort with this feller for 0093
|
||||||
@ -1217,13 +1232,23 @@ public class Base {
|
|||||||
File subfolder = new File(folder, platform);
|
File subfolder = new File(folder, platform);
|
||||||
|
|
||||||
File boardsFile = new File(subfolder, "boards.txt");
|
File boardsFile = new File(subfolder, "boards.txt");
|
||||||
if (boardsFile.exists()) {
|
try {
|
||||||
Preferences.load(new FileInputStream(boardsFile), "boards");
|
if (boardsFile.exists()) {
|
||||||
|
Preferences.load(new FileInputStream(boardsFile), "boards");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error loading boards from " +
|
||||||
|
boardsFile + ": " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
File programmersFile = new File(subfolder, "programmers.txt");
|
File programmersFile = new File(subfolder, "programmers.txt");
|
||||||
if (programmersFile.exists()) {
|
try {
|
||||||
Preferences.load(new FileInputStream(programmersFile), "programmers");
|
if (programmersFile.exists()) {
|
||||||
|
Preferences.load(new FileInputStream(programmersFile), "programmers");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error loading programmers from " +
|
||||||
|
programmersFile + ": " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
platformsTable.put(platform, subfolder);
|
platformsTable.put(platform, subfolder);
|
||||||
@ -1513,6 +1538,11 @@ public class Base {
|
|||||||
static public String getSketchbookLibrariesPath() {
|
static public String getSketchbookLibrariesPath() {
|
||||||
return getSketchbookLibrariesFolder().getAbsolutePath();
|
return getSketchbookLibrariesFolder().getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public File getSketchbookHardwareFolder() {
|
||||||
|
return new File(getSketchbookFolder(), "hardware");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected File getDefaultSketchbookFolder() {
|
protected File getDefaultSketchbookFolder() {
|
||||||
|
@ -706,16 +706,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
if (boardsMenu == null) {
|
if (boardsMenu == null) {
|
||||||
boardsMenu = new JMenu("Board");
|
boardsMenu = new JMenu("Board");
|
||||||
ButtonGroup boardGroup = new ButtonGroup();
|
base.rebuildBoardsMenu(boardsMenu);
|
||||||
for (Iterator i = Preferences.getSubKeys("boards"); i.hasNext(); ) {
|
|
||||||
String board = (String) i.next();
|
|
||||||
Action action = new BoardMenuAction(board);
|
|
||||||
item = new JRadioButtonMenuItem(action);
|
|
||||||
if (board.equals(Preferences.get("board")))
|
|
||||||
item.setSelected(true);
|
|
||||||
boardGroup.add(item);
|
|
||||||
boardsMenu.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
menu.add(boardsMenu);
|
menu.add(boardsMenu);
|
||||||
|
|
||||||
@ -727,14 +718,9 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
menu.add(serialMenu);
|
menu.add(serialMenu);
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
JMenu bootloaderMenu = new JMenu("Burn Bootloader");
|
JMenu bootloaderMenu = new JMenu("Burn Bootloader");
|
||||||
for (Iterator i = Preferences.getSubKeys("programmers"); i.hasNext(); ) {
|
base.rebuildBurnBootloaderMenu(bootloaderMenu);
|
||||||
String programmer = (String) i.next();
|
|
||||||
Action action = new BootloaderMenuAction(programmer);
|
|
||||||
item = new JMenuItem(action);
|
|
||||||
bootloaderMenu.add(item);
|
|
||||||
}
|
|
||||||
menu.add(bootloaderMenu);
|
menu.add(bootloaderMenu);
|
||||||
|
|
||||||
menu.addMenuListener(new MenuListener() {
|
menu.addMenuListener(new MenuListener() {
|
||||||
@ -964,30 +950,6 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BoardMenuAction extends AbstractAction {
|
|
||||||
private String board;
|
|
||||||
public BoardMenuAction(String board) {
|
|
||||||
super(Preferences.get("boards." + board + ".name"));
|
|
||||||
this.board = board;
|
|
||||||
}
|
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
|
||||||
//System.out.println("Switching to " + board);
|
|
||||||
Preferences.set("board", board);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BootloaderMenuAction extends AbstractAction {
|
|
||||||
private String programmer;
|
|
||||||
public BootloaderMenuAction(String programmer) {
|
|
||||||
super("w/ " + Preferences.get("programmers." + programmer + ".name"));
|
|
||||||
this.programmer = programmer;
|
|
||||||
}
|
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
|
||||||
handleBurnBootloader(programmer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void populateSerialMenu() {
|
protected void populateSerialMenu() {
|
||||||
// getting list of ports
|
// getting list of ports
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ public class Preferences {
|
|||||||
* baz.count=3
|
* baz.count=3
|
||||||
* this will return { "foo", "bar", "baz" }.
|
* this will return { "foo", "bar", "baz" }.
|
||||||
*/
|
*/
|
||||||
static public Iterator getSubKeys(String prefix) {
|
static public Set<String> getSubKeys(String prefix) {
|
||||||
if (!prefixes.containsKey(prefix))
|
if (!prefixes.containsKey(prefix))
|
||||||
return null;
|
return null;
|
||||||
Set subkeys = new LinkedHashSet();
|
Set subkeys = new LinkedHashSet();
|
||||||
@ -657,7 +657,7 @@ public class Preferences {
|
|||||||
subkey = subkey.substring(0, subkey.indexOf('.'));
|
subkey = subkey.substring(0, subkey.indexOf('.'));
|
||||||
subkeys.add(subkey);
|
subkeys.add(subkey);
|
||||||
}
|
}
|
||||||
return subkeys.iterator();
|
return subkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,23 +71,25 @@ 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");
|
String platform = Preferences.get("boards", "board", "build.core");
|
||||||
|
File platformFile = Base.platformsTable.get(platform);
|
||||||
|
String corePath = new File(platformFile, "core").getAbsolutePath();
|
||||||
|
|
||||||
List<File> objectFiles = new ArrayList<File>();
|
List<File> objectFiles = new ArrayList<File>();
|
||||||
|
|
||||||
List includePaths = new ArrayList();
|
List includePaths = new ArrayList();
|
||||||
includePaths.add(target.getPath());
|
includePaths.add(corePath);
|
||||||
|
|
||||||
String runtimeLibraryName = buildPath + File.separator + "core.a";
|
String runtimeLibraryName = buildPath + File.separator + "core.a";
|
||||||
|
|
||||||
// 1. compile the target (core), outputting .o files to <buildPath> and
|
// 1. compile the core, outputting .o files to <buildPath> and then
|
||||||
// then collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
|
|
||||||
List<File> targetObjectFiles =
|
List<File> coreObjectFiles =
|
||||||
compileFiles(avrBasePath, buildPath, includePaths,
|
compileFiles(avrBasePath, buildPath, includePaths,
|
||||||
findFilesInPath(target.getPath(), "S", true),
|
findFilesInPath(corePath, "S", true),
|
||||||
findFilesInPath(target.getPath(), "c", true),
|
findFilesInPath(corePath, "c", true),
|
||||||
findFilesInPath(target.getPath(), "cpp", true));
|
findFilesInPath(corePath, "cpp", true));
|
||||||
|
|
||||||
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
|
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
|
||||||
avrBasePath + "avr-ar",
|
avrBasePath + "avr-ar",
|
||||||
@ -95,7 +97,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
runtimeLibraryName
|
runtimeLibraryName
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for(File file : targetObjectFiles) {
|
for(File file : coreObjectFiles) {
|
||||||
List commandAR = new ArrayList(baseCommandAR);
|
List commandAR = new ArrayList(baseCommandAR);
|
||||||
commandAR.add(file.getAbsolutePath());
|
commandAR.add(file.getAbsolutePath());
|
||||||
execAsynchronously(commandAR);
|
execAsynchronously(commandAR);
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
package processing.app.preproc;
|
package processing.app.preproc;
|
||||||
|
|
||||||
import processing.app.*;
|
import processing.app.*;
|
||||||
import processing.app.debug.Target;
|
|
||||||
import processing.core.*;
|
import processing.core.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -50,7 +49,6 @@ public class PdePreprocessor {
|
|||||||
// we always write one header: WProgram.h
|
// we always write one header: WProgram.h
|
||||||
public int headerCount = 1;
|
public int headerCount = 1;
|
||||||
|
|
||||||
Target target;
|
|
||||||
List prototypes;
|
List prototypes;
|
||||||
|
|
||||||
|
|
||||||
@ -82,12 +80,10 @@ public class PdePreprocessor {
|
|||||||
public PdePreprocessor() { }
|
public PdePreprocessor() { }
|
||||||
|
|
||||||
public int writePrefix(String program, String buildPath,
|
public int writePrefix(String program, String buildPath,
|
||||||
String name, String codeFolderPackages[],
|
String name, String codeFolderPackages[])
|
||||||
Target target)
|
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
this.buildPath = buildPath;
|
this.buildPath = buildPath;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.target = target;
|
|
||||||
|
|
||||||
int tabSize = Preferences.getInteger("editor.tabs.size");
|
int tabSize = Preferences.getInteger("editor.tabs.size");
|
||||||
char[] indentChars = new char[tabSize];
|
char[] indentChars = new char[tabSize];
|
||||||
@ -196,7 +192,7 @@ public class PdePreprocessor {
|
|||||||
// String extraImports[]) throws java.lang.Exception {
|
// String extraImports[]) throws java.lang.Exception {
|
||||||
public String write() throws java.lang.Exception {
|
public String write() throws java.lang.Exception {
|
||||||
writeProgram(stream, program, prototypes);
|
writeProgram(stream, program, prototypes);
|
||||||
writeFooter(stream, target);
|
writeFooter(stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@ -223,23 +219,7 @@ public class PdePreprocessor {
|
|||||||
*
|
*
|
||||||
* @param out PrintStream to write it to.
|
* @param out PrintStream to write it to.
|
||||||
*/
|
*/
|
||||||
protected void writeFooter(PrintStream out, Target target) throws java.lang.Exception {
|
protected void writeFooter(PrintStream out) throws java.lang.Exception {}
|
||||||
// Open the file main.cxx and copy its entire contents to the bottom of the
|
|
||||||
// generated sketch .cpp file...
|
|
||||||
|
|
||||||
String mainFileName = target.getPath() + File.separator + "main.cxx";
|
|
||||||
FileReader reader = null;
|
|
||||||
reader = new FileReader(mainFileName);
|
|
||||||
|
|
||||||
LineNumberReader mainfile = new LineNumberReader(reader);
|
|
||||||
|
|
||||||
String line;
|
|
||||||
while ((line = mainfile.readLine()) != null) {
|
|
||||||
out.print(line + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
mainfile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<String> getExtraImports() {
|
public ArrayList<String> getExtraImports() {
|
||||||
|
@ -36,7 +36,7 @@ else
|
|||||||
chmod +x work/Arduino.app/Contents/MacOS/JavaApplicationStub
|
chmod +x work/Arduino.app/Contents/MacOS/JavaApplicationStub
|
||||||
|
|
||||||
cp -rX ../shared/lib "$RESOURCES/"
|
cp -rX ../shared/lib "$RESOURCES/"
|
||||||
cp -rX ../shared/libraries "$RESOURCES/"
|
cp -rX ../../libraries "$RESOURCES/"
|
||||||
cp -rX ../shared/tools "$RESOURCES/"
|
cp -rX ../shared/tools "$RESOURCES/"
|
||||||
|
|
||||||
cp -rX ../../hardware "$RESOURCES/"
|
cp -rX ../../hardware "$RESOURCES/"
|
||||||
@ -126,4 +126,4 @@ cd ../..
|
|||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo Done.
|
echo Done.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <WProgram.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
Reference in New Issue
Block a user