From b1a7face177e7e6cccb62d08730cec4fdcf6c664 Mon Sep 17 00:00:00 2001 From: Haolan Date: Tue, 24 Jun 2025 15:47:56 +0800 Subject: [PATCH 1/4] docs: add llcppcfg design --- doc/en/dev/llcppcfg.md | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 doc/en/dev/llcppcfg.md diff --git a/doc/en/dev/llcppcfg.md b/doc/en/dev/llcppcfg.md new file mode 100644 index 00000000..dc3e2998 --- /dev/null +++ b/doc/en/dev/llcppcfg.md @@ -0,0 +1,69 @@ +# Abstract +The LLCppg core configuration file, llcppg.cfg, can be complex and error-prone to configure. This is because it requires a deep understanding of the project structure and compilation details. We have designed llcppcfg to automatically generate the basic llcppg.cfg configuration file for users. It greatly simplifies the configuration process, allowing users to simply provide the target library's name as input. The tool then generates corresponding configuration content based on established rules or templates. + +# Installation +`go install github.com/goplus/llcppg/cmd/llcppcfg` + +# Basic Usage +`llcppcfg [options] ` + +## Example of Generating Configuration File +`llcppcfg cjson` + +This command will generate the llcppg.cfg configuration file in the current directory. + +## Command Line Option Details + +| Option | Default | Description | +|------------|----------|-----------------------------------------------------------------------------| +| `-cpp` | false | Specifies this is a C++ library (generates C++ related configuration when true) | +| `-tab` | true | Uses tab indentation to format the output configuration file | +| `-exts` | ".h" | List of included header file extensions (e.g., `-exts=".h .hpp .hh"`) | +| `-excludes`| "" | Excluded subdirectories (e.g., `-excludes="internal private"` to exclude these directories) | +| `-deps` | "" | Dependency library list (e.g., `-deps="zlib libssl"`) | +| `-help` | false | Displays help information | + +### Advanced Usage Examples +Generate configuration file for C++ library: + +`llcppcfg -cpp -exts=".h .hpp .hh" opencv` + +Customize header file extensions and exclude specific directories: + +`llcppcfg -exts=".h .hpp" -excludes="internal impl" curl` + +Specify dependent libraries: + +`llcppcfg -deps="github.com/goplus/llpkg/zlib@v1.0.2" openssl` + +### Configuration File Generation Example +After executing the following command: + +`llcppcfg -cpp -deps="github.com/goplus/llpkg/zlib@v1.0.2" -exts=".h .hpp" openssl` + +The generated llcppg.cfg content will be similar to: + +```json +{ + "name": "openssl", + "cflags": "$(pkg-config --cflags openssl)", + "libs": "$(pkg-config --libs openssl)", + "cplusplus": true, + "include": [ + "ssl.h", + "crypto.h", + // ...other header files + ], + "deps": ["github.com/goplus/llpkg/zlib@v1.0.2"] +} +``` + +# Design + +## Header File Acquisition + +Based on the user-provided PC name, we can obtain its `cflags` information + +Subsequently, based on the `cflags` information, we find the header file storage path and scan all files that meet the requirements + +Then, by calling the `clang` preprocessor, we obtain its dependency graph and sort the header files based on the dependency graph information From bab29c985ea37a1ae1fb846006dc2092cf42439c Mon Sep 17 00:00:00 2001 From: Haolan Date: Tue, 24 Jun 2025 16:27:38 +0800 Subject: [PATCH 2/4] docs: remove camel name and installation --- doc/en/dev/llcppcfg.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/en/dev/llcppcfg.md b/doc/en/dev/llcppcfg.md index dc3e2998..9dd7a0d0 100644 --- a/doc/en/dev/llcppcfg.md +++ b/doc/en/dev/llcppcfg.md @@ -1,8 +1,5 @@ # Abstract -The LLCppg core configuration file, llcppg.cfg, can be complex and error-prone to configure. This is because it requires a deep understanding of the project structure and compilation details. We have designed llcppcfg to automatically generate the basic llcppg.cfg configuration file for users. It greatly simplifies the configuration process, allowing users to simply provide the target library's name as input. The tool then generates corresponding configuration content based on established rules or templates. - -# Installation -`go install github.com/goplus/llcppg/cmd/llcppcfg` +The llcppg core configuration file, llcppg.cfg, can be complex and error-prone to configure. This is because it requires a deep understanding of the project structure and compilation details. We have designed llcppcfg to automatically generate the basic llcppg.cfg configuration file for users. It greatly simplifies the configuration process, allowing users to simply provide the target library's name as input. The tool then generates corresponding configuration content based on established rules or templates. # Basic Usage `llcppcfg [options] ` From 47213b7c4d77ddc2ad1d5a209d2de9acb5fb6a27 Mon Sep 17 00:00:00 2001 From: Haolan Date: Tue, 24 Jun 2025 17:48:41 +0800 Subject: [PATCH 3/4] docs: fix statement for header sorting --- doc/en/dev/llcppcfg.md | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/en/dev/llcppcfg.md b/doc/en/dev/llcppcfg.md index 9dd7a0d0..4174a6d1 100644 --- a/doc/en/dev/llcppcfg.md +++ b/doc/en/dev/llcppcfg.md @@ -57,10 +57,26 @@ The generated llcppg.cfg content will be similar to: # Design -## Header File Acquisition - -Based on the user-provided PC name, we can obtain its `cflags` information - -Subsequently, based on the `cflags` information, we find the header file storage path and scan all files that meet the requirements - -Then, by calling the `clang` preprocessor, we obtain its dependency graph and sort the header files based on the dependency graph information +## Header File + +1. **Extract Include Paths** + Parse the `cflags` from pkg-config to identify include paths (`-I` flags) + +2. **Discover Header Files** + Scan each include path for files: + - Matching specified extensions (`.h`, `.hpp`, etc.) + - Excluding specified subdirectories (`internal`, `impl`, etc.) + +3. **Analyze Dependencies** + For each valid header file: + - Execute `clang -MM [header_path]` + - Capture dependency output in Makefile format: + ``` + header.o: header.cpp \ + dependency1.h \ + dependency2.h + ``` + +4. **Sort by Dependency Weight** + Prioritize headers based on: + - Dependency count (files with more dependencies rank higher) \ No newline at end of file From 67720dcbc4f162b002b6e45dbdef69d1844f7055 Mon Sep 17 00:00:00 2001 From: Haolan Date: Wed, 25 Jun 2025 11:45:15 +0800 Subject: [PATCH 4/4] docs: change title --- doc/en/dev/llcppcfg.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/dev/llcppcfg.md b/doc/en/dev/llcppcfg.md index 4174a6d1..6a9991b0 100644 --- a/doc/en/dev/llcppcfg.md +++ b/doc/en/dev/llcppcfg.md @@ -55,7 +55,7 @@ The generated llcppg.cfg content will be similar to: } ``` -# Design +# Process Design ## Header File