759de07343a88cd8a26f9ce76108bb08c57e47b4
[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
17 .. TODO: Consider what is the most reasonable structure; currently, this list
18    here does not make much sense in the overall organization and creates a
19    confusing TOC for the developer guide.
20
21 .. TODO: Add details for most of the tools, either in the form of links to wiki,
22    or to a separate page that explains more details.
23
24 Change management
25 -----------------
26
27 |Gromacs| change management is supported by the following tools.
28 (For change submission guidelines, refer to :doc:`contribute`.)
29
30 git
31   |Gromacs| uses `git <https://git-scm.com/>`__ as the version control system.
32   Instructions for setting up git for |Gromacs|, as well as tips and tricks for
33   its use, can be found in :doc:`change-management`.
34
35   Other basic tutorial material for ``git`` can be found on the `web <https://git-scm.com/doc/ext>`__.
36
37 Gerrit
38   All code changes go through a code review system at
39   http://gerrit.gromacs.org.
40
41 Jenkins
42   All changes pushed to Gerrit are automatically compiled and otherwise
43   checked on various platforms using a continuous integration system at
44   http://jenkins.gromacs.org.
45   :doc:`jenkins` documents how Jenkins interacts with the build system,
46   providing information on how to replicate the builds Jenkins does (e.g., to
47   diagnose issues).
48   :doc:`releng/index` provides more information on the technical implementation
49   of the builds.
50
51 Redmine
52   Bugs and issues, as well as some random features and discussions,
53   are tracked at http://redmine.gromacs.org.
54
55 .. _Git Tips & Tricks: http://www.gromacs.org/index.php?title=Developer_Zone/Git/Git_Tips_%26_Tricks
56
57 Build system
58 ------------
59
60 .. TODO: details, ASAN, others?
61
62 CMake
63   Main tool used in the build system.
64
65 ccache
66   When the `ccache <https://ccache.samba.org>`_ caching compiler wrapper is
67   found on the PATH, we attempt to set up a caching compiler wrapper for CMake
68   builds. Not all compilers are supported. Refer to the ``ENABLE_CCACHE``
69   option in ``CMakeLists.txt`` and to ``cmake/gmxCcache.cmake``
70   for details. Please submit updates if you find that the current
71   configuration is too conservative.
72
73 packaging for distribution (CPack)
74
75 unit testing (CTest)
76   |Gromacs| uses a unit testing framework based on Google C++ Testing
77   Framework (gtest) and CTest.  All unit tests are automatically run on Jenkins
78   for each commit.
79   Details can be found on a separate page on :doc:`testutils`.
80
81 regression tests
82
83 clang-tidy
84   `clang-tidy <http://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`
85   is used for static code analysis. clang-tidy is easy to install. It is contained in
86   the llvm binary `package <http://releases.llvm.org/download.html#6.0.0>`. Only
87   version 6.0 is supported. Others might miss tests or give false positives.
88   It is run automatically on Jenkins for each commit. To run it manually, configure
89   with ``cmake -DGMX_CLANG_TIDY=ON -DGMX_OPENMP=no -DCMAKE_BUILD_TYPE=Debug`` and then run make
90   normally (for ``CMAKE_BUILD_TYPE`` any type which enables asserts (e.g. ASAN) works).
91   The name of the clang-tidy executable that CMake should search for be set with
92   ``-DCLANG_TIDY=...`, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
93   Many checks have fixes which automatically get applied when building with clang-tidy
94   enabled, so you may want to run this tool locally to apply the fixes before
95   you upload to Gerrit.
96
97 cppcheck
98   `cppcheck <http://cppcheck.sourceforge.net>`_ is used for static code
99   analysis, and is run automatically on Jenkins for each commit.  Different rules
100   are used for C and C++ code (with stricter checking for C++ code, as that is
101   newer).  The build system provides a ``cppcheck`` target (produced from
102   ``tests/CppCheck.cmake``) to run the tool.  This target is used also by Jenkins.
103
104 clang static analyzer
105
106 coverage
107
108 .. _dev-formatting-tools:
109
110 Code formatting and style
111 -------------------------
112
113 The tools and scripts listed below are used to automatically check/apply
114 formatting that follows |Gromacs| style guidelines described on a separate page:
115 :doc:`style`.
116
117 uncrustify
118   `uncrustify <http://uncrustify.sourceforge.net>`_ is used for automatic
119   indentation and other formatting of the source code to follow
120   :doc:`formatting`.  All code must remain invariant under uncrustify
121   with the config at ``admin/uncrustify.cfg``.  A patched version of uncrustify is
122   used.  See :doc:`uncrustify` for details.
123
124 ``admin/copyright.py``
125   This Python script adds and formats copyright headers in source files.
126   ``uncrustify.sh`` (see below) uses the script to check/update copyright years on
127   changed files automatically.
128
129 ``admin/uncrustify.sh``
130   This ``bash`` script runs uncrustify and ``copyright.py`` for all
131   files that have local changes and checks that they conform to the prescribed
132   style.  Optionally, the script can also apply changes to make the files
133   conform.
134   This script is automatically run by Jenkins to ensure that all commits adhere
135   to :doc:`formatting`.  If the uncrustify job does not succeed, it
136   means that this script has something to complain.
137   See :doc:`uncrustify` for details.
138
139 ``admin/git-pre-commit``
140   This sample git pre-commit hook can be used if one wants to apply
141   ``uncrustify.sh`` automatically before every commit to check for formatting
142   issues.  See :doc:`uncrustify` for details.
143
144 ``docs/doxygen/includesorter.py``
145   This Python script sorts and reformats #include directives according to
146   the guidelines at :doc:`includestyle`.  Details are documented on a
147   separate page (with the whole suite of Python scripts used for source code
148   checks): :ref:`dev-include-sorter`.
149
150 include directive checker
151   In its present form, the above include sorter script cannot be conveniently
152   applied in ``uncrustify.sh``.  To check for issues, it is instead integrated into
153   a ``check-source`` build target.  When this target is built, it also checks for
154   include formatting issues.  Internally, it uses the sorter script.  This check
155   is run in Jenkins as part of the Documentation job.
156   Details for the checking mechanism are on a separate page (common for several
157   checkers): :doc:`gmxtree`.
158
159 ``admin/reformat_all.sh``
160   This ``bash`` script runs uncrustify/``copyright.py``/include sorter
161   on all relevant files in the source tree (or in a particular directory).
162   The script can also produce the list of files where these scripts are applied,
163   for use with other scripts.  See :doc:`uncrustify` for details.
164
165 git attributes
166   git attributes (specified in ``.gitattributes`` files) are used to annotate
167   which files are subject to automatic formatting checks (and for automatic
168   reformatting by the above scripts).  See ``man gitattributes`` for an overview of
169   the mechanism.  We use the ``filter`` attribute to specify the type of automatic
170   checking/formatting to apply.  Custom attributes are used for specifying some
171   build system dependencies for easier processing in CMake.
172
173 include-what-you-use
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301