1
1
# CPPINCLUDE
2
2
3
3
Tool for analyzing includes in C++.
4
- One of the problem in C++ is that if header file was changed all files that
5
- include the file will be recompiled and sometime it takes a lot of time.
4
+ One of the problems in C++ is that if a header file was changed all files that
5
+ include that file will be recompiled and sometime it takes a lot of time.
6
6
7
7
## Table of Contents
8
8
@@ -69,9 +69,10 @@ public:
69
69
70
70
```
71
71
72
- If file * char_kind.hpp* is changed all files that include * base_char_factory.hpp*
73
- and * base_char.hpp* will be recompile and it will take time. This tool helps to find
74
- file in top of include hierarchy:
72
+ If file * char_kind.hpp* is changed all files that
73
+ include * base_char_factory.hpp* and * base_char.hpp* will be recompiled and
74
+ it will take time. This tool helps to find the file at the top of
75
+ the include hierarchy:
75
76
76
77
```
77
78
cppinclude
@@ -123,8 +124,8 @@ Name|Short description
123
124
124
125
### configuration_file
125
126
126
- The tool read setting from * .cppinclude.json* in work directory or
127
- you can set file in argument * configuration_file* .
127
+ The tool reads settings from * .cppinclude.json* located in the work directory or
128
+ you can pass a configuration file in the argument * configuration_file* .
128
129
For example:
129
130
130
131
` cppinclude --configuration_file=project.json `
@@ -138,102 +139,103 @@ Path to generated *compile_commands.json* file by CMake with argument
138
139
139
140
` cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
140
141
141
- You can set path in configuration file:
142
+ You can set the path for the compile_command.json file in the configuration file:
142
143
143
144
``` json
144
145
{
145
146
"compile_commands" : " build/compile_commands.json"
146
147
}
147
148
```
148
149
149
- or in arguments :
150
+ or, pass as an argument :
150
151
151
152
` cppinclude --compile_commands=build/compile_commands.json `
152
153
153
154
[ Back to top] ( #cppinclude )
154
155
155
156
### project_dir
156
157
157
- Path to folder with sources. Often source files are located in * src * or
158
- * sources* folder, not in root folder of project.
159
- You can set in configuration file:
158
+ PPath to a folder that contains sources. Often source files are located
159
+ in * src * or * sources* folder, not in the root folder of project.
160
+ You can set it in configuration file with :
160
161
161
162
``` json
162
163
{
163
164
"project_dir" : " src"
164
165
}
165
166
```
166
167
167
- or in arguments :
168
+ or, pass as an argument :
168
169
169
170
` cppinclude --project_dir=src `
170
171
171
172
[ Back to top] ( #cppinclude )
172
173
173
174
### file_extensions
174
175
175
- If you use file extensions for C++ that aren’t in default values. You can set in
176
- configuration file:
176
+ If you use other file extensions than default values * file_extensions *
177
+ for C++ sources you can specify them in the configuration file with :
177
178
178
179
``` json
179
180
{
180
181
"file_extensions" : [" *.cc" , " *.hh" ]
181
182
}
182
183
```
183
184
184
- or in arguments :
185
+ or, pass as an argument :
185
186
186
187
` cppinclude --file_extensions=*.cc,*hh `
187
188
188
189
[ Back to top] ( #cppinclude )
189
190
190
191
### analyze_without_extension
191
192
192
- Analyze files in project directory without extension , default: false.
193
- You can set in configuration file:
193
+ Analyze files without extension in the project directory, default: false.
194
+ You can set this option in the configuration file with :
194
195
195
196
``` json
196
197
{
197
198
"analyze_without_extension" : true
198
199
}
199
200
```
200
201
201
- or in arguments :
202
+ or, pass as an argument :
202
203
203
204
` cppinclude --analyze_without_extension=true `
204
205
205
206
[ Back to top] ( #cppinclude )
206
207
207
208
### include_dirs
208
209
209
- Add folders where search included files . Default value is project folder.
210
- You can set in configuration file:
210
+ Add paths to the header search directories . Default value is project folder.
211
+ You can set it in the configuration file with :
211
212
212
213
``` json
213
214
{
214
215
"include_dirs" : [ " lib1" , " lib2" ]
215
216
}
216
217
```
217
218
218
- or in arguments :
219
+ or, pass as an argument :
219
220
220
221
` cppinclude --include_dirs=lib1,lib2 `
221
222
222
223
[ Back to top] ( #cppinclude )
223
224
224
225
### ignore_dirs
225
226
226
- Folders that will be ignored during analyzing project’s files.
227
- It can be third-party libraries that are located in project directory
228
- but don't need to analyze. You can set in configuration file:
227
+ Folders to be ignored during project analysis.
228
+ For example: third-party libraries that are located under the project directory
229
+ but should not be analyzed.
230
+ You can set it in the configuration file with:
229
231
230
232
``` json
231
233
{
232
234
"ignore_dirs" : [" ./3rd-part" , " gtest" ]
233
235
}
234
236
```
235
237
236
- or in arguments :
238
+ or, pass as an argument :
237
239
238
240
` cppinclude --ignore_dirs=./3rd-part,gtest `
239
241
@@ -242,15 +244,15 @@ or in arguments:
242
244
### ignore_system_includes
243
245
244
246
Ignore includes with * \<\> * , example * #include \< iostream\> * will be ignored.
245
- You can set in configuration file:
247
+ You can set it in the configuration file with :
246
248
247
249
``` json
248
250
{
249
251
"ignore_system_includes" : true
250
252
}
251
253
```
252
254
253
- or in arguments :
255
+ or, pass as an argument :
254
256
255
257
` cppinclude --ignore_system_includes=true `
256
258
@@ -268,7 +270,7 @@ or generated files (*.gen). You can set in configuration file
268
270
}
269
271
```
270
272
271
- or in arguments :
273
+ or, pass as an argument :
272
274
273
275
` cppinclude --ignore_files=boost/.*,.*\\.def `
274
276
@@ -278,18 +280,20 @@ or in arguments:
278
280
279
281
Name of report. Possible values:
280
282
281
- * * unresolved* -- show included files that are not found in project folder;
283
+ * * unresolved* -- show included files that are not found within the project folder;
282
284
* * most_impact* -- show files that most impact on other files;
283
285
* * unincluded* -- show unincluded headers;
284
286
* * different_type* -- show headers that are included in #include <...> and #include "..." .
285
287
288
+ As arguments:
289
+
286
290
```
287
291
cppinclude --report=unresolved
288
292
cppinclude --report=most_impact
289
293
cppinclude --report=unresolved,most_impact
290
294
```
291
295
292
- Also you can set in configuration file:
296
+ As a configuration file setting :
293
297
294
298
``` json
295
299
{
@@ -301,9 +305,10 @@ Also you can set in configuration file:
301
305
302
306
#### unresolved
303
307
304
- Show files that are found in includes but didn't found in file system.
305
- One of the resean is missing includes files, for example:
306
- There is file * main.cpp* , folder * include* that store file * header.hpp* :
308
+ Show headers that are included but not found in the given search paths.
309
+ One possible reason is missing include files, for example:
310
+ iven a * main.cpp* file and a * include* folder that stores
311
+ the * header.hpp* header:
307
312
308
313
```
309
314
tree
314
319
315
320
```
316
321
317
- If run * cppinclude* result will be:
322
+ When * cppinclude* is run, the result will be:
318
323
319
324
```
320
325
cppinclude --report=unresolved
@@ -327,7 +332,8 @@ Unresolved files:
327
332
328
333
```
329
334
330
- But if add folder * include* to * include_dirs* resultat will be empty:
335
+ Adding the * include* folder to * include_dirs* will remove the
336
+ unresolved files entry:
331
337
332
338
```
333
339
cppinclude --report=unresolved --include_dirs=include
@@ -337,7 +343,7 @@ cppinclude --report=unresolved --include_dirs=include
337
343
338
344
#### most_impact
339
345
340
- Show how many files will be recompiled with header will be changed.
346
+ Show how many files will be recompiled when a given header is changed.
341
347
Example from [ docs/examples/simple_example/] ( docs/examples/simple_example/ )
342
348
343
349
```
@@ -359,14 +365,17 @@ Included by:
359
365
...
360
366
```
361
367
362
- It means if file char_kind.hpp will be changed 11 files are recompiled.
368
+ The above output means that a change in char_kind.hpp will force 11
369
+ files to recompile.
363
370
364
371
[ Back to top] ( #cppinclude )
365
372
366
373
#### unincluded
367
374
368
- Show files that are found in file system but didn't found in includes.
369
- It often happens after refactoring when file that include header was deleted.
375
+ Show headers that are found in the search directories but that were not
376
+ included in the source code.
377
+ It often happens after refactoring when headers when include directives
378
+ were removed from code and thefiles remained in place.
370
379
Example from [ docs/examples/simple_example_with_unincluded_headers/] ( docs/examples/simple_example_with_unincluded_headers/ )
371
380
372
381
```
@@ -382,18 +391,19 @@ Unincluded headers:
382
391
383
392
** Limitations:**
384
393
385
- * Header with same names:
394
+ * Headers with same names:
386
395
387
- If headers have same name but are located in different folders will be found
388
- only first header and other will be unincluded.
389
- For example: * lib1/ header.hpp * , * lib2/header.hpp * and
390
- * main.cpp* :
396
+ If headers have the same name but are located in different paths only one
397
+ occurrence will be counted.
398
+ only first header and other will be unincluded.
399
+ For example: * lib1/header.hpp * , * lib2/header.hpp * and * main.cpp* :
391
400
392
401
``` c++
393
402
#include " header.hpp"
394
403
...
395
404
```
396
- Result will be:
405
+
406
+ The result will be:
397
407
398
408
```
399
409
cppinclude --include_dirs=lib1,lib2 --report=unincluded
@@ -406,23 +416,22 @@ Unincluded headers:
406
416
407
417
```
408
418
409
- * Empty result for CMake project:
419
+ * Empty result for CMake project:
410
420
411
- If analyze CMake project ( generated file compile_commands.json )
412
- result will be empty. Because in current implementation * cppinclude * analyze
413
- source files on file system or files from compile_commands.json
421
+ The current implementation ignores CMake project files.
422
+ Only source files are analyzed currently that are either specified
423
+ in compile_commands.json or that are found on the filesystem.
414
424
415
425
* Header files are files that have extension started with * h* letter
416
426
417
- *** All limitations will be fixed in future releases ** *
418
-
427
+ *** All limitations will be fixed in future releases***
419
428
420
429
[ Back to top] ( #cppinclude )
421
430
422
431
#### different_type
423
432
424
433
Show headers that are included in different ways.
425
- It helps to follow code style in project,
434
+ It helps to follow code styles in project,
426
435
for example include third party libraries in <...> and project header in "...".
427
436
Example from [ docs/examples/simple_example_for_different_type_report/] ( docs/examples/simple_example_for_different_type_report/ )
428
437
0 commit comments