From fc1ca8a0661ef52aa16fb05258e17c074e4d780d Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sun, 27 Aug 2006 09:45:28 +0000 Subject: [PATCH] Appled Hans Steiner's patch to search for avr=tools in path on Linux (instead of requiring symlinks to the Arduino tools directory). Added an upload.verbose preference for dumping details of the upload process. --- app/Compiler.java | 23 +++++++++++++++-------- app/Library.java | 16 +++++++++++++--- app/Sizer.java | 13 +++++++++++-- app/Uploader.java | 29 +++++++++++++++++++++++------ build/shared/lib/preferences.txt | 1 + 5 files changed, 63 insertions(+), 19 deletions(-) diff --git a/app/Compiler.java b/app/Compiler.java index e30830fb0..c721f28e7 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -83,10 +83,20 @@ public class Compiler implements MessageConsumer { // } catch (IOException e) { // throw new RunnerException(e.getMessage()); // } + String avrBasePath; + if(Base.isMacOS()) { + avrBasePath = new String("tools/avr/bin/"); + } + else if(Base.isLinux()) { + avrBasePath = new String(""); + } + else { + avrBasePath = new String(userdir + "tools/avr/bin/"); + } + String preCommandCompiler[] = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-gcc" : - userdir + "tools/avr/bin/avr-gcc"), + avrBasePath + "avr-gcc", "-c", // compile, don't link "-g", // include debugging info (so errors include line numbers) "-Os", // optimize for size @@ -111,8 +121,7 @@ public class Compiler implements MessageConsumer { } String preCommandCompilerCPP[] = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-g++" : - userdir + "tools/avr/bin/avr-g++"), + avrBasePath + "avr-g++", "-c", // compile, don't link "-g", // include debugging info (so errors include line numbers) "-Os", // optimize for size @@ -132,8 +141,7 @@ public class Compiler implements MessageConsumer { } String preCommandLinker[] = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-gcc" : - userdir + "tools/avr/bin/avr-gcc"), + avrBasePath + "avr-gcc", " ", "-mmcu=" + Preferences.get("build.mcu"), "-o", @@ -162,8 +170,7 @@ public class Compiler implements MessageConsumer { } String baseCommandObjcopy[] = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-objcopy" : - userdir + "tools/avr/bin/avr-objcopy"), + avrBasePath + "avr-objcopy", "-O", " ", "-R", diff --git a/app/Library.java b/app/Library.java index 9b31878cf..24a7eac17 100755 --- a/app/Library.java +++ b/app/Library.java @@ -315,10 +315,20 @@ public class Library implements MessageConsumer{ return false; } - String userDir = System.getProperty("user.dir") + File.separator; + String userdir = System.getProperty("user.dir") + File.separator; + String avrBasePath; + if(Base.isMacOS()) { + avrBasePath = new String("tools/avr/bin/"); + } + else if(Base.isLinux()) { + avrBasePath = new String(""); + } + else { + avrBasePath = new String(userdir + "tools/avr/bin/"); + } String[] baseCompileCommandC = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-gcc" : userDir + "tools/avr/bin/avr-gcc"), + avrBasePath + "avr-gcc", "-c", "-g", "-Os", @@ -330,7 +340,7 @@ public class Library implements MessageConsumer{ }; String[] baseCompileCommandCPP = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-g++" : userDir + "tools/avr/bin/avr-g++"), + avrBasePath + "avr-g++", "-c", "-g", "-Os", diff --git a/app/Sizer.java b/app/Sizer.java index 68efdab59..deb837fa5 100644 --- a/app/Sizer.java +++ b/app/Sizer.java @@ -40,9 +40,18 @@ public class Sizer implements MessageConsumer { public long computeSize() throws RunnerException { String userdir = System.getProperty("user.dir") + File.separator; + String avrBasePath; + if(Base.isMacOS()) { + avrBasePath = new String("tools/avr/bin/"); + } + else if(Base.isLinux()) { + avrBasePath = new String(""); + } + else { + avrBasePath = new String(userdir + "tools/avr/bin/"); + } String commandSize[] = new String[] { - ((!Base.isMacOS()) ? "tools/avr/bin/avr-size" : - userdir + "tools/avr/bin/avr-size"), + avrBasePath + "avr-size", " " }; diff --git a/app/Uploader.java b/app/Uploader.java index b4638488a..f95930576 100755 --- a/app/Uploader.java +++ b/app/Uploader.java @@ -2,7 +2,7 @@ /* Uploader - default downloader class that connects to uisp - Part of the Arduino project - http://arduino.berlios.de/ + Part of the Arduino project - http://www.arduino.cc/ Copyright (c) 2004-05 Hernando Barragan @@ -134,13 +134,23 @@ public class Uploader implements MessageConsumer { int result=0; // pre-initialized to quiet a bogus warning from jikes try { List commandDownloader = new ArrayList(); - commandDownloader.add((!Base.isMacOS() ? "" : userdir) + "tools/avr/bin/uisp"); + String avrBasePath; + if(Base.isMacOS()) { + avrBasePath = new String("tools/avr/bin/"); + } + else if(Base.isLinux()) { + avrBasePath = new String(""); + } + else { + avrBasePath = new String(userdir + "tools/avr/bin/"); + } + commandDownloader.add(avrBasePath + "uisp"); + //commandDownloader.add((!Base.isMacOS() ? "" : userdir) + "tools/avr/bin/uisp"); + if (Preferences.getBoolean("upload.verbose")) + commandDownloader.add("-v=4"); commandDownloader.add("-dpart=" + Preferences.get("build.mcu")); commandDownloader.addAll(params); //commandDownloader.add("-v=4"); // extra verbosity for help debugging. - //for(int i = 0; i < commandDownloader.length; i++) { - // System.out.println(commandDownloader[i]); - //} // Cleanup the serial buffer Serial serialPort = new Serial(); @@ -152,7 +162,14 @@ public class Uploader implements MessageConsumer { serialPort.dispose(); String[] commandArray = new String[commandDownloader.size()]; - Process process = Runtime.getRuntime().exec((String[]) commandDownloader.toArray(commandArray)); + commandDownloader.toArray(commandArray); + if (Preferences.getBoolean("upload.verbose")) { + for(int i = 0; i < commandArray.length; i++) { + System.out.print(commandArray[i] + " "); + } + System.out.println(); + } + Process process = Runtime.getRuntime().exec(commandArray); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 276e06735..2b012d1e1 100755 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -268,6 +268,7 @@ linestatus.color = #ffffff linestatus.height = 20 # set the upload defaults +upload.verbose=false upload.erase=false upload.verify=false upload.programmer=stk500