Skip to content

Commit cfd8472

Browse files
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.
1 parent c7c0461 commit cfd8472

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Diff for: build/build.xml

+23-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
libraries. E.g., run ant -Dinstall_toolchains=false -->
3131
<property name="install_toolchains" value="true" />
3232
<property name="install_native_libs" value="true" />
33+
<!-- Define this to true to make the $target/work/hardware/arduino
34+
a symlink instead of a copy. This makes development easier,
35+
because you can change core files without having to re-run ant.
36+
Enable by passing -Dlink_hardware=true to ant. -->
37+
<property name="link_hardware" value="false" />
3338

3439
<condition property="arch-bits" value="32">
3540
<equals arg1="${platform}" arg2="linux32"/>
@@ -101,7 +106,14 @@
101106
<!-- - - - - - - - - -->
102107
<!-- Basic Assembly -->
103108
<!-- - - - - - - - - -->
104-
<target name="copy-hardware">
109+
<target name="clean-hardware">
110+
<!-- Clean up old symlink and directory -->
111+
<symlink action="delete" link="${target.path}/hardware/arduino" failonerror="false" />
112+
<delete dir="${target.path}/hardware" failonerror="false" />
113+
<mkdir dir="${target.path}/hardware" />
114+
</target>
115+
116+
<target name="copy-hardware" depends="clean-hardware" unless="${link_hardware}">
105117
<!-- copy hardware folder -->
106118
<copy todir="${target.path}/hardware">
107119
<fileset dir="../hardware">
@@ -115,7 +127,16 @@
115127
</copy>
116128
</target>
117129

118-
<target name="assemble" depends="copy-hardware">
130+
<target name="link-hardware" depends="clean-hardware" if="${link_hardware}">
131+
<fail if="windows"
132+
message="link_hardware not supported on Windows" />
133+
134+
<symlink link="${target.path}/hardware/arduino"
135+
resource="${basedir}/../hardware/arduino"
136+
failonerror="true"/>
137+
</target>
138+
139+
<target name="assemble" depends="copy-hardware, link-hardware">
119140
<fail unless="target.path"
120141
message="Do not call assemble from the command line." />
121142

0 commit comments

Comments
 (0)