Giter Club home page Giter Club logo

cppinclude's Introduction

CPPINCLUDE

Tool for analyzing includes in C++. One of the problems in C++ is that if a header file was changed all files that include that file will be recompiled and sometime it takes a lot of time.

Table of Contents

Examples

Example from docs/examples/simple_example/

  • file base_char_factory.hpp
#pragma once
#include "base_char.hpp"
#include <memory>

class BaseCharFactory
{
public:
    virtual ~BaseCharFactory() = default;
    virtual std::unique_ptr< BaseChar > createObject() = 0;
};
  • file base_char.hpp
#pragma once
#include "char_kind.hpp"

class BaseChar
{
public:
    virtual ~BaseChar() = default;
    virtual CharKind getKind() const noexcept = 0;
};

If file char_kind.hpp is changed all files that include base_char_factory.hpp and base_char.hpp will be recompiled and it will take time. This tool helps to find the file at the top of the include hierarchy:

cppinclude
...
Most impact files:
1 : "char_kind.hpp" impact on 11 files
Included by:
   1 : "base_char.hpp" line 3, impact on 10 files
2 : "base_char.hpp" impact on 10 files
Included by:
    1 : "base_char_factory.hpp" line 3, impact on 5 files
    2 : "char_a.hpp" line 3, impact on 2 files
    3 : "char_b.hpp" line 3, impact on 2 files
3 : "base_char_factory.hpp" impact on 5 files
Included by:
    1 : "char_a_factory.hpp" line 3, impact on 2 files
    2 : "char_b_factory.hpp" line 3, impact on 2 files
...

See more examples in docs/examples/

Back to top

Settings

All arguments

Name Short description
--report=name1,name2,... List reports. Name of reports: unresolved, most_impact, unincluded, different_type (default: unresolved,most_impact,unincluded)
--configuration_file=file Path to configuration file (default: .cppinclude.json)
--compile_commands=file Path to JSON Compilation Database (default: compile_commands.json)
--project_dir=dir Project directory
--file_extensions=arg1,arg2,... Extensions C++ files (default: *.cpp, *.hpp,*.c,*.h,*.cxx,*.hxx)
--analyze_without_extension=true Analyze files without extension (default: false)
--include_dirs=dir1,dir2,... Include directories
--ignore_dirs=dir1,dir2,... Directories that will be ignored
--ignore_system_includes=true Ignore headers in <> (default: false)
--ignore_files=regexp1,regexp2,... Files will be ignored by regexp
--report_limit=42 Maximum elements in report, 0 - unlimited (default: 10)
--report_details_limit=42 Maximum details in report, 0 - unlimited (default: 10)
--show_std_files Show standard library headers in output (default: false)
--show_only_std_headers Show only standard library headers in output (default: false)
--show_details Show details in output (default: true)
--thousands_separator=separator Set thousands separator, for example ',' (default: ' ')
--help Show usage
--verbose Verbose mode
--version Show application version
--verbose_ignore Show ignored files

Back to top

configuration_file

The tool reads settings from .cppinclude.json located in the work directory or you can pass a configuration file in the argument configuration_file. For example:

cppinclude --configuration_file=project.json

Back to top

compile_commands

Path to generated compile_commands.json file by CMake with argument -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, for example:

cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

You can set the path for the compile_command.json file in the configuration file:

{
    "compile_commands" : "build/compile_commands.json"
}

or, pass as an argument:

cppinclude --compile_commands=build/compile_commands.json

Back to top

project_dir

PPath to a folder that contains sources. Often source files are located in src or sources folder, not in the root folder of project. You can set it in configuration file with:

{
    "project_dir" : "src"
}

or, pass as an argument:

cppinclude --project_dir=src

Back to top

file_extensions

If you use other file extensions than default values file_extensions for C++ sources you can specify them in the configuration file with:

{
    "file_extensions" : ["*.cc", "*.hh"]
}

or, pass as an argument:

cppinclude --file_extensions=*.cc,*hh

Back to top

analyze_without_extension

Analyze files without extension in the project directory, default: false. You can set this option in the configuration file with:

{
    "analyze_without_extension" : true
}

or, pass as an argument:

cppinclude --analyze_without_extension=true

Back to top

include_dirs

Add paths to the header search directories. Default value is project folder. You can set it in the configuration file with:

{
    "include_dirs" : [ "lib1", "lib2"]
}

or, pass as an argument:

cppinclude --include_dirs=lib1,lib2

Back to top

ignore_dirs

Folders to be ignored during project analysis. For example: third-party libraries that are located under the project directory but should not be analyzed. You can set it in the configuration file with:

{
    "ignore_dirs" : ["./3rd-part", "gtest"]
}

or, pass as an argument:

cppinclude --ignore_dirs=./3rd-part,gtest

Back to top

ignore_system_includes

Ignore includes with <>, example #include <iostream> will be ignored. You can set it in the configuration file with:

{
    "ignore_system_includes" : true
}

or, pass as an argument:

cppinclude --ignore_system_includes=true

Back to top

ignore_files

Ignore files by regexp. The tool will ignore files in project’s directory and files in includes. For example, ignore all boost files or generated files (*.gen). You can set in configuration file

{
    "ignore_files" : [ "boost/.*", ".*\\.def"]
}

or, pass as an argument:

cppinclude --ignore_files=boost/.*,.*\\.def

Back to top

report

Name of report. Possible values:

  • unresolved -- show included files that are not found within the project folder;
  • most_impact -- show files that most impact on other files;
  • unincluded -- show unincluded headers;
  • different_type -- show headers that are included in #include <...> and #include "..." .

As arguments:

cppinclude --report=unresolved
cppinclude --report=most_impact
cppinclude --report=unresolved,most_impact

As a configuration file setting:

{
    "report" : [ "unresolved", "most_impact"]
}

Back to top

unresolved

Show headers that are included but not found in the given search paths. One possible reason is missing include files, for example: iven a main.cpp file and a include folder that stores the header.hpp header:

tree
.
├── include
│   └── header.hpp
└── main.cpp

When cppinclude is run, the result will be:

cppinclude --report=unresolved
Start initialization project ...
Start analyze sources ...
Start report results ...
Unresolved files:
1. "header.hpp" isn't resolved in:
    1. "main.cpp" line: 1

Adding the include folder to include_dirs will remove the unresolved files entry:

cppinclude --report=unresolved --include_dirs=include

Back to top

most_impact

Show how many files will be recompiled when a given header is changed. Example from docs/examples/simple_example/

cppinclude --report=most_impact
...
Most impact files:
1 : "char_kind.hpp" impact on 11 files
Included by:
   1 : "base_char.hpp" line 3, impact on 10 files
2 : "base_char.hpp" impact on 10 files
Included by:
    1 : "base_char_factory.hpp" line 3, impact on 5 files
    2 : "char_a.hpp" line 3, impact on 2 files
    3 : "char_b.hpp" line 3, impact on 2 files
3 : "base_char_factory.hpp" impact on 5 files
Included by:
    1 : "char_a_factory.hpp" line 3, impact on 2 files
    2 : "char_b_factory.hpp" line 3, impact on 2 files
...

The above output means that a change in char_kind.hpp will force 11 files to recompile.

Back to top

unincluded

Show headers that are found in the search directories but that were not included in the source code. It often happens after refactoring when headers when include directives were removed from code and thefiles remained in place. Example from docs/examples/simple_example_with_unincluded_headers/

cppinclude --report=unincluded
Start initialization project ...
Start analyze sources ...
Start report results ...
Unincluded headers:
1 : "config.hpp"
2 : "settings.hpp"

Limitations:

  • Headers with same names:

If headers have the same name but are located in different paths only one occurrence will be counted. only first header and other will be unincluded. For example: lib1/header.hpp, lib2/header.hpp and main.cpp :

#include "header.hpp"
...

The result will be:

cppinclude --include_dirs=lib1,lib2 --report=unincluded

Start initialization project ...
Start analyze sources ...
Start report results ...
Unincluded headers:
1 : "lib2/header.hpp"

  • Empty result for CMake project:

The current implementation ignores CMake project files. Only source files are analyzed currently that are either specified in compile_commands.json or that are found on the filesystem.

  • Header files are files that have extension started with h letter

All limitations will be fixed in future releases

Back to top

different_type

Show headers that are included in different ways. It helps to follow code styles in project, for example include third party libraries in <...> and project header in "...". Example from docs/examples/simple_example_for_different_type_report/

cppinclude --report=different_type
Start initialization project ...
Start analyze sources ...
Start report results ...
Files that are included by different ways:
1. base_char.hpp
With double quotation marks ( #include "..." ) in files:
    1. base_char_factory.hpp line 3
    2. char_b.hpp line 3
With angle brackets ( #include <...> ) in files:
    1. char_a.hpp line 3
2. base_char_factory.hpp
With double quotation marks ( #include "..." ) in files:
    1. char_b_factory.hpp line 3
With angle brackets ( #include <...> ) in files:
    1. char_a_factory.hpp line 3

Back to top

report_limit

Maximum number of files in report. For example, only 5 unresolved files will be in report:

cppinclude --report=unresolved --report_limit=5

Also you can set in configuration file:

{
    "report_limit" : 5
}

Back to top

report_details_limit

Maximum number of detail in report. For example, only 3 files will be in report that include unresolved file

cppinclude --report=unresolved --report_details_limit=3

Also you can set in configuration file:

{
    "report_details_limit" : 3
}

Back to top

show_std_files

Enable showing standard library headers in output.

cppinclude --show_std_files=true

Also you can set in configuration file:

{
    "show_std_files" : true
}

Back to top

show_only_std_headers

Show only standard library headers in output.

cppinclude --show_only_std_headers=true

Also you can set in configuration file:

{
    "show_only_std_headers" : true
}

show_details

Show or hide details

cppinclude --show_details=false

Also you can set in configuration file:

{
    "show_details" : false
}

Example lua :

cppinclude --show_details=false

...
Most impact files:
1 : "luaconf.h" impact on 62 files
2 : "lua.h" impact on 61 files
3 : "llimits.h" impact on 40 files
...

Don't show where files are included

Back to top

thousands_separator

You can change default thousands separator (space) to your separator

For example:

cppinclude --thousands_separator=,

Also you can set in configuration file:

{
    "thousands_separator" : ","
}

Result:

...
Most impact files:
1 : "supper_header.h" impact on 123,456 files
2 : "config.h" impact on 12,345 files
3 : "limits.h" impact on 1,234 files
...

Note: you can use only one character

Don't show where files are included

Back to top

verbose_ignore

Show ignored files and folders. For example:

cppinclude --verbose_ignore

Path "sys/types.h" was ignored by "sys/.*.h"
Path "mach/mach_init.h" was ignored by "mach/.*.h"
Folder ".../3rdparty" was ignored
...

Back to top

Build

Requirements:

  • C++17
  • CMake
  • Compilers:
    • GCC ( tested on 7.5 and 10.1 versions )
    • Visual Studio ( tested on 2017 and 2019 community edition versions )
    • Clang ( tested on 10.0 version )
    • Apple Clang ( tested on 12.0 version )

Build script on Windows:

.\build.bat

on Unix:

./build.sh

Back to top

Docker image

Pull image:

docker pull cppinclude/cppinclude

Or build docker image from source:

docker build -t cppinclude/cppinclude .

Test image:

docker run -it cppinclude/cppinclude bash
cppinclude --version

Analyze your sources in docker image:

docker run -v /tmp/project_src:/src/project_src -it cppinclude/cppinclude
cd /src/project_src
cppinclude

Back to top

Presentations

Back to top

Tips for optimization includes

Back to top

Third-party libraries

Back to top

Support

If you need help with your project or need some feature please write email to [email protected]

Back to top

cppinclude's People

Contributors

cppinclude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cppinclude's Issues

Won't build on CentOS 7 with devtoolset-8

From here:

Developer Toolset is designed for developers working on CentOS or Red Hat Enterprise Linux platform. It provides current versions of the GNU Compiler Collection, GNU Debugger, and other development, debugging, and performance monitoring tools.

In summary, my steps were:

  1. Clone cppinclude
  2. Switch to devtoolset-8
  3. Generate makefiles
  4. Build

As a result, I got the following compile error:

[  1%] Building CXX object json/CMakeFiles/json_lib.dir/ih/json_accessor_impl.cpp.o
In file included from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor.hpp:3,
                 from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor_impl.hpp:1,
                 from /home/c/luizromario/local/cppinclude/src/json/ih/json_accessor_impl.cpp:1:
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:136:14: error: expected unqualified-id before ‘<’ token
     template <class _Elem, class _Traits, class _Alloc>

The code around line 136 of stdfwd.hpp looks like this:

    // <string>
    template <class CharT>
    struct char_traits;
    _GLIBCXX_BEGIN_NAMESPACE_CXX11_INLINE
    template <class _Elem, class _Traits, class _Alloc>
    class basic_string;
    using string = basic_string<char, char_traits<char>, allocator<char>>;
    using wstring = basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>;
    using u16string = basic_string<char16_t, char_traits<char16_t>, allocator<char16_t>>;
    using u32string = basic_string<char32_t, char_traits<char32_t>, allocator<char32_t>>;
    _GLIBCXX_END_NAMESPACE_CXX11

I suspect this has something to do with the fact that the devtoolset headers are not in their standard locations, but rather in /opt/devtoolset-8/... -- in fact, the whole toolset is under /opt/devtoolset-8.


Complete steps:

$ git clone https://github.com/cppinclude/cppinclude
$ cd cppinclude/build
$ scl enable devtoolset-8 bash  # Enable the devtoolset
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cmake3 --version
cmake3 version 3.17.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ cmake3 ../src                 # Can't use build.sh since the `cmake` command points to an old version
    # (All good, skipping CMake output)
$ cmake3 --build .
Scanning dependencies of target json_lib
[  1%] Building CXX object json/CMakeFiles/json_lib.dir/ih/json_accessor_impl.cpp.o
In file included from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor.hpp:3,
                 from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor_impl.hpp:1,
                 from /home/c/luizromario/local/cppinclude/src/json/ih/json_accessor_impl.cpp:1:
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:136:14: error: expected unqualified-id before ‘<’ token
     template <class _Elem, class _Traits, class _Alloc>
              ^
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:138:20: error: ‘basic_string’ does not name a type
     using string = basic_string<char, char_traits<char>, allocator<char>>;
                    ^~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:139:21: error: ‘basic_string’ does not name a type
     using wstring = basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>;
                     ^~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:140:23: error: ‘basic_string’ does not name a type
     using u16string = basic_string<char16_t, char_traits<char16_t>, allocator<char16_t>>;
                       ^~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:141:23: error: ‘basic_string’ does not name a type
     using u32string = basic_string<char32_t, char_traits<char32_t>, allocator<char32_t>>;
                       ^~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:193:14: error: expected unqualified-id before ‘<’ token
     template <typename _Tp, typename _Alloc>
              ^
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:41:47: error: ‘inline’ can only be specified for functions
 #define _GLIBCXX_BEGIN_NAMESPACE_CXX11_INLINE inline _GLIBCXX_BEGIN_NAMESPACE_CXX11
                                               ^~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:242:5: note: in expansion of macro ‘_GLIBCXX_BEGIN_NAMESPACE_CXX11_INLINE’
     _GLIBCXX_BEGIN_NAMESPACE_CXX11_INLINE
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:265:14: error: expected unqualified-id before ‘<’ token
     template <typename _CharT, typename _Traits, typename _Alloc>
              ^
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:297:23: error: ‘basic_stringbuf’ does not name a type; did you mean ‘basic_streambuf’?
     using stringbuf = basic_stringbuf<char, char_traits<char>, allocator<char>>;
                       ^~~~~~~~~~~~~~~
                       basic_streambuf
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:312:24: error: ‘basic_stringbuf’ does not name a type; did you mean ‘basic_streambuf’?
     using wstringbuf = basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>;
                        ^~~~~~~~~~~~~~~
                        basic_streambuf
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:808:27: error: ‘basic_string’ in namespace ‘std’ does not name a template type
 using basic_string = std::basic_string<Char, Traits, Allocator>;
                           ^~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:808:22: note: ‘std::basic_string’ is defined in header ‘<string>; did you forget to ‘#include <string>’?
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:7:1:
+#include <string>
 
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:808:22:
 using basic_string = std::basic_string<Char, Traits, Allocator>;
                      ^~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:809:12: error: ‘std::string’ has not been declared
 using std::string;
            ^~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:810:12: error: ‘std::u16string’ has not been declared
 using std::u16string;
            ^~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:811:12: error: ‘std::u32string’ has not been declared
 using std::u32string;
            ^~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:812:12: error: ‘std::wstring’ has not been declared
 using std::wstring;
            ^~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:824:19: error: ‘list’ in namespace ‘std’ does not name a template type
 using list = std::list<_Tp, _Alloc>;
                   ^~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:824:14: note: ‘std::list’ is defined in header ‘<list>; did you forget to ‘#include <list>’?
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:7:1:
+#include <list>
 
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:824:14:
 using list = std::list<_Tp, _Alloc>;
              ^~~
In file included from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor.hpp:3,
                 from /home/c/luizromario/local/cppinclude/src/./json/ih/json_accessor_impl.hpp:1,
                 from /home/c/luizromario/local/cppinclude/src/json/ih/json_accessor_impl.cpp:1:
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:892:30: error: ‘basic_stringbuf’ in namespace ‘std’ does not name a template type
 using basic_stringbuf = std::basic_stringbuf<charT, traits, Allocator>;
                              ^~~~~~~~~~~~~~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:892:25: note: ‘std::basic_stringbuf’ is defined in header ‘<sstream>; did you forget to ‘#include <sstream>’?
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:7:1:
+#include <sstream>
 
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:892:25:
 using basic_stringbuf = std::basic_stringbuf<charT, traits, Allocator>;
                         ^~~
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:923:19: error: ‘basic_stringbuf’ does not name a type; did you mean ‘basic_streambuf’?
 using stringbuf = basic_stringbuf<char>;
                   ^~~~~~~~~~~~~~~
                   basic_streambuf
/home/c/luizromario/local/cppinclude/src/./3rd-part/cpp-std-fwd/stdfwd.hpp:938:20: error: ‘basic_stringbuf’ does not name a type; did you mean ‘basic_streambuf’?
 using wstringbuf = basic_stringbuf<wchar_t>;
                    ^~~~~~~~~~~~~~~
                    basic_streambuf
gmake[2]: *** [json/CMakeFiles/json_lib.dir/build.make:83: json/CMakeFiles/json_lib.dir/ih/json_accessor_impl.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:544: json/CMakeFiles/json_lib.dir/all] Error 2
gmake: *** [Makefile:104: all] Error 2

Nice talk on CppCon, btw.

Non-English directory name in a project leads to error

If there is a directory that contains e.g. characters in Chinese in its name, cppinclude stops with an error. Even if the directory doesn't contain any source files.

Steps to reproduce:

  1. Create a directory with a name
  2. Run cppinclude in that directory

Result:

e:\tmp>cppinclude --version
0.3.0

e:\tmp>cppinclude.exe
Start initialization project ...
Start analyze sources ...
No mapping for the Unicode character exists in the target multi-byte code page.

e:\tmp>dir
 Volume in drive E has no label.
 Volume Serial Number is 4261-4543

 Directory of e:\tmp

01/25/2021  02:08 PM    <DIR>          .
01/25/2021  02:08 PM    <DIR>          ..
01/21/2021  10:23 PM           889,344 cppinclude.exe
01/25/2021  02:05 PM    <DIR>          夹
               1 File(s)        889,344 bytes
               3 Dir(s)  26,526,605,312 bytes free

image

C extension

Hello,
cppinclude can be used to analyze C nature project?
Like cppinclude --file_extensions=*.c,*.h

Thanks.

Thank you for your cppinclude project

Hi, I checked the newest lua source code with your cppinclude, here is the result:

Start initialization project ...
Start analyze sources ...
Start report results ...
Unresolved files:

  1. "unistd.h" isn't resolved in:
    1. "loslib.c" line: 115
    2. "lua.c" line: 367
  2. "windows.h" isn't resolved in:
    1. "loadlib.c" line: 157
    2. "lua.c" line: 373
  3. "dlfcn.h" isn't resolved in:
    1. "loadlib.c" line: 114
  4. "io.h" isn't resolved in:
    1. "lua.c" line: 372
  5. "readline\history.h" isn't resolved in:
    1. "lua.c" line: 398
  6. "readline\readline.h" isn't resolved in:
    1. "lua.c" line: 397
  7. "sys\types.h" isn't resolved in:
    1. "liolib.c" line: 108
  8. "sys\wait.h" isn't resolved in:
    1. "lauxlib.c" line: 267
    Most impact files:
    1 : "luaconf.h" impact to 58 file(s)
    Included by:
    1 : "lua.h" line 16, impact to 57 file(s)
    2 : "lua.h" impact to 57 file(s)
    Included by:
    1 : "llimits.h" line 15, impact to 40 file(s)
    2 : "lobject.h" line 16, impact to 33 file(s)
    3 : "lmem.h" line 14, impact to 31 file(s)
    4 : "lzio.h" line 11, impact to 30 file(s)
    5 : "lstate.h" line 10, impact to 25 file(s)
    6 : "lauxlib.h" line 15, impact to 15 file(s)
    7 : "lualib.h" line 11, impact to 13 file(s)
    8 : "lctype.h" line 10, impact to 3 file(s)
    9 : "lapi.c" line 17
    10 : "lauxlib.c" line 25
    ... 10 of 41 details
    3 : "llimits.h" impact to 40 file(s)
    Included by:
    1 : "lobject.h" line 15, impact to 33 file(s)
    2 : "lmem.h" line 13, impact to 31 file(s)
    3 : "lopcodes.h" line 10, impact to 8 file(s)
    4 : "lparser.h" line 10, impact to 6 file(s)
    5 : "lundump.h" line 10, impact to 5 file(s)
    6 : "lapi.h" line 11, impact to 4 file(s)
    7 : "lctype.h" line 36, impact to 3 file(s)
    8 : "lzio.c" line 17
    4 : "lprefix.h" impact to 34 file(s)
    Included by:
    1 : "lapi.c" line 10
    2 : "lauxlib.c" line 10
    3 : "lbaselib.c" line 10
    4 : "lcode.c" line 10
    5 : "lcorolib.c" line 10
    6 : "lctype.c" line 10
    7 : "ldblib.c" line 10
    8 : "ldebug.c" line 10
    9 : "ldo.c" line 10
    10 : "ldump.c" line 10
    ... 10 of 34 details
    5 : "lobject.h" impact to 33 file(s)
    Included by:
    1 : "ltm.h" line 11, impact to 26 file(s)
    2 : "lstate.h" line 12, impact to 25 file(s)
    3 : "ldo.h" line 11, impact to 17 file(s)
    4 : "lgc.h" line 11, impact to 17 file(s)
    5 : "lstring.h" line 11, impact to 14 file(s)
    6 : "ltable.h" line 10, impact to 11 file(s)
    7 : "lfunc.h" line 11, impact to 9 file(s)
    8 : "lvm.h" line 12, impact to 8 file(s)
    9 : "llex.h" line 10, impact to 6 file(s)
    10 : "lparser.h" line 11, impact to 6 file(s)
    ... 10 of 29 details
    6 : "lmem.h" impact to 31 file(s)
    Included by:
    1 : "lzio.h" line 13, impact to 30 file(s)
    2 : "lapi.c" line 24
    3 : "lcode.c" line 24
    4 : "ldo.c" line 24
    5 : "lfunc.c" line 21
    6 : "lgc.c" line 22
    7 : "lmem.c" line 20
    8 : "lobject.c" line 25
    9 : "lparser.c" line 23
    10 : "lstate.c" line 24
    ... 10 of 14 details
    7 : "lzio.h" impact to 30 file(s)
    Included by:
    1 : "lstate.h" line 14, impact to 25 file(s)
    2 : "ldo.h" line 13, impact to 17 file(s)
    3 : "llex.h" line 11, impact to 6 file(s)
    4 : "lparser.h" line 12, impact to 6 file(s)
    5 : "lundump.h" line 12, impact to 5 file(s)
    6 : "ldo.c" line 34
    7 : "llex.c" line 28
    8 : "lundump.c" line 25
    9 : "lzio.c" line 20
    8 : "ltm.h" impact to 26 file(s)
    Included by:
    1 : "lstate.h" line 13, impact to 25 file(s)
    2 : "lvm.h" line 13, impact to 8 file(s)
    3 : "lapi.c" line 29
    4 : "ldebug.c" line 29
    5 : "ldo.c" line 31
    6 : "lgc.c" line 27
    7 : "lstate.c" line 28
    8 : "ltm.c" line 24
    9 : "lvm.c" line 30
    9 : "lstate.h" impact to 25 file(s)
    Included by:
    1 : "ldebug.h" line 11, impact to 17 file(s)
    2 : "ldo.h" line 12, impact to 17 file(s)
    3 : "lgc.h" line 12, impact to 17 file(s)
    4 : "lstring.h" line 12, impact to 14 file(s)
    5 : "lapi.h" line 12, impact to 4 file(s)
    6 : "lapi.c" line 26
    7 : "ldebug.c" line 26
    8 : "ldo.c" line 28
    9 : "ldump.c" line 18
    10 : "lfunc.c" line 23
    ... 10 of 22 details
    10 : "ldebug.h" impact to 17 file(s)
    Included by:
    1 : "lapi.c" line 20
    2 : "lcode.c" line 20
    3 : "ldebug.c" line 21
    4 : "ldo.c" line 20
    5 : "lfunc.c" line 17
    6 : "lgc.c" line 18
    7 : "llex.c" line 19
    8 : "lmem.c" line 17
    9 : "lobject.c" line 23
    10 : "lparser.c" line 19
    ... 10 of 17 details
    ... 10 of 35 files

I have 3 issues:
(1) what does it means like this "windows.h" isn't resolved in:",""io.h" isn't resolved in:".........
(2) why only 10 files of the 28 files were detected ? But the result showed "... 10 of 35 files"
(there are only 28 header files)
(3) Other *.h files belong to windows were not detected, maybe called "External Dependencies"
(ex. in the limits.h of LUA src, there are 2 include, #include <limits.h> and #include <stddef.h>)

impact to -> maybe you want to say "impact on" ?

CMake: install functionality is missing

CMake has a standard way to install things that were built (and to pack things which is missing, too).
By providing such a section, you could install the cppinclude executable via the CMake build-script instead of doing by hand in the build.sh shell script.

EXAMPLE:

# -- RECIPE: build.sh (with replaced last step)
$ cd build
$ cmake ../src/ -DCMAKE_BUILD_TYPE=Release
$ cmake --build . --config Release
$ cmake --build . --target install

OR (with a thin wrapper around cmake using cmake-build):

# -- COMPLETE CYCLE: Build the CMAKE_BUILD_TYPE=Release variant and installing it.
$ cd src
$ export CMAKE_BUILD_CONFIG=release
$ cmake-build
$ cmake-build install --prefix=$PWD/.installed
...
cmake --build . --target install

# -- ALTERNATIVE: build and install in one step (last two steps executed in sequence after each other)
$ cmake-build build install --prefix=$PWD/.installed

Project licensing

Hello! First of all, thanks for the great project, I'm sure it has been helping a lot of people out there 🥂

I would like to package this program for Arch Linux, however, I have to specify the license used by the project and it currently has nothing. Therefore, I ask that you kindly add a license to the project, otherwise it gets in a gray area in regards to distribution (IIRC it is copyrighted by default and not legally redistributable).

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.