From ea8b7ffb87986835be38a8e62a17309ea07f5aac Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 4 Dec 2013 20:48:07 +0100 Subject: [PATCH 1/8] Remove duplicate actions from build.xml The arduino script was copied into the output directory twice in the linux-build target. The avrdude64 binary was copied both by the linux-build and linux64-build targets. --- build/build.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build/build.xml b/build/build.xml index 4a89922295f..ebee60a1d90 100644 --- a/build/build.xml +++ b/build/build.xml @@ -473,9 +473,6 @@ - - - @@ -499,10 +496,6 @@ - - - - From 94985181741add79dcb9f13b9845c02e0af9b25b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 4 Dec 2013 21:17:50 +0100 Subject: [PATCH 2/8] Split off toolchain and native library installs in build.xml This doesn't change anything except a bit of ordering in the build, but prepares for making these steps optional. --- build/build.xml | 90 ++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/build/build.xml b/build/build.xml index ebee60a1d90..d8695922c89 100644 --- a/build/build.xml +++ b/build/build.xml @@ -198,7 +198,7 @@ - + @@ -222,9 +222,12 @@ - - + + + + + @@ -243,10 +246,6 @@ - - - - @@ -259,7 +258,9 @@ + + @@ -460,7 +461,22 @@ + + + + + + + + + + + + + @@ -472,14 +488,9 @@ - - - - - - + @@ -492,10 +503,9 @@ - - + @@ -630,7 +640,7 @@ @@ -656,28 +666,6 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -699,6 +687,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + From 60ca108bd61735464d96c81deba3ac176309e280 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 4 Dec 2013 22:08:13 +0100 Subject: [PATCH 3/8] Make installing toolchains and native libraries optional If you pass -Dinstall_toolchains=false or -Dinstall_native_libs=false to the ant command, the toolchains or native libraries will not be installed into the build/work directory, making the IDE fall back on the system versions instead. This is intended for advanced users who run from git and want to use their system toolchain or libraries. These toolchain-less installs are not intended to be distributed as tarballs. --- build/build.xml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build/build.xml b/build/build.xml index d8695922c89..251b56b4818 100644 --- a/build/build.xml +++ b/build/build.xml @@ -26,6 +26,10 @@ + + + @@ -227,7 +231,7 @@ - + @@ -260,7 +264,7 @@ - + @@ -463,7 +467,7 @@ - + @@ -476,7 +480,7 @@ - + @@ -490,7 +494,7 @@ - + @@ -505,7 +509,7 @@ - + @@ -689,13 +693,13 @@ - + - + From 179720e7fedcff973a6b52cf1db10af7fbc30045 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 5 Dec 2013 10:36:51 +0100 Subject: [PATCH 4/8] Split off hardware folder copying in build.xml This shouldn't change anything except a bit of ordering, but prepares for the next commit. --- build/build.xml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/build/build.xml b/build/build.xml index 251b56b4818..c0f7c799285 100644 --- a/build/build.xml +++ b/build/build.xml @@ -101,8 +101,21 @@ + + + + + + + + + + + + + - + @@ -116,18 +129,6 @@ - - - - - - - - - - - - From c7c04618c4893fa523870b1b3d68bdf9788f62ab Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 5 Dec 2013 11:01:04 +0100 Subject: [PATCH 5/8] Remove hardware/tools folder This folder is automatically created by the buildsystem inside the $platform/work directory already, so no need to carry an empty folder here. --- hardware/tools/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 hardware/tools/.keep diff --git a/hardware/tools/.keep b/hardware/tools/.keep deleted file mode 100644 index e69de29bb2d..00000000000 From cfd8472c1ca73d0d6853153ba30460e4585be9b0 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 5 Dec 2013 11:52:24 +0100 Subject: [PATCH 6/8] Allow making $platform/work/hardware/arduino a symlink This allows easily changing the arduino core files during development, without having to re-run ant on every build. This feature can be switched on by running ant -Dlink_harware=true. This also adds a clean-hardware target, to remove the work/hardware directory during the build. This is needed to prevent problems when switching the linking on and off. As an additional feature, if you remove any files from the hardware/arduino directory, they'll actually get removed from the resulting build now as well. The actual deleting of the symlinks is a bit of a mess, since ant's symlink support is a bit weird and underdocumented. --- build/build.xml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/build/build.xml b/build/build.xml index c0f7c799285..39d3bf23f7e 100644 --- a/build/build.xml +++ b/build/build.xml @@ -30,6 +30,11 @@ libraries. E.g., run ant -Dinstall_toolchains=false --> + + @@ -101,7 +106,14 @@ - + + + + + + + + @@ -115,7 +127,16 @@ - + + + + + + + From 7c8157f180783326d64d56f56f5e857cc7c4d324 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 5 Dec 2013 14:52:12 +0100 Subject: [PATCH 7/8] Move command printing into ProcessUtils::exec This removes some duplicate code, and prepares for the next commit. --- app/src/cc/arduino/packages/Uploader.java | 7 +------ app/src/processing/app/debug/Compiler.java | 8 +------- app/src/processing/app/debug/Sizer.java | 2 +- app/src/processing/app/helpers/ProcessUtils.java | 8 +++++++- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/app/src/cc/arduino/packages/Uploader.java b/app/src/cc/arduino/packages/Uploader.java index 2b9195701e3..e70d07a4361 100644 --- a/app/src/cc/arduino/packages/Uploader.java +++ b/app/src/cc/arduino/packages/Uploader.java @@ -94,12 +94,7 @@ protected boolean executeUploadCommand(String command[]) throws Exception { int result = -1; try { - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - Process process = ProcessUtils.exec(command); + Process process = ProcessUtils.exec(command, verbose); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 5bdb7d2e989..e94a4d59e24 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -346,18 +346,12 @@ private void execAsynchronously(String[] command) throws RunnerException { return; int result = 0; - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - firstErrorFound = false; // haven't found any errors yet secondErrorFound = false; Process process; try { - process = ProcessUtils.exec(command); + process = ProcessUtils.exec(command, verbose); } catch (IOException e) { RunnerException re = new RunnerException(e.getMessage()); re.hideStackTrace(); diff --git a/app/src/processing/app/debug/Sizer.java b/app/src/processing/app/debug/Sizer.java index 09cb8ea3064..b24dfb68a1e 100644 --- a/app/src/processing/app/debug/Sizer.java +++ b/app/src/processing/app/debug/Sizer.java @@ -68,7 +68,7 @@ public long[] computeSize() throws RunnerException { textSize = -1; dataSize = -1; eepromSize = -1; - Process process = ProcessUtils.exec(cmd); + Process process = ProcessUtils.exec(cmd, false); MessageSiphon in = new MessageSiphon(process.getInputStream(), this); MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); diff --git a/app/src/processing/app/helpers/ProcessUtils.java b/app/src/processing/app/helpers/ProcessUtils.java index ebbbb0bcd2e..0eaa1d252ef 100644 --- a/app/src/processing/app/helpers/ProcessUtils.java +++ b/app/src/processing/app/helpers/ProcessUtils.java @@ -6,7 +6,13 @@ public class ProcessUtils { - public static Process exec(String[] command) throws IOException { + public static Process exec(String[] command, boolean print) throws IOException { + if (print) { + for (String c : command) + System.out.print(c + " "); + System.out.println(); + } + // No problems on linux and mac if (!Base.isWindows()) { return Runtime.getRuntime().exec(command); From a69eb7e4829f3d098e9ad25d4e925b8f58270424 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 5 Dec 2013 13:44:40 +0100 Subject: [PATCH 8/8] Fall back to system uploader tools Before, when no bundled compiler was available, the IDE would fall back to using system-wide commands. For the uploader tools, the IDE wouold try to execute a non-existent tool and show an error. This commit implements this in a more generic way: Whenever executing an external command, if the full path to the command could not be found, strip the path and let the system shell find the command in the regular places. Because of this, the previous special handling of compiler.path is removed and the variable is explicitely defined in avr/platform.txt. sam/platform.txt already contained an explicit definition of compiler.path. --- app/src/cc/arduino/packages/Uploader.java | 2 +- app/src/processing/app/Base.java | 10 ---------- app/src/processing/app/debug/Compiler.java | 5 +---- app/src/processing/app/debug/Sizer.java | 2 +- app/src/processing/app/helpers/ProcessUtils.java | 12 ++++++++++++ hardware/arduino/avr/platform.txt | 3 +-- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/src/cc/arduino/packages/Uploader.java b/app/src/cc/arduino/packages/Uploader.java index e70d07a4361..734cc2b7965 100644 --- a/app/src/cc/arduino/packages/Uploader.java +++ b/app/src/cc/arduino/packages/Uploader.java @@ -94,7 +94,7 @@ protected boolean executeUploadCommand(String command[]) throws Exception { int result = -1; try { - Process process = ProcessUtils.exec(command, verbose); + Process process = ProcessUtils.execWithSystemFallback(command, verbose); new MessageSiphon(process.getInputStream(), this); new MessageSiphon(process.getErrorStream(), this); diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 5f351f76477..3f544ed1c7a 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2048,16 +2048,6 @@ static public String getHardwarePath() { return getHardwareFolder().getAbsolutePath(); } - - static public String getAvrBasePath() { - String path = getHardwarePath() + File.separator + "tools" + - File.separator + "avr" + File.separator + "bin" + File.separator; - if (Base.isLinux() && !(new File(path)).exists()) { - return ""; // use distribution provided avr tools if bundled tools missing - } - return path; - } - /** * Returns a specific TargetPackage * diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index e94a4d59e24..9b203839406 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -180,9 +180,6 @@ private PreferencesMap createBuildPreferences(String _buildPath, targetArch = targetPlatform.getId(); p.put("build.arch", targetArch.toUpperCase()); - if (!p.containsKey("compiler.path")) - p.put("compiler.path", Base.getAvrBasePath()); - // Core folder TargetPlatform tp = corePlatform; if (tp == null) @@ -351,7 +348,7 @@ private void execAsynchronously(String[] command) throws RunnerException { Process process; try { - process = ProcessUtils.exec(command, verbose); + process = ProcessUtils.execWithSystemFallback(command, verbose); } catch (IOException e) { RunnerException re = new RunnerException(e.getMessage()); re.hideStackTrace(); diff --git a/app/src/processing/app/debug/Sizer.java b/app/src/processing/app/debug/Sizer.java index b24dfb68a1e..6b443407fec 100644 --- a/app/src/processing/app/debug/Sizer.java +++ b/app/src/processing/app/debug/Sizer.java @@ -68,7 +68,7 @@ public long[] computeSize() throws RunnerException { textSize = -1; dataSize = -1; eepromSize = -1; - Process process = ProcessUtils.exec(cmd, false); + Process process = ProcessUtils.execWithSystemFallback(cmd, false); MessageSiphon in = new MessageSiphon(process.getInputStream(), this); MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); diff --git a/app/src/processing/app/helpers/ProcessUtils.java b/app/src/processing/app/helpers/ProcessUtils.java index 0eaa1d252ef..ee27f517781 100644 --- a/app/src/processing/app/helpers/ProcessUtils.java +++ b/app/src/processing/app/helpers/ProcessUtils.java @@ -1,11 +1,23 @@ package processing.app.helpers; import java.io.IOException; +import java.io.File; import processing.app.Base; public class ProcessUtils { + public static Process execWithSystemFallback(String[] command, boolean print) throws IOException { + File path = new File(command[0]); + if (!path.exists()) { + String[] newcmd = command.clone(); + newcmd[0] = path.getName(); + return exec(newcmd, print); + } else { + return exec(command, print); + } + } + public static Process exec(String[] command, boolean print) throws IOException { if (print) { for (String c : command) diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt index 4e28f0a38d9..a6b82038400 100644 --- a/hardware/arduino/avr/platform.txt +++ b/hardware/arduino/avr/platform.txt @@ -11,8 +11,7 @@ version=1.5.5 # AVR compile variables # --------------------- -# Default "compiler.path" is correct, change only if you want to overidde the initial value -#compiler.path={ide.path}/tools/avr/bin/.. +compiler.path={runtime.ide.path}/hardware/tools/avr/bin/ compiler.c.cmd=avr-gcc compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD compiler.c.elf.flags=-Os -Wl,--gc-sections