2019-10-24 01:29:09 +03:00
|
|
|
# Using clang-format on 1DS C++ SDK Code
|
2019-10-24 01:17:12 +03:00
|
|
|
|
|
|
|
## Command-line use
|
|
|
|
|
|
|
|
To format a file according to [1DS C++ SDK coding style](Coding%20style.md), from the command line.
|
|
|
|
|
|
|
|
Setup the build tools environment first.
|
|
|
|
|
|
|
|
For Windows - cmd.exe command:
|
2019-10-24 01:31:57 +03:00
|
|
|
|
2019-10-24 01:17:12 +03:00
|
|
|
```call tools\setup-devenv.cmd```
|
|
|
|
|
2019-10-24 01:31:39 +03:00
|
|
|
For POSIX (Linux and Mac) - shell command:
|
2019-10-24 01:31:57 +03:00
|
|
|
|
2019-10-24 01:17:12 +03:00
|
|
|
```source tools/setup-devenv.sh```
|
|
|
|
|
|
|
|
Command will add the tools from repo *tools* directory to PATH environment variable.
|
|
|
|
|
|
|
|
Then run:
|
2019-10-24 01:31:57 +03:00
|
|
|
|
2019-10-24 01:17:12 +03:00
|
|
|
```git cl format <filename>```
|
|
|
|
|
|
|
|
At the moment the tool requires to specify the file path. Uber goal is to integrate the toolset
|
|
|
|
from Chromium to automagically apply clang-format on all files in a current pending commit.
|
|
|
|
|
|
|
|
## Editor integrations
|
|
|
|
|
|
|
|
For further guidance on editor integration, see these specific pages:
|
2019-10-24 01:33:04 +03:00
|
|
|
* [Download link for LLVM tools for Windows](https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe)
|
2019-10-24 01:17:12 +03:00
|
|
|
* [LLVM tools extension for Visual Studio](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain)
|
|
|
|
* [Visual Studio code extension](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
|
|
|
|
* [CppStyle Eclipse CDT extension](https://marketplace.eclipse.org/content/cppstyle)
|
|
|
|
|
|
|
|
## Are robots taking over my freedom to choose where newlines go?
|
|
|
|
|
|
|
|
No. For the project as a whole, using clang-format is just one optional way to format your code.
|
|
|
|
While it will produce style-guide conformant code, other formattings would also satisfy the style
|
|
|
|
guide. For certain modules it may be appropriate to use alternate coding style. In those scenarios
|
|
|
|
a local directory *.clang-format* settings file takes precedence over the one at top-level.
|