Projects/Edu/KStars/C++ developer tools with KStars on Linux: Difference between revisions

From KDE TechBase
< Projects‎ | Edu‎ | KStars
(Created page with "This page describes how to use open-source C++ tools to hunt down memory errors and improve the code quality. === CCache === Official homepage: https://ccache.samba.org CCa...")
 
No edit summary
Line 16: Line 16:


You can build KStars after these steps normally, CMake will put the compiler invocation after the ccache command and the object files will be saved to the local cache when a make command is executed.
You can build KStars after these steps normally, CMake will put the compiler invocation after the ccache command and the object files will be saved to the local cache when a make command is executed.
=== Clang Format ===
Official homepage: https://clang.llvm.org/docs/ClangFormat.html
Clang Format can indent the source codes with a defined style. The config file (.clang-format) is in the root of the KStars Git repository. The clang format can be installed easily in Ubuntu Linux from the LLVM repositories (http://apt.llvm.org/):
  sudo apt-get install clang-format-5.0
The current bleeding-edge Clang Format does not support value indentation after #define as of now (June 2017), therefore, a patched package is uploaded to this wiki page which contains the "define patch" from https://bugs.llvm.org//show_bug.cgi?id=20637.
When clang-format is installed, a cmake flag (-DFORMAT_CODE=ON) is needed to enable Clang Format support. For example:
  cmake . -DFORMAT_CODE=ON
To format the code, a make command must be executed:
  make clang-format

Revision as of 14:05, 11 June 2017

This page describes how to use open-source C++ tools to hunt down memory errors and improve the code quality.

CCache

Official homepage: https://ccache.samba.org

CCache is a useful tool to cache the compiled object files to avoid recompilation of the same source files. A typical use case is changing git branches when some include files are modified. By default, the compiler would recompile the affected source files after each branch checkout. With CCache, the build system can get the already-compiled object file from a local cache on the disk if available.

Install CCache on Ubuntu Linux:

  sudo apt-get install ccache

Add the -DCCACHE_SUPPORT=ON to the CMake flags to enable this feature. For example:

  cmake . -DCCACHE_SUPPORT=ON

You can build KStars after these steps normally, CMake will put the compiler invocation after the ccache command and the object files will be saved to the local cache when a make command is executed.

Clang Format

Official homepage: https://clang.llvm.org/docs/ClangFormat.html

Clang Format can indent the source codes with a defined style. The config file (.clang-format) is in the root of the KStars Git repository. The clang format can be installed easily in Ubuntu Linux from the LLVM repositories (http://apt.llvm.org/):

  sudo apt-get install clang-format-5.0

The current bleeding-edge Clang Format does not support value indentation after #define as of now (June 2017), therefore, a patched package is uploaded to this wiki page which contains the "define patch" from https://bugs.llvm.org//show_bug.cgi?id=20637.

When clang-format is installed, a cmake flag (-DFORMAT_CODE=ON) is needed to enable Clang Format support. For example:

  cmake . -DFORMAT_CODE=ON

To format the code, a make command must be executed:

  make clang-format