Skip to content

Commit 20b4865

Browse files
authored
Update documentation for clang-format (#2907)
This PR updates the Sming coding style documentation as discussed in #2898 (comment) and #2904 (comment). Sming requires version 8 which is generally no longer available in the standard repositories for recent GNU/Linux distributions. Different versions of clang-format produce different output with the same configuration. This is such a common problem that a kind soul has provided standalone builds here https://github.com/muttleyxd/clang-tools-static-binaries/releases. The default name of the clang-format executable has been changed to `clang-format-8`. This is because `clang-format` is now very unlikely to be the default installed version, and so avoids the subtle issues with running the wrong version.
1 parent 78e70fe commit 20b4865

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

Sming/build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ CMAKE ?= cmake
140140

141141
# clang-format command
142142
DEBUG_VARS += CLANG_FORMAT
143-
CLANG_FORMAT ?= clang-format
143+
CLANG_FORMAT ?= clang-format-8
144144

145145
# more tools
146146
DEBUG_VARS += AWK

docs/source/information/develop/clang-tools.rst

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ Note that *clang-format* is part of the main **Clang** project, whilst *clang-ti
1515
found in **clang-tools-extra**.
1616

1717

18-
Installation
18+
clang-format
1919
------------
2020

21-
In Ubuntu you should be able to install them using the following command::
21+
Installation
22+
~~~~~~~~~~~~
2223

23-
sudo apt-get install clang-format clang-tidy
24+
Sming requires version 8 which is generally no longer available in the standard repositories for recent GNU/Linux distributions.
25+
You can find standalone builds at https://github.com/muttleyxd/clang-tools-static-binaries/releases.
26+
27+
For example:
28+
29+
```
30+
export CLANG_FORMAT=/opt/clang-format-8
31+
wget https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-32d3ac78/clang-format-8_linux-amd64 -O /opt/clang-format-8
32+
chmod +x $CLANG_FORMAT
33+
```
34+
35+
You should persist the definition for :envvar:`CLANG_FORMAT` as Sming uses this when running the ``make cs`` commands (see below).
2436

25-
See the the `download <http://releases.llvm.org/download.html>`__ page
26-
of the Clang project for installation instructions for other operating
27-
systems.
2837

2938
.. important::
3039

@@ -37,10 +46,6 @@ systems.
3746
You should install the same version on your development computer.
3847

3948

40-
41-
clang-format
42-
------------
43-
4449
Rules
4550
~~~~~
4651

@@ -57,6 +62,8 @@ IDE integration
5762
There are multiple existing integrations for IDEs. You can find details
5863
in the `ClangFormat documentation <https://clang.llvm.org/docs/ClangFormat.html>`__.
5964

65+
For VS Code/Codium install the **clang-format** extension and configure the path with the location of the **clang-format-8** executable.
66+
6067
For the Eclipse IDE we recommend installing
6168
the `CppStyle plugin <https://github.com/wangzw/CppStyle>`__. You can
6269
configure your IDE to auto-format the code on "Save" using the
@@ -114,12 +121,23 @@ C, C++ or header file or a selection in it and run the ``Format`` command
114121
clang-tidy
115122
----------
116123

117-
Configuration
118-
~~~~~~~~~~~~~
124+
Installation
125+
~~~~~~~~~~~~
119126

120127
No specific version is required but generally you should aim to use the most recent version
121128
available in your distribution. Version 17.0.6 was used at time of writing these notes.
122129

130+
In Ubuntu you should be able install using the following command::
131+
132+
sudo apt-get install clang-tidy
133+
134+
See the the `download <http://releases.llvm.org/download.html>`__ page
135+
of the Clang project for installation instructions for other operating
136+
systems.
137+
138+
Configuration
139+
~~~~~~~~~~~~~
140+
123141
The default tool configuration is defined in the
124142
`.clang-tidy <https://github.com/SmingHub/Sming/blob/develop/.clang-tidy>`__
125143
file, located in the root directory of the framework.

0 commit comments

Comments
 (0)