Skip to content
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

Use clang-format for auto-format (replaces libastyle) #11543

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ build/windows/launch4j-*.zip
build/windows/launcher/launch4j
build/windows/WinAVR-*.zip
build/macosx/arduino-*.zip
build/macosx/clang*.zip
build/macosx/dist/*.tar.gz
build/macosx/dist/*.tar.bz2
build/macosx/*.tar.bz2
98 changes: 0 additions & 98 deletions app/src/cc/arduino/packages/formatter/AStyle.java

This file was deleted.

90 changes: 0 additions & 90 deletions app/src/cc/arduino/packages/formatter/AStyleInterface.java

This file was deleted.

186 changes: 186 additions & 0 deletions app/src/cc/arduino/packages/formatter/clangformat/ClangFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* This file is part of Arduino.
*
* Arduino is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* Copyright 2021 Arduino LLC (http://www.arduino.cc/)
*/

package cc.arduino.packages.formatter.clangformat;

import static processing.app.I18n.tr;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.commons.compress.utils.IOUtils;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import processing.app.Base;
import processing.app.BaseNoGui;
import processing.app.Editor;
import processing.app.syntax.SketchTextArea;

public class ClangFormat implements Runnable {

private final String clangExecutable = Base.getContentFile("clang-format")
.getAbsolutePath();
private Editor editor;

public ClangFormat(Editor editor) {
this.editor = editor;
}

@Override
public void run() {
SketchTextArea tab = editor.getCurrentTab().getTextArea();
String originalText = tab.getText();
int cursorOffset = tab.getCaretPosition();
try {
FormatResult result = runClangFormatOn(originalText, cursorOffset);
if (result.FormattedText.equals(originalText)) {
editor.statusNotice(tr("No changes necessary for Auto Format."));
return;
}

// To keep cursor position after UNDO we produce a bogus edit (insertion
// and removal of a " " at cursor position) and we compound this change
// with the full auto-format update.
tab.beginAtomicEdit();
tab.insert(" ", cursorOffset);
tab.replaceRange("", cursorOffset, cursorOffset + 1);
tab.setText(result.FormattedText);
tab.endAtomicEdit();

tab.setCaretPosition(result.Cursor);

editor.statusNotice(tr("Auto Format finished."));
} catch (IOException | InterruptedException e) {
editor.statusError("Auto format error: " + e.getMessage());
e.printStackTrace();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Care to removee e.printStackTrace();?

} catch (ClangException e) {
editor.statusError("Auto format error: " + e.getMessage());
}
}

private Thread copyAndClose(InputStream input, OutputStream output) {
Thread t = new Thread(() -> {
try {
IOUtils.copy(input, output);
} catch (IOException e) {
e.printStackTrace();
}
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
});
t.start();
return t;
}

private File findConfigFile() {
// check if sketch has a config file
File sketchDir = editor.getSketch().getFolder();
if (new File(sketchDir, ".clang-format").isFile()) {
return sketchDir;
}

// check if a global config file exists
if (BaseNoGui.getSettingsFile(".clang-format").isFile()) {
return BaseNoGui.getSettingsFolder();
}

// otherwise: no custom configs, return Arduino IDE app dir.
return new File(clangExecutable).getParentFile();
}

FormatResult runClangFormatOn(String source, int cursorOffset)
throws IOException, InterruptedException, ClangException {
String cmd[] = new String[] { clangExecutable, "--cursor=" + cursorOffset };

Process process = Runtime.getRuntime().exec(cmd, null, findConfigFile());
ByteArrayOutputStream clangOutput = new ByteArrayOutputStream();
ByteArrayOutputStream clangError = new ByteArrayOutputStream();
ByteArrayInputStream dataOut = new ByteArrayInputStream(source.getBytes());

Thread in = copyAndClose(dataOut, process.getOutputStream());
Thread err = copyAndClose(process.getErrorStream(), clangError);
Thread out = copyAndClose(process.getInputStream(), clangOutput);

int r = process.waitFor();
in.join();
out.join();
err.join();

if (r != 0) {
throw new ClangException(clangError.toString());
}

// clang-format will output first a JSON object with:
// - the resulting cursor position and
// - a flag teling if the conversion was successful
// for example:
//
// { "Cursor": 34, "IncompleteFormat": false }
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
FormatResult res = mapper.readValue(clangOutput.toByteArray(),
FormatResult.class);

// After the JSON object above clang-format will output the formatted source
// code in plain text
String formattedText = clangOutput.toString();
formattedText = formattedText.substring(formattedText.indexOf('}') + 1);
// handle different line endings
res.FormattedText = formattedText.replaceFirst("\\R", "");
return res;
}
}

class ClangException extends Exception {
public ClangException(String string) {
super(string);
}
}

class FormatResult {
public String FormattedText;
public int Cursor;
public boolean IncompleteFormat;
}
31 changes: 14 additions & 17 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.MonitorFactory;
import cc.arduino.packages.Uploader;
import cc.arduino.packages.formatter.clangformat.ClangFormat;
import cc.arduino.packages.uploaders.SerialUploader;
import cc.arduino.view.GoToLineNumber;
import cc.arduino.view.StubMenuListener;
@@ -234,13 +235,15 @@ public boolean test(SketchController controller) {
private UploadHandler uploadUsingProgrammerHandler;
private Runnable timeoutUploadHandler;

private Map<String, Tool> internalToolCache = new HashMap<String, Tool>();
private Map<String, Tool> internalToolCache = new HashMap<>();

final ClangFormat formatter;

public Editor(Base ibase, File file, int[] storedLocation, int[] defaultLocation, Platform platform) throws Exception {
super("Arduino");
this.base = ibase;
this.platform = platform;

this.formatter = new ClangFormat(this);
Base.setIcon(this);

// Install default actions for Run, Present, etc.
@@ -981,24 +984,19 @@ private Tool getOrCreateToolInstance(String className) {
}

private void addInternalTools(JMenu menu) {
JMenuItem item;

item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
if (item == null) {
throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
}
item.setName("menuToolsAutoFormat");
JMenuItem autoFormat = new JMenuItem(tr("Auto Format"));
autoFormat.setName("menuToolsAutoFormat");
autoFormat.addActionListener(event -> SwingUtilities.invokeLater(formatter));
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
menu.add(item);
autoFormat.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
menu.add(autoFormat);

//menu.add(createToolMenuItem("processing.app.tools.CreateFont"));
//menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
// menu.add(createToolMenuItem("processing.app.tools.CreateFont"));
// menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
Comment on lines +994 to +995
Copy link

@silvanocerza silvanocerza May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just remove these comments?

menu.add(createToolMenuItem("processing.app.tools.Archiver"));
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
}


private void selectSerialPort(String name) {
if(portMenu == null) {
System.out.println(tr("serialMenu is null"));
@@ -1837,7 +1835,7 @@ public void updateTitle() {
SketchFile current = getCurrentTab().getSketchFile();
String customFormat = PreferencesData.get("editor.custom_title_format");
if (customFormat != null && !customFormat.trim().isEmpty()) {
Map<String, String> titleMap = new HashMap<String, String>();
Map<String, String> titleMap = new HashMap<>();
titleMap.put("file", current.getFileName());
String path = sketch.getFolder().getAbsolutePath();
titleMap.put("folder", path);
@@ -1896,8 +1894,7 @@ private boolean handleSave2() {
boolean saved = false;
try {
if (PreferencesData.getBoolean("editor.autoformat_currentfile_before_saving")) {
Tool formatTool = getOrCreateToolInstance("cc.arduino.packages.formatter.AStyle");
formatTool.run();
formatter.run();
}

boolean wasReadOnly = sketchController.isReadOnly();
14 changes: 6 additions & 8 deletions app/src/processing/app/EditorTab.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.border.MatteBorder;
import javax.swing.event.PopupMenuEvent;
@@ -197,15 +198,12 @@ private void configurePopupMenu(final SketchTextArea textarea){

menu.addSeparator();

JMenuItem item = editor.createToolMenuItem("cc.arduino.packages.formatter.AStyle");
if (item == null) {
throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
}
item.setName("menuToolsAutoFormat");

menu.add(item);
JMenuItem autoFormat = new JMenuItem(tr("Auto Format"));
autoFormat.addActionListener(event -> SwingUtilities.invokeLater(editor.formatter));
autoFormat.setName("menuToolsAutoFormat");
menu.add(autoFormat);

item = new JMenuItem(tr("Comment/Uncomment"), '/');
JMenuItem item = new JMenuItem(tr("Comment/Uncomment"), '/');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCommentUncomment();
Original file line number Diff line number Diff line change
@@ -48,12 +48,10 @@ public class AutoformatProducesOneUndoActionTest extends AbstractGUITest {
"}";
public static final String SOURCE_AFTER = "void setup() {\n" +
" // put your setup code here, to run once:\n" +
"\n" +
"}\n" +
"\n" +
"void loop() {\n" +
" // put your main code here, to run repeatedly:\n" +
"\n" +
"}";

@Test
@@ -74,7 +72,8 @@ public void shouldSaveCaretPositionAfterAutoformat() {
String formattedText = editor.getText();
assertEquals(SOURCE_AFTER, formattedText);

assertEquals(29, editor.getCaretPosition());
// Autoformat with clang-format keeps cursor relative to source code
assertEquals(17, editor.getCaretPosition());

menuEditUndo.requireEnabled();
menuEditUndo.click();
5 changes: 2 additions & 3 deletions app/test/processing/app/AutoformatSavesCaretPositionTest.java
Original file line number Diff line number Diff line change
@@ -60,15 +60,14 @@ public void shouldSaveCaretPositionAfterAutoformat() {
String formattedText = editor.getText();
assertEquals("void setup() {\n" +
" // put your setup code here, to run once:\n" +
"\n" +
"}\n" +
"\n" +
"void loop() {\n" +
" // put your main code here, to run repeatedly:\n" +
"\n" +
"}", formattedText);

assertEquals(29, editor.getCaretPosition());
// Autoformat with clang-format keeps cursor relative to source code
assertEquals(17, editor.getCaretPosition());

}

4 changes: 2 additions & 2 deletions app/test/processing/app/AutoformatTest.java
Original file line number Diff line number Diff line change
@@ -58,8 +58,8 @@ public void shouldProduceNicelyFormattedCode() throws Exception {
String formattedText = editor.getText();
assertEquals("void setup() {\n" +
" // put your setup code here, to run once:\n" +
" int foo[] = { 1, 2, 3, 4, 5};\n" +
" int foo[2][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};\n" +
" int foo[] = { 1, 2, 3, 4, 5 };\n" +
" int foo[2][5] = { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 } };\n" +
"}\n" +
"\n" +
"void loop() {\n" +
94 changes: 40 additions & 54 deletions build/build.xml
Original file line number Diff line number Diff line change
@@ -50,6 +50,16 @@
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linuxarm" /></condition>
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linuxaarch64" /></condition>

<condition property="download_os" value="macOS_64bit"><equals arg1="${platform}" arg2="macosx" /></condition>
<condition property="download_os" value="Windows_32bit"><equals arg1="${platform}" arg2="windows" /></condition>
<condition property="download_os" value="Linux_32bit"><equals arg1="${platform}" arg2="linux32" /></condition>
<condition property="download_os" value="Linux_64bit"><equals arg1="${platform}" arg2="linux64" /></condition>
<condition property="download_os" value="Linux_ARMv6"><equals arg1="${platform}" arg2="linuxarm" /></condition>
<condition property="download_os" value="Linux_ARM64"><equals arg1="${platform}" arg2="linuxaarch64" /></condition>

<condition property="exec_ext" value=".exe"><isset property="windows" /></condition>
<property name="exec_ext" value="" />

<condition property="arch-bits" value="32">
<equals arg1="${platform}" arg2="linux32"/>
</condition>
@@ -108,6 +118,7 @@
<property name="WIFI101-FW-UPDATER_VERSION" value="0.11.0" />
<!-- https://github.com/arduino/built-in-examples -->
<property name="BUILT-IN-EXAMPLES-VERSION" value="1.9.1" />
<property name="CLANG-FORMAT-VERSION" value="12.0.0" />

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

<antcall target="assemble-libraries" />

<antcall target="assemble-clang-format" />

<!-- Add WiFi101 updater tool -->
<antcall target="unzip">
<param name="archive_file" value="shared/WiFi101-Updater-ArduinoIDE-Plugin-${WIFI101-FW-UPDATER_VERSION}.zip" />
@@ -316,6 +329,26 @@
<copy file="../hardware/package_index_bundled.json" todir="${target.path}/hardware/" />
</target>

<!-- clang-format -->
<target name="assemble-clang-format" unless="light_bundle">
<property name="clang_arch_name" value="clang_${CLANG-FORMAT-VERSION}_${download_os}" />
<antcall target="unzip">
<param name="archive_file" value="${staging_folder}/${clang_arch_name}.zip"/>
<param name="archive_url" value="https://github.com/arduino/clang-static-binaries/releases/download/${CLANG-FORMAT-VERSION}/${clang_arch_name}.zip"/>
<param name="dest_folder" value="${staging_folder}/${clang_arch_name}/"/>
<param name="final_folder" value="${staging_folder}/${clang_arch_name}/clang-format"/>
</antcall>

<copy file="${staging_folder}/${clang_arch_name}/clang-format${exec_ext}" tofile="${staging_folder}/work/${staging_hardware_folder}/../clang-format${exec_ext}" overwrite="true"/>
<antcall target="make-file-executable">
<param name="file" value="${staging_folder}/work/${staging_hardware_folder}/../clang-format${exec_ext}" />
</antcall>

<delete dir="${staging_folder}/${clang_arch_name}"/>

<copy file="shared/clang-format-arduino" tofile="${staging_folder}/work/${staging_hardware_folder}/../.clang-format" />
</target>

<!-- - - - - - - - - -->
<!-- Revision check -->
<!-- - - - - - - - - -->
@@ -492,17 +525,6 @@
<param name="target.path" value="${staging_folder}/work/${staging_hardware_folder}/.." />
</antcall>

<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.1-5.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/libastylej-2.05.1-5.zip" />
<param name="final_folder" value="${staging_folder}/libastylej-2.05.1" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="macosx/libastylej-2.05.1/libastylej.jnilib" todir="macosx/work/${staging_hardware_folder}/../lib/" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../lib/libastylej.jnilib" />
<copy file="macosx/libastylej-2.05.1/libastylej.jnilib" tofile="macosx/work/${staging_hardware_folder}/../lib/libastylej.dylib" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../lib/libastylej.dylib" />

<antcall target="unzip">
<param name="archive_file" value="./liblistSerials-${LIBLISTSERIAL-VERSION}.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/liblistSerials/liblistSerials-${LIBLISTSERIAL-VERSION}.zip" />
@@ -680,16 +702,7 @@
</chmod>
</target>

<target name="linux-libastyle-x86" depends="linux-build" description="Download libastyle.so for x86/x64 arch">
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.1-5.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/libastylej-2.05.1-5.zip" />
<param name="final_folder" value="${staging_folder}/libastylej-2.05.1" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="linux/libastylej-2.05.1/libastylej${arch-bits}.so" tofile="linux/work/lib/libastylej.so" />
<chmod perm="755" file="linux/work/lib/libastylej.so" />

<target name="linux-liblistserials-x86" depends="linux-build" description="Download liblistserials.so for x86/x64 arch">
<antcall target="portable-${portable}">
<param name="parentdir" value="linux/work" />
</antcall>
@@ -702,19 +715,9 @@
</antcall>
<copy file="linux/liblistSerials-${LIBLISTSERIAL-VERSION}/linux${arch-bits}/liblistSerialsj.so" todir="linux/work/lib/" />
<chmod perm="755" file="linux/work/lib/liblistSerialsj.so" />

</target>

<target name="linux-libastyle-arm" depends="linux-build" description="Download libastyle.so for ARM">
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.1-5.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/libastylej-2.05.1-5.zip" />
<param name="final_folder" value="${staging_folder}/libastylej-2.05.1" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="linux/libastylej-2.05.1/libastylej_arm.so" tofile="linux/work/lib/libastylej.so" />
<chmod perm="755" file="linux/work/lib/libastylej.so" />

<target name="linux-liblistserials-arm" depends="linux-build" description="Download liblistserials.so for ARM">
<antcall target="portable-${portable}">
<param name="parentdir" value="linux/work" />
</antcall>
@@ -727,10 +730,9 @@
</antcall>
<copy file="linux/liblistSerials-${LIBLISTSERIAL-VERSION}/arm/liblistSerialsj.so" todir="linux/work/lib/" />
<chmod perm="755" file="linux/work/lib/liblistSerialsj.so" />

</target>

<target name="linuxarm-build" depends="linux-libastyle-arm" description="Build linux (32-bit) version">
<target name="linuxarm-build" depends="linux-liblistserials-arm" description="Build linux (32-bit) version">
<antcall target="linux-jvm-${linux-bundle-jvm-task}">
<param name="JVM" value="${LINUXARM_BUNDLED_JVM}"/>
</antcall>
@@ -748,16 +750,7 @@
</antcall>
</target>

<target name="linux-libastyle-aarch64" depends="linux-build" description="Download libastyle.so for AArch64">
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.1-5.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/libastylej-2.05.1-5.zip" />
<param name="final_folder" value="${staging_folder}/libastylej-2.05.1" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="linux/libastylej-2.05.1/libastylej_aarch64.so" tofile="linux/work/lib/libastylej.so" />
<chmod perm="755" file="linux/work/lib/libastylej.so" />

<target name="linux-liblistserials-aarch64" depends="linux-build" description="Download liblistserials.so for AArch64">
<antcall target="portable-${portable}">
<param name="parentdir" value="linux/work" />
</antcall>
@@ -772,7 +765,7 @@
<chmod perm="755" file="linux/work/lib/liblistSerialsj.so" />
</target>

<target name="linuxaarch64-build" depends="linux-libastyle-aarch64" description="Build Linux (AArch64) version">
<target name="linuxaarch64-build" depends="linux-liblistserials-aarch64" description="Build Linux (AArch64) version">
<antcall target="linux-jvm-${linux-bundle-jvm-task}">
<param name="JVM" value="${LINUXAARCH64_BUNDLED_JVM}"/>
</antcall>
@@ -790,7 +783,7 @@
</antcall>
</target>

<target name="linux32-build" depends="linux-libastyle-x86" description="Build linux (32-bit) version">
<target name="linux32-build" depends="linux-liblistserials-x86" description="Build linux (32-bit) version">
<antcall target="linux-jvm-${linux-bundle-jvm-task}">
<param name="JVM" value="${LINUX32_BUNDLED_JVM}"/>
</antcall>
@@ -808,7 +801,7 @@
</antcall>
</target>

<target name="linux64-build" depends="linux-libastyle-x86" description="Build linux (64-bit) version">
<target name="linux64-build" depends="linux-liblistserials-x86" description="Build linux (64-bit) version">
<antcall target="linux-jvm-${linux-bundle-jvm-task}">
<param name="JVM" value="${LINUX64_BUNDLED_JVM}"/>
</antcall>
@@ -1069,13 +1062,6 @@

<antcall target="windows-build-avr-toolchain" />

<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.1-5.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/libastylej-2.05.1-5.zip" />
<param name="final_folder" value="${staging_folder}/libastylej-2.05.1" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="windows/libastylej-2.05.1/AStylej.dll" todir="windows/work/lib" />
<copy file="windows/msvcp100.dll" todir="windows/work" />
<copy file="windows/msvcr100.dll" todir="windows/work" />

1 change: 0 additions & 1 deletion build/libastylej-2.05.1-5.zip.sha

This file was deleted.

1 change: 1 addition & 0 deletions build/linux/clang_12.0.0_Linux_32bit.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b10e77fb79a41880766439dc65cd8aaa328af5bc
1 change: 1 addition & 0 deletions build/linux/clang_12.0.0_Linux_64bit.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e3fe347cdb2e4b7b1c92b8e21b4aae49eeaaad55
1 change: 1 addition & 0 deletions build/linux/clang_12.0.0_Linux_ARM64.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a81b7e8c6c5922fbcd423228f13a1148a91a3932
1 change: 1 addition & 0 deletions build/linux/clang_12.0.0_Linux_ARMv6.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d10ae0b04eadf9fd0fa52d16549a2c6bec482738
1 change: 1 addition & 0 deletions build/macosx/clang_12.0.0_macOS_64bit.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
154b62e3062b5040594155702c7c7508d18c6b3a
145 changes: 145 additions & 0 deletions build/shared/clang-format-arduino
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# See: https://releases.llvm.org/11.0.1/tools/clang/docs/ClangFormatStyleOptions.html
---
Language: Cpp
# LLVM is the default style setting, used when a configuration option is not set here
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: true
BinPackParameters: true
# Only used when "BreakBeforeBraces" set to "Custom"
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
#AfterObjCDeclaration:
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
# Java-specific
#BreakAfterJavaFieldAnnotations:
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 0
# "" matches none
CommentPragmas: ""
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
# Docs say "Do not use this in config files". The default (LLVM 11.0.1) is "false".
#ExperimentalAutoDetectBinPacking:
FixNamespaceComments: false
ForEachMacros: []
IncludeBlocks: Preserve
IncludeCategories: []
# "" matches none
IncludeIsMainRegex: ""
IncludeIsMainSourceRegex: ""
IndentCaseBlocks: true
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
# Java-specific
#JavaImportGroups:
# JavaScript-specific
#JavaScriptQuotes:
#JavaScriptWrapImports
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
# Set to a large number to effectively disable
MaxEmptyLinesToKeep: 100000
NamespaceIndentation: None
NamespaceMacros: []
# Objective C-specific
#ObjCBinPackProtocolList:
#ObjCBlockIndentWidth:
#ObjCBreakBeforeNestedBlockParam:
#ObjCSpaceAfterProperty:
#ObjCSpaceBeforeProtocolList
PenaltyBreakAssignment: 1
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 1
PenaltyBreakFirstLessLess: 1
PenaltyBreakString: 1
PenaltyBreakTemplateDeclaration: 1
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 1
# Used as a fallback if alignment style can't be detected from code (DerivePointerAlignment: true)
PointerAlignment: Right
RawStringFormats: []
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementMacros: []
TabWidth: 2
TypenameMacros: []
# Default to LF if line endings can't be detected from the content (DeriveLineEnding).
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros: []
1 change: 1 addition & 0 deletions build/windows/clang_12.0.0_Windows_32bit.zip.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d2a5246fed18b61d96de49887e16520be5dad944