0b84988c2736b3aab89dd9daa421d079c9c86d17
[alexxy/gromacs.git] / docs / dev-manual / tools.rst
1 Development-time tools
2 ======================
3
4 Several tools have their own individual pages and are listed below.
5
6 .. toctree::
7    :maxdepth: 2
8
9    doxygen
10    change-management
11    jenkins
12    releng/index
13    gmxtree
14    uncrustify
15    testutils
16    physical_validation
17
18 .. TODO: Consider what is the most reasonable structure; currently, this list
19    here does not make much sense in the overall organization and creates a
20    confusing TOC for the developer guide.
21
22 .. TODO: Add details for most of the tools, either in the form of links to wiki,
23    or to a separate page that explains more details.
24
25 Change management
26 -----------------
27
28 |Gromacs| change management is supported by the following tools.
29 (For change submission guidelines, refer to :doc:`contribute`.)
30
31 git
32   |Gromacs| uses `git <https://git-scm.com/>`__ as the version control system.
33   Instructions for setting up git for |Gromacs|, as well as tips and tricks for
34   its use, can be found in :doc:`change-management`.
35
36   Other basic tutorial material for ``git`` can be found on the `web <https://git-scm.com/doc/ext>`__.
37
38 Gerrit
39   All code changes go through a code review system at
40   http://gerrit.gromacs.org.
41
42 Jenkins
43   All changes pushed to Gerrit are automatically compiled and otherwise
44   checked on various platforms using a continuous integration system at
45   http://jenkins.gromacs.org.
46   :doc:`jenkins` documents how Jenkins interacts with the build system,
47   providing information on how to replicate the builds Jenkins does (e.g., to
48   diagnose issues).
49   :doc:`releng/index` provides more information on the technical implementation
50   of the builds.
51
52 Redmine
53   Bugs and issues, as well as some random features and discussions,
54   are tracked at http://redmine.gromacs.org.
55
56 .. _Git Tips & Tricks: http://www.gromacs.org/index.php?title=Developer_Zone/Git/Git_Tips_%26_Tricks
57
58 Build system
59 ------------
60
61 .. TODO: details, ASAN, others?
62
63 CMake
64   Main tool used in the build system.
65
66 packaging for distribution (CPack)
67
68 unit testing (CTest)
69   |Gromacs| uses a unit testing framework based on Google C++ Testing
70   Framework (gtest) and CTest.  All unit tests are automatically run on Jenkins
71   for each commit.
72   Details can be found on a separate page on :doc:`testutils`.
73
74 regression tests
75
76 clang-tidy
77   `clang-tidy <http://releases.llvm.org/7.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`_
78   is used for static code analysis. clang-tidy is easy to install. It is contained in
79   the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`_. Only
80   version 7.0.* with libstdc++<7 or libc++ is supported. Others might miss tests or give false positives.
81   It is run automatically on Jenkins for each commit. Many checks have fixes which can automatically be
82   applied. To run it, the build has to be configured with
83   ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on``.
84   Any ``CMAKE_BUILD_TYPE`` which enables asserts (e.g. ASAN) works. Such a configured build will
85   run both the compiler as well as clang-tidy when building. The name of the clang-tidy executable is set with
86 ``-DCLANG_TIDY=...``, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
87   To apply the automatic fixes to the issue identified clang-tidy should be run sepereately (running clang-tidy
88   with ``-fix`` as part of the build can corrupt header files). To fix a specific file run
89   ``clang-tidy -fix -header-filter '.*' {file}``, to fix all files in parallel
90   ``run-clang-tidy.py -fix -header-filter '.*' '(?<!/selection/parser\.cpp|selection/scanner\.cpp)$'``,
91   and to fix all modified files ``run-clang-tidy.py -fix -header-filter '.*' $(git diff HEAD --name-only)``.
92   The run-clang-tidy.py script is in the
93   ``share/clang/`` subfolder of the llvm distribution. ``clang-tidy`` has to be able to find the
94   ``compile_commands.json`` file. Eithe run from the build folder or add a symlink to the source folder.
95
96 clang static analyzer
97
98 coverage
99
100 .. _dev-formatting-tools:
101
102 Code formatting and style
103 -------------------------
104
105 The tools and scripts listed below are used to automatically check/apply
106 formatting that follows |Gromacs| style guidelines described on a separate page:
107 :doc:`style`.
108
109 uncrustify
110   `uncrustify <http://uncrustify.sourceforge.net>`_ is used for automatic
111   indentation and other formatting of the source code to follow
112   :doc:`formatting`.  All code must remain invariant under uncrustify
113   with the config at ``admin/uncrustify.cfg``.  A patched version of uncrustify is
114   used.  See :doc:`uncrustify` for details.
115
116 ``admin/copyright.py``
117   This Python script adds and formats copyright headers in source files.
118   ``uncrustify.sh`` (see below) uses the script to check/update copyright years on
119   changed files automatically.
120
121 ``admin/uncrustify.sh``
122   This ``bash`` script runs uncrustify and ``copyright.py`` for all
123   files that have local changes and checks that they conform to the prescribed
124   style.  Optionally, the script can also apply changes to make the files
125   conform.
126   This script is automatically run by Jenkins to ensure that all commits adhere
127   to :doc:`formatting`.  If the uncrustify job does not succeed, it
128   means that this script has something to complain.
129   See :doc:`uncrustify` for details.
130
131 ``admin/git-pre-commit``
132   This sample git pre-commit hook can be used if one wants to apply
133   ``uncrustify.sh`` automatically before every commit to check for formatting
134   issues.  See :doc:`uncrustify` for details.
135
136 ``docs/doxygen/includesorter.py``
137   This Python script sorts and reformats #include directives according to
138   the guidelines at :doc:`includestyle`.  Details are documented on a
139   separate page (with the whole suite of Python scripts used for source code
140   checks): :ref:`dev-include-sorter`.
141
142 include directive checker
143   In its present form, the above include sorter script cannot be conveniently
144   applied in ``uncrustify.sh``.  To check for issues, it is instead integrated into
145   a ``check-source`` build target.  When this target is built, it also checks for
146   include formatting issues.  Internally, it uses the sorter script.  This check
147   is run in Jenkins as part of the Documentation job.
148   Details for the checking mechanism are on a separate page (common for several
149   checkers): :doc:`gmxtree`.
150
151 ``admin/reformat_all.sh``
152   This ``bash`` script runs uncrustify/``copyright.py``/include sorter
153   on all relevant files in the source tree (or in a particular directory).
154   The script can also produce the list of files where these scripts are applied,
155   for use with other scripts.  See :doc:`uncrustify` for details.
156
157 git attributes
158   git attributes (specified in ``.gitattributes`` files) are used to annotate
159   which files are subject to automatic formatting checks (and for automatic
160   reformatting by the above scripts).  See ``man gitattributes`` for an overview of
161   the mechanism.  We use the ``filter`` attribute to specify the type of automatic
162   checking/formatting to apply.  Custom attributes are used for specifying some
163   build system dependencies for easier processing in CMake.
164
165 include-what-you-use