Permalink
Browse files

Added log4j into Base.java, enabled library directory to change when …

…a chipKit board is selected.
  • Loading branch information...
2 parents d61b1c4 + d1603b1 commit 0df5bc35ef13a1dda9ecf84672d2ebf1b04b1d69 @ricklon ricklon committed May 11, 2011
View
@@ -15,6 +15,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/video"/>
<classpathentry kind="lib" path="lib/antlr.jar"/>
<classpathentry kind="lib" path="lib/jna.jar"/>
- <classpathentry kind="lib" path="lib/ecj.jar"/>
<classpathentry kind="output" path="bin"/>
+ <classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
+ <classpathentry kind="lib" path="lib/log4j.properties"/>
</classpath>
View
@@ -44,7 +44,7 @@
encoding="UTF-8"
includeAntRuntime="false"
debug="true"
- 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" />
+ 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; lib/log4j-1.2.16.jar; lib/log4j.properties" />
</target>
<target name="build" depends="compile" description="Build PDE">
@@ -29,6 +29,13 @@
import javax.swing.*;
+import org.apache.log4j.BasicConfigurator;
+//import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+
+
import processing.app.debug.Compiler;
import processing.app.debug.Target;
import processing.core.*;
@@ -41,12 +48,18 @@
* files and images, etc) that comes from that.
*/
public class Base {
+
+ //private static Logger logger = Logger.getLogger(Base.class.getName());
+ static Logger logger = Logger.getLogger(Base.class.getName());
+
+
public static final int REVISION = 22;
/** This might be replaced by main() if there's a lib/version.txt file. */
static String VERSION_NAME = "0022";
/** Set true if this a proper release rather than a numbered revision. */
static public boolean RELEASE = false;
-
+
+
static HashMap<Integer, String> platformNames = new HashMap<Integer, String>();
static {
platformNames.put(PConstants.WINDOWS, "windows");
@@ -107,6 +120,11 @@
static public void main(String args[]) {
try {
+ BasicConfigurator.configure();
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ logger.debug("DEBUG: Logging enabled.");
+
+
File versionFile = getContentFile("lib/version.txt");
if (versionFile.exists()) {
String version = PApplet.loadStrings(versionFile)[0];
@@ -188,6 +206,7 @@ static public void main(String args[]) {
untitledFolder.deleteOnExit();
new Base(args);
+
}
@@ -926,7 +945,8 @@ public void actionPerformed(ActionEvent e) {
} catch (IOException e) {
e.printStackTrace();
}
-
+
+
//System.out.println("rebuilding examples menu");
// Add each of the subfolders of examples directly to the menu
try {
@@ -938,8 +958,21 @@ public void actionPerformed(ActionEvent e) {
} catch (IOException e) {
e.printStackTrace();
}
+
+/*
+ //System.out.println("rebuilding examples menu");
+ // Add each of the subfolders of examples directly to the menu
+ try {
+
+ boolean found = addSketches(menu, getPic32CoreLibraries(), true);
+ if (found) menu.addSeparator();
+ addSketches(menu, librariesFolder, true);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
-
+*/
+ }
protected void rebuildSketchbookMenu(JMenu menu) {
//System.out.println("rebuilding sketchbook menu");
@@ -955,7 +988,8 @@ protected void rebuildSketchbookMenu(JMenu menu) {
public void rebuildImportMenu(JMenu importMenu) {
- //System.out.println("rebuilding import menu");
+ logger.debug("DEBUG:start: rebuilding import menu");
+
importMenu.removeAll();
// reset the set of libraries
@@ -965,8 +999,28 @@ public void rebuildImportMenu(JMenu importMenu) {
importToLibraryTable = new HashMap<String, File>();
// Add from the "libraries" subfolder in the Processing directory
+ //Choose which library to add by chip platform
+
try {
- addLibraries(importMenu, librariesFolder);
+ Target t = getTarget();
+ logger.debug("DEBUG: target=" + t.getName());
+ if ( !t.getName().equals("pic32")) {
+ logger.debug("DEBUG: add avr libraries.");
+ JMenuItem platformItem = new JMenuItem("Arduino");
+ platformItem.setEnabled(false);
+ importMenu.add(platformItem);
+ importMenu.addSeparator();
+ addLibraries(importMenu, librariesFolder);
+ }
+ else
+ {
+ logger.debug("DEBUG: add pic32 libraries.");
+ JMenuItem platformItem = new JMenuItem("chipKit");
+ platformItem.setEnabled(false);
+ importMenu.add(platformItem);
+ importMenu.addSeparator();
+ addLibraries(importMenu, getPic32CoreLibraries());
+ }
} catch (IOException e) {
e.printStackTrace();
}
@@ -1003,17 +1057,24 @@ public void rebuildExamplesMenu(JMenu menu) {
public void rebuildBoardsMenu(JMenu menu) {
- //System.out.println("rebuilding boards menu");
+ logger.debug("DEBUG: start: rebuilding boards menu.");
+
menu.removeAll();
ButtonGroup group = new ButtonGroup();
for (Target target : targetsTable.values()) {
for (String board : target.getBoards().keySet()) {
+
AbstractAction action =
new AbstractAction(target.getBoards().get(board).get("name")) {
public void actionPerformed(ActionEvent actionevent) {
- //System.out.println("Switching to " + target + ":" + board);
+ logger.debug("DEBUG: start: " + "Switching to " + (String) getValue("target") + ":" + (String) getValue("board"));
Preferences.set("target", (String) getValue("target"));
Preferences.set("board", (String) getValue("board"));
+ logger.debug("DEBUG: rebuildBoardsMenu: inside rebuildImportMenu" );
+ //Debug: created new imports menu based on board
+ JMenu emptyMenu = new JMenu();
+ rebuildImportMenu(emptyMenu);
+
}
};
action.putValue("target", target.getName());
@@ -1022,11 +1083,14 @@ public void actionPerformed(ActionEvent actionevent) {
if (target.getName().equals(Preferences.get("target")) &&
board.equals(Preferences.get("board"))) {
item.setSelected(true);
- }
+ }
group.add(item);
menu.add(item);
}
}
+
+ logger.debug("DEBUG: end: rebuilding boards menu.");
+
}
@@ -1154,6 +1218,8 @@ public void actionPerformed(ActionEvent e) {
protected boolean addLibraries(JMenu menu, File folder) throws IOException {
+ logger.debug("DEBUG: start: addLibraries.");
+
if (!folder.isDirectory()) return false;
String list[] = folder.list(new FilenameFilter() {
@@ -1526,6 +1592,10 @@ static public File getHardwareFolder() {
return getContentFile("hardware");
}
+ //Get the pci32 core libraries from folder
+ static public File getPic32CoreLibraries() {
+ return getContentFile("hardware/pic32/libraries");
+ }
static public String getHardwarePath() {
return getHardwareFolder().getAbsolutePath();
@@ -628,10 +628,10 @@ public void actionPerformed(ActionEvent e) {
sketchMenu.addSeparator();
- if (importMenu == null) {
- importMenu = new JMenu("Import Library...");
+ if (importMenu == null) {
+ importMenu = new JMenu("Import Library...");
base.rebuildImportMenu(importMenu);
- }
+ }
sketchMenu.add(importMenu);
item = newJMenuItem("Show Sketch Folder", 'K');
@@ -684,6 +684,9 @@ public void actionPerformed(ActionEvent e) {
if (boardsMenu == null) {
boardsMenu = new JMenu("Board");
base.rebuildBoardsMenu(boardsMenu);
+ //Debug: rebuild imports
+ importMenu.removeAll();
+ base.rebuildImportMenu(importMenu);
}
menu.add(boardsMenu);
View
@@ -28,6 +28,8 @@
<include name="app/lib/RXTXcomm.jar" />
<include name="app/lib/ant.jar" />
<include name="app/lib/ant-launcher.jar" />
+ <include name="app/lib/log4j-1.2.16.jar" />
+ <include name="app/lib/log4j.properties" />
</fileset>
<target name="build" description="Build Arduino.">
@@ -219,7 +221,7 @@
</target>
<target name="macosx-run" depends="macosx-build" description="Run Mac OS X version">
- <exec executable="macosx/work/Arduino.app/Contents/MacOS/JavaApplicationStub" spawn="true"/>
+ <exec executable="macosx/work/Arduino.app/Contents/MacOS/JavaApplicationStub" spawn="false"/>
</target>
<target name="macosx-dist" if="macosx" depends="macosx-build" description="Create a .dmg of the Mac OS X version">
@@ -72,7 +72,7 @@
<!-- In 0149, removed /System/Library/Java from the CLASSPATH because
it can cause problems if users have installed weird files there.
http://dev.processing.org/bugs/show_bug.cgi?id=1045 -->
- <string>$JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/RXTXcomm.jar</string>
+ <string>$JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/RXTXcomm.jar:$JAVAROOT/log4j-1.2.16.jar:$JAVAROOT/log4j.properties</string>
<key>JVMArchs</key>
<array>
@@ -1,12 +1,12 @@
############################################################
-mega_pic32.name=Digilent Pic32 Mega
+mega_pic32.name=chipKIT MAX32
# new items
mega_pic32.platform=pic32
mega_pic32.board=_BOARD_MEGA_
mega_pic32.define=anything_you_want
mega_pic32.ccflags=ffff
-mega_pic32.ldscript=chipKIT-application-mega-32MX795F512L.ld
+mega_pic32.ldscript=chipKIT-MAX32-application-32MX795F512L.ld
# end of new items
mega_pic32.upload.protocol=stk500v2
@@ -27,14 +27,14 @@ mega_pic32.build.core=pic32
#mega_pic32.upload.using=
############################################################
-uno_pic32.name=Digilent Pic32 Uno
+uno_pic32.name=chipKIT UNO32
# new items
uno_pic32.platform=pic32
uno_pic32.board=_BOARD_UNO_
uno_pic32.define=anything_you_want
uno_pic32.ccflags=ffff
-uno_pic32.ldscript=chipKIT-application-uno-32MX320F128L.ld
+uno_pic32.ldscript=chipKIT-UNO32-application-32MX320F128L.ld
# end of new items
uno_pic32.upload.protocol=stk500v2
Oops, something went wrong.

0 comments on commit 0df5bc3

Please sign in to comment.