Skip to content

Building the IDE without bundling the toolchain #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7 changes: 1 addition & 6 deletions app/src/cc/arduino/packages/Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 0 additions & 10 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
11 changes: 1 addition & 10 deletions app/src/processing/app/debug/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/src/processing/app/debug/Sizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
20 changes: 19 additions & 1 deletion app/src/processing/app/helpers/ProcessUtils.java
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
149 changes: 91 additions & 58 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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." />

Expand All @@ -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" />
Expand Down Expand Up @@ -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 -->
Expand All @@ -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" />
Expand All @@ -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" />
Expand All @@ -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/" />
Expand Down Expand Up @@ -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" />
Expand All @@ -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" />
Expand All @@ -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" />
Expand Down Expand Up @@ -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" />

Expand All @@ -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>
Expand All @@ -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">
Expand Down
3 changes: 1 addition & 2 deletions hardware/arduino/avr/platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file removed hardware/tools/.keep
Empty file.