diff --git a/app/Compiler.java b/app/Compiler.java index 101291cd7..6324112b8 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -1,9 +1,9 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - /* - Compiler - default compiler class that connects to jikes - Part of the Processing project - http://processing.org + Compiler - default compiler class that connects to the external compiler + Part of the Arduino project - http://arduino.berlios.de + + Derived from the Processing project - http://processing.org Copyleft 2005 Massimo Banzi (arduino modifications) Copyright (c) 2004-05 Ben Fry and Casey Reas @@ -26,8 +26,6 @@ package processing.app; -//import processing.core.*; - import java.io.*; import java.util.*; import java.util.zip.*; @@ -74,11 +72,14 @@ public class Compiler implements MessageConsumer { System.out.println("Compiling Arduino program"); Process process; + String commandLine = userdir + "tools/gnumake -C " + userdir + "lib compile"; + //TODO test this in windows + if (Base.isWindows()) commandLine.replace('/','\\'); int result = 0; try { - process = Runtime.getRuntime().exec(userdir + "tools/gnumake -s -C " + userdir + "lib compile"); + // System.out.println(commandLine); + process = Runtime.getRuntime().exec(commandLine); - // System.err.println(userdir + "lib/wiringlite/bin/gnumake -s -C " + userdir + "lib compile"); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); @@ -112,11 +113,40 @@ public class Compiler implements MessageConsumer { * whenever a piece (usually a line) of error message is spewed * out from the compiler. The errors are parsed for their contents * and line number, which is then reported back to Editor. + * In Arduino v1 this is very very crude */ public void message(String s) { // This receives messages as full lines, so a newline needs // to be added as they're printed to the console. - System.err.println(s); + //System.out.print(s); + + + //if ((s.indexOf("warning:") != -1) && (s.indexOf("prog.c:") != -1) ) { + // String[] result = s.split(":"); + // for (int x=0; x Serial menu to select"); + System.out.println("where you have connected your arduino board"); + return false; + }; + + String commandLine = ""; + + + if (debug) System.out.println("userdir is "+userdir); + + int result = -1; + String ext = ""; + + + // TODO make this code more portable using File.separator + if (Base.isMacOS()) { + ext = ""; + commandLine = userdir + "tools/avr/bin/uisp "; + commandLine += " -dprog=stk500 -dspeed=9600 "; + commandLine += " -dserial=" + serial_port; + commandLine += " -dpart=ATmega8"; + commandLine += " if=" +userdir + "lib/wiringlite/tmp/prog.hex --upload"; + } else { + ext = ".exe"; + commandLine = userdir + "lib\\wiringlite\\bin\\gnumake" + ext + " SERIAL=" + serial_port + verbose + " -C " + userdir + "lib\\wiringlite program"; + } + if (debug) System.out.println(commandLine); + + // Launch the command as a thread (this way we can kill it + // in the case it times out) + Command command = new Command(commandLine, true); + command.setName("theDownloader"); + command.start(); + + // TODO move this to Preferences + // Default timeout when calling a command (in seconds) + final int maxTimeOut = 30; // 10 secs + + + // Start timer to monitor buffer timeout ==> deadlock in process + int timeCount = 0; + + while ((timeCount <= maxTimeOut) && (result == -1) && command.isAlive()) { + try { + result = command.waitResult; + Thread.currentThread().sleep(1000); + } catch (InterruptedException ie) { + } + timeCount++; + } + result = command.waitResult; + + if ((result != 0) && (command.errorResult == -1)) { +// result = 94; + System.out.println("Time out error when trying to upload the program"); + System.out.println("Board not present, bootloader not installed or processor's failure"); + System.out.println("Arduino download unsuccessful (error: " + result + ")"); + } else if (result == 0) { + System.out.println(command.errorMsg); + System.out.println("OK - Arduino download successful"); + } else if ((result != 0) && (49 == command.errorResult)) { + System.out.println(command.errorMsg); + System.out.println("Bootloader not responding"); + System.out.println("Arduino download unsuccessful (error: " + result + ")"); + } else { + System.out.println(command.errorMsg); + System.out.println("Arduino download unsuccessful (error: " + result + ")"); + } + if (command.isAlive()) command.process.destroy(); + } else { + System.out.println("You have to compile the code first"); + System.out.println("Arduino download unsuccessful"); + } + + return true; + } + + + + } diff --git a/app/Editor.java b/app/Editor.java index 36b697a7d..529ce4d3c 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -632,7 +632,7 @@ public class Editor extends JFrame item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AutoFormat(Editor.this).show(); - //handleBeautify(); + } }); menu.add(item); @@ -1140,17 +1140,16 @@ public class Editor extends JFrame for (int i = 0; i < 10; i++) System.out.println(); // clear the console on each run, unless the user doesn't want to - //if (Base.getBoolean("console.auto_clear", true)) { //if (Preferences.getBoolean("console.auto_clear", true)) { if (Preferences.getBoolean("console.auto_clear")) { - console.clear(); + console.clear(); } presenting = present; - console.message("Arduino compiling\n", false,true); + // console.message("Arduino compiling\n", false,true); String cfilename = System.getProperty("user.dir") + File.separator + "lib/build/arduino.c"; - // console.message(" file = " + cfilename, false,true); + //console.message(" file = " + cfilename, false,true); try { Writer out = new FileWriter(cfilename); out.write(textarea.getText()); @@ -1164,12 +1163,12 @@ public class Editor extends JFrame Compiler compiler = new Compiler(); String buildPath = Preferences.get("build.path"); - // console.message(" buildpath = " + buildPath, false,true); + //console.message(" buildpath = " + buildPath, false,true); try { - boolean success = compiler.compile(sketch, buildPath); + boolean success = compiler.compile(sketch, buildPath); } catch (RunnerException e) { error(e); - } + } buttons.clear(); @@ -1287,6 +1286,7 @@ public class Editor extends JFrame * mode, this will always be called instead of doStop(). */ public void doClose() { + /* //if (presenting) { //presentationWindow.hide(); //} else { @@ -1295,7 +1295,7 @@ public class Editor extends JFrame // externally. so don't even try setting if window is null // since Runner will set the appletLocation when an // external process is in use. - if (runtime.window != null) { + //if (runtime.window != null) { appletLocation = runtime.window.getLocation(); } } catch (NullPointerException e) { } @@ -1311,7 +1311,7 @@ public class Editor extends JFrame } } catch (Exception e) { } //buttons.clear(); // done by doStop - + */ sketch.cleanup(); // [toxi 030903] diff --git a/build/macosx/dist.sh b/build/macosx/dist.sh index ec39c5674..21d0bfa0d 100755 --- a/build/macosx/dist.sh +++ b/build/macosx/dist.sh @@ -51,7 +51,13 @@ find arduino -name ".svn" -exec rm -rf {} ';' 2> /dev/null mv arduino/Arduino.app "arduino/Arduino $SHORT_REVISION.app" mv arduino arduino-$REVISION -zip -r arduino-$REVISION.zip arduino-$REVISION +#zip -r arduino-$REVISION.zip arduino-$REVISION + +rm -Rf tmp + +mkdir tmp +mv arduino-$REVISION/ tmp/ +hdiutil create -fs HFS+ -srcfolder "./tmp/" -volname "arduino-$REVISION" "arduino-$REVISION.dmg" #` don't have deluxe on my laptop right now #stuff -f sitx arduino-$REVISION