diff --git a/app/src/cc/arduino/packages/Uploader.java b/app/src/cc/arduino/packages/Uploader.java index 2b9195701e3..734cc2b7965 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.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 5bdb7d2e989..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) @@ -346,18 +343,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.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 09cb8ea3064..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); + 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 ebbbb0bcd2e..ee27f517781 100644 --- a/app/src/processing/app/helpers/ProcessUtils.java +++ b/app/src/processing/app/helpers/ProcessUtils.java @@ -1,12 +1,30 @@ package processing.app.helpers; import java.io.IOException; +import java.io.File; import processing.app.Base; public class ProcessUtils { - public static Process exec(String[] command) throws IOException { + 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) + System.out.print(c + " "); + System.out.println(); + } + // No problems on linux and mac if (!Base.isWindows()) { return Runtime.getRuntime().exec(command); diff --git a/build/build.xml b/build/build.xml index 4a89922295f..39d3bf23f7e 100644 --- a/build/build.xml +++ b/build/build.xml @@ -26,6 +26,15 @@ <condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="windows" /></condition> <condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linux32" /></condition> <condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linux64" /></condition> + <!-- Define these to false skip installing the toolchains and native + libraries. E.g., run ant -Dinstall_toolchains=false --> + <property name="install_toolchains" value="true" /> + <property name="install_native_libs" value="true" /> + <!-- Define this to true to make the $target/work/hardware/arduino + a symlink instead of a copy. This makes development easier, + because you can change core files without having to re-run ant. + Enable by passing -Dlink_hardware=true to ant. --> + <property name="link_hardware" value="false" /> <condition property="arch-bits" value="32"> <equals arg1="${platform}" arg2="linux32"/> @@ -97,8 +106,37 @@ <!-- - - - - - - - - --> <!-- Basic Assembly --> <!-- - - - - - - - - --> + <target name="clean-hardware"> + <!-- Clean up old symlink and directory --> + <symlink action="delete" link="${target.path}/hardware/arduino" failonerror="false" /> + <delete dir="${target.path}/hardware" failonerror="false" /> + <mkdir dir="${target.path}/hardware" /> + </target> + + <target name="copy-hardware" depends="clean-hardware" unless="${link_hardware}"> + <!-- copy hardware folder --> + <copy todir="${target.path}/hardware"> + <fileset dir="../hardware"> + <exclude name="arduino/sam/system/CMSIS/Device/ATMEL/*/svd/"/> + <exclude name="arduino/sam/system/CMSIS/Device/ATMEL/*/html/"/> + <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/ARM/*M0*"/> + <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/ARM/*M4*"/> + <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/GCC/*M0*"/> + <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/GCC/*M4*"/> + </fileset> + </copy> + </target> - <target name="assemble"> + <target name="link-hardware" depends="clean-hardware" if="${link_hardware}"> + <fail if="windows" + message="link_hardware not supported on Windows" /> + + <symlink link="${target.path}/hardware/arduino" + resource="${basedir}/../hardware/arduino" + failonerror="true"/> + </target> + + <target name="assemble" depends="copy-hardware, link-hardware"> <fail unless="target.path" message="Do not call assemble from the command line." /> @@ -112,18 +150,6 @@ <fileset dir="../libraries" /> </copy> - <!-- copy hardware folder --> - <copy todir="${target.path}/hardware"> - <fileset dir="../hardware"> - <exclude name="arduino/sam/system/CMSIS/Device/ATMEL/*/svd/"/> - <exclude name="arduino/sam/system/CMSIS/Device/ATMEL/*/html/"/> - <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/ARM/*M0*"/> - <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/ARM/*M4*"/> - <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/GCC/*M0*"/> - <exclude name="arduino/sam/system/CMSIS/CMSIS/Lib/GCC/*M4*"/> - </fileset> - </copy> - <!-- copy shared examples folder --> <copy todir="${target.path}/examples"> <fileset dir="shared/examples" /> @@ -198,7 +224,7 @@ <fail message="wrong platform (${os.name})" /> </target> - <target name="macosx-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build" description="Build Mac OS X version"> + <target name="macosx-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build, macosx-native-libs, macosx-toolchains" description="Build Mac OS X version"> <mkdir dir="macosx/work" /> <!-- assemble the pde --> @@ -222,9 +248,12 @@ <fileset file="shared/revisions.txt" /> </copy> - <!-- Unzip AVR tools --> - <!-- <unzip dest="macosx/work/Arduino.app/Contents/Resources/Java/hardware" src="macosx/dist/tools-universal.zip" overwrite="false"/> --> + <antcall target="assemble"> + <param name="target.path" value="macosx/work/Arduino.app/Contents/Resources/Java" /> + </antcall> + </target> + <target name="macosx-toolchains" if="${install_toolchains}"> <exec executable="unzip"> <arg value="-q" /> <arg value="-n" /> @@ -243,10 +272,6 @@ <fileset file="macosx/dist/eeprom.h" /> </copy> - <antcall target="assemble"> - <param name="target.path" value="macosx/work/Arduino.app/Contents/Resources/Java" /> - </antcall> - <antcall target="unzip-arm-toolchain"> <param name="dist_file" value="gcc-arm-none-eabi-4.4.1-2010q1-188-macos.tar.gz" /> <param name="dist_url" value="http://arduino.googlecode.com/files/gcc-arm-none-eabi-4.4.1-2010q1-188-macos.tar.gz" /> @@ -259,7 +284,9 @@ <fileset dir="macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools" includes="**/man/**/*"/> <fileset dir="macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools" includes="**/man"/> </delete> + </target> + <target name="macosx-native-libs" if="${install_native_libs}"> <get src="http://downloads.arduino.cc/libastylej-2.03.zip" dest="macosx" usetimestamp="true" /> <unzip src="macosx/libastylej-2.03.zip" dest="macosx" overwrite="true"/> <copy file="macosx/libastylej/libastylej.jnilib" todir="macosx/work/Arduino.app/Contents/Resources/Java/lib/" /> @@ -460,7 +487,22 @@ <copy todir="linux/work" file="linux/dist/arduino" /> <chmod perm="755" file="linux/work/arduino" /> + </target> + <target name="linux-native-libs" if="${install_native_libs}"> + <get src="http://downloads.arduino.cc/libastylej-2.03.zip" dest="linux" usetimestamp="true" /> + <unzip src="linux/libastylej-2.03.zip" dest="linux" overwrite="true"/> + <copy file="linux/libastylej/libastylej${arch-bits}.so" tofile="linux/work/lib/libastylej.so" /> + <chmod perm="755" file="linux/work/lib/libastylej.so" /> + </target> + + <target name="linux32-build" depends="linux-build, linux32-toolchains, linux-native-libs" + description="Build linux (32-bit) version" /> + + <target name="linux64-build" depends="linux-build, linux64-toolchains, linux-native-libs" + description="Build linux (64-bit) version" /> + + <target name="linux-toolchains" if="${install_toolchains}"> <mkdir dir="linux/work/hardware/tools" /> <copy file="linux/dist/tools/adk2install" todir="linux/work/hardware/tools" /> <copy file="linux/dist/tools/adk2tool" todir="linux/work/hardware/tools" /> @@ -472,17 +514,9 @@ <chmod perm="755" file="linux/work/hardware/tools/bossac" /> <chmod perm="755" file="linux/work/hardware/tools/adk2tool" /> <chmod perm="755" file="linux/work/hardware/tools/adk2install" /> - - <copy todir="linux/work" file="linux/dist/arduino" /> - <chmod perm="755" file="linux/work/arduino" /> - - <get src="http://downloads.arduino.cc/libastylej-2.03.zip" dest="linux" usetimestamp="true" /> - <unzip src="linux/libastylej-2.03.zip" dest="linux" overwrite="true"/> - <copy file="linux/libastylej/libastylej${arch-bits}.so" tofile="linux/work/lib/libastylej.so" /> - <chmod perm="755" file="linux/work/lib/libastylej.so" /> </target> - <target name="linux32-build" depends="linux-build" description="Build linux (32-bit) version"> + <target name="linux32-toolchains" depends="linux-toolchains" if="${install_toolchains}"> <!-- Unzip ARM tools --> <antcall target="unzip-arm-toolchain"> <param name="dist_file" value="gcc-arm-none-eabi-4.4.1-2010q1-188-linux32.tar.gz" /> @@ -495,14 +529,9 @@ <arg value="-xjf"/> <arg value="../../avr_tools_linux32.tar.bz2"/> </exec> - </target> - <target name="linux64-build" depends="linux-build" description="Build linux (64-bit) version"> - <copy tofile="linux/work/hardware/tools/avrdude" file="linux/dist/tools/avrdude64" overwrite="true" /> - - <chmod perm="755" file="linux/work/hardware/tools/avrdude" /> - + <target name="linux64-toolchains" depends="linux-toolchains" if="${install_toolchains}"> <!-- Unzip ARM tools --> <antcall target="unzip-arm-toolchain"> <param name="dist_file" value="gcc-arm-none-eabi-4.4.1-2010q1-188-linux32.tar.gz" /> @@ -637,7 +666,7 @@ </target> <target name="windows-build" - depends="revision-check, windows-checkos, subprojects-build" + depends="revision-check, windows-checkos, subprojects-build, windows-toolchains, windows-native-libs" description="Build windows version"> <mkdir dir="windows/work" /> @@ -663,28 +692,6 @@ <fileset dir="windows/dist" includes="drivers/**" /> </copy> - <!-- Unzip AVR tools --> - <get src="http://downloads.arduino.cc/WinAVR-20081205-arduino-2.zip" dest="windows" usetimestamp="true" skipexisting="true" verbose="true" /> - <unzip dest="windows/work/hardware" src="windows/WinAVR-20081205-arduino-2.zip" overwrite="false"/> - - <copy todir="windows/work/hardware/tools/avr/avr/include/avr"> - <fileset file="windows/eeprom.h" /> - </copy> - - <get src="http://downloads.arduino.cc/libastylej-2.03.zip" dest="windows" usetimestamp="true" /> - <unzip src="windows/libastylej-2.03.zip" dest="windows" overwrite="true"/> - <copy file="windows/libastylej/AStylej.dll" todir="windows/work/lib" /> - - <!-- Copy bossac.exe tool --> - <copy todir="windows/work/hardware/tools"> - <fileset file="windows/bossac.exe" /> - <fileset file="windows/listComPorts.exe" /> - </copy> - <chmod perm="755"> - <fileset file="windows/work/hardware/tools/bossac.exe" /> - <fileset file="windows/work/hardware/tools/listComPorts.exe" /> - </chmod> - <antcall target="assemble"> <param name="target.path" value="windows/work" /> </antcall> @@ -706,6 +713,32 @@ <chmod perm="755"> <fileset dir="windows/work" includes="**/*.html, **/*.dll, **/*.exe" /> </chmod> + </target> + + <target name="windows-native-libs" if="${install_native_libs}"> + <get src="http://downloads.arduino.cc/libastylej-2.03.zip" dest="windows" usetimestamp="true" /> + <unzip src="windows/libastylej-2.03.zip" dest="windows" overwrite="true"/> + <copy file="windows/libastylej/AStylej.dll" todir="windows/work/lib" /> + </target> + + <target name="windows-toolchains" if="${install_toolchains}"> + <!-- Unzip AVR tools --> + <get src="http://downloads.arduino.cc/WinAVR-20081205-arduino-2.zip" dest="windows" usetimestamp="true" skipexisting="true" verbose="true" /> + <unzip dest="windows/work/hardware" src="windows/WinAVR-20081205-arduino-2.zip" overwrite="false"/> + + <copy todir="windows/work/hardware/tools/avr/avr/include/avr"> + <fileset file="windows/eeprom.h" /> + </copy> + + <!-- Copy bossac.exe tool --> + <copy todir="windows/work/hardware/tools"> + <fileset file="windows/bossac.exe" /> + <fileset file="windows/listComPorts.exe" /> + </copy> + <chmod perm="755"> + <fileset file="windows/work/hardware/tools/bossac.exe" /> + <fileset file="windows/work/hardware/tools/listComPorts.exe" /> + </chmod> <!-- Unzip ARM toolchain --> <antcall target="unzip-arm-toolchain"> 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 diff --git a/hardware/tools/.keep b/hardware/tools/.keep deleted file mode 100644 index e69de29bb2d..00000000000