Skip to content

Commit 7ef8b06

Browse files
committed
Added clang-format download in build.xml
1 parent 4a1ef0f commit 7ef8b06

9 files changed

+42
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ build/windows/launch4j-*.zip
2929
build/windows/launcher/launch4j
3030
build/windows/WinAVR-*.zip
3131
build/macosx/arduino-*.zip
32+
build/macosx/clang*.zip
3233
build/macosx/dist/*.tar.gz
3334
build/macosx/dist/*.tar.bz2
3435
build/macosx/*.tar.bz2

app/src/cc/arduino/packages/formatter/clangformat/ClangFormat.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@
4040
import org.apache.commons.compress.utils.IOUtils;
4141
import org.apache.logging.log4j.core.util.NullOutputStream;
4242

43+
import processing.app.Base;
4344
import processing.app.Editor;
4445
import processing.app.helpers.ProcessUtils;
4546
import processing.app.tools.Tool;
4647

4748
public class ClangFormat implements Tool {
4849

50+
private final String clangExecutable = Base.getContentFile("clang-format")
51+
.getAbsolutePath();
4952
private Editor editor;
5053

5154
public ClangFormat() {
@@ -103,7 +106,7 @@ private Thread copyAndClose(InputStream input, OutputStream output) {
103106

104107
String runClangFormatOn(String source)
105108
throws IOException, InterruptedException {
106-
String cmd[] = new String[] { "clang-format" };
109+
String cmd[] = new String[] { clangExecutable };
107110

108111
Process process = ProcessUtils.exec(cmd);
109112
ByteArrayOutputStream result = new ByteArrayOutputStream();

build/build.xml

+31
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linuxarm" /></condition>
5151
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linuxaarch64" /></condition>
5252

53+
<condition property="download_os" value="macOS_64bit"><equals arg1="${platform}" arg2="macosx" /></condition>
54+
<condition property="download_os" value="Windows_32bit"><equals arg1="${platform}" arg2="windows" /></condition>
55+
<condition property="download_os" value="Linux_32bit"><equals arg1="${platform}" arg2="linux32" /></condition>
56+
<condition property="download_os" value="Linux_64bit"><equals arg1="${platform}" arg2="linux64" /></condition>
57+
<condition property="download_os" value="Linux_ARMv6"><equals arg1="${platform}" arg2="linuxarm" /></condition>
58+
<condition property="download_os" value="Linux_ARM64"><equals arg1="${platform}" arg2="linuxaarch64" /></condition>
59+
60+
<condition property="exec_ext" value=".exe"><isset property="windows" /></condition>
61+
<property name="exec_ext" value="" />
62+
5363
<condition property="arch-bits" value="32">
5464
<equals arg1="${platform}" arg2="linux32"/>
5565
</condition>
@@ -108,6 +118,7 @@
108118
<property name="WIFI101-FW-UPDATER_VERSION" value="0.11.0" />
109119
<!-- https://github.com/arduino/built-in-examples -->
110120
<property name="BUILT-IN-EXAMPLES-VERSION" value="1.9.1" />
121+
<property name="CLANG-FORMAT-VERSION" value="12.0.0" />
111122

112123
<!-- Libraries required for running arduino -->
113124
<fileset dir=".." id="runtime.jars">
@@ -223,6 +234,8 @@
223234

224235
<antcall target="assemble-libraries" />
225236

237+
<antcall target="assemble-clang-format" />
238+
226239
<!-- Add WiFi101 updater tool -->
227240
<antcall target="unzip">
228241
<param name="archive_file" value="shared/WiFi101-Updater-ArduinoIDE-Plugin-${WIFI101-FW-UPDATER_VERSION}.zip" />
@@ -316,6 +329,24 @@
316329
<copy file="../hardware/package_index_bundled.json" todir="${target.path}/hardware/" />
317330
</target>
318331

332+
<!-- clang-format -->
333+
<target name="assemble-clang-format" unless="light_bundle">
334+
<property name="clang_arch_name" value="clang_${CLANG-FORMAT-VERSION}_${download_os}" />
335+
<antcall target="unzip">
336+
<param name="archive_file" value="${staging_folder}/${clang_arch_name}.zip"/>
337+
<param name="archive_url" value="https://github.com/arduino/clang-static-binaries/releases/download/${CLANG-FORMAT-VERSION}/${clang_arch_name}.zip"/>
338+
<param name="dest_folder" value="${staging_folder}/${clang_arch_name}/"/>
339+
<param name="final_folder" value="${staging_folder}/${clang_arch_name}/clang-format"/>
340+
</antcall>
341+
342+
<copy file="${staging_folder}/${clang_arch_name}/clang-format${exec_ext}" tofile="${staging_folder}/work/${staging_hardware_folder}/../clang-format${exec_ext}" overwrite="true"/>
343+
<antcall target="make-file-executable">
344+
<param name="file" value="${staging_folder}/work/${staging_hardware_folder}/../clang-format${exec_ext}" />
345+
</antcall>
346+
347+
<delete dir="${staging_folder}/${clang_arch_name}"/>
348+
</target>
349+
319350
<!-- - - - - - - - - -->
320351
<!-- Revision check -->
321352
<!-- - - - - - - - - -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b10e77fb79a41880766439dc65cd8aaa328af5bc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e3fe347cdb2e4b7b1c92b8e21b4aae49eeaaad55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a81b7e8c6c5922fbcd423228f13a1148a91a3932
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d10ae0b04eadf9fd0fa52d16549a2c6bec482738
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
154b62e3062b5040594155702c7c7508d18c6b3a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d2a5246fed18b61d96de49887e16520be5dad944

0 commit comments

Comments
 (0)