Skip to content

Commit 2b6543c

Browse files
authored
docs: add llcppcfg design (#467)
* docs: add llcppcfg design * docs: remove camel name and installation * docs: fix statement for header sorting * docs: change title
1 parent 70f71e1 commit 2b6543c

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

doc/en/dev/llcppcfg.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Abstract
2+
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.
3+
4+
# Basic Usage
5+
`llcppcfg [options] <library actual PC name>`
6+
7+
## Example of Generating Configuration File
8+
`llcppcfg cjson`
9+
10+
This command will generate the llcppg.cfg configuration file in the current directory.
11+
12+
## Command Line Option Details
13+
14+
| Option | Default | Description |
15+
|------------|----------|-----------------------------------------------------------------------------|
16+
| `-cpp` | false | Specifies this is a C++ library (generates C++ related configuration when true) |
17+
| `-tab` | true | Uses tab indentation to format the output configuration file |
18+
| `-exts` | ".h" | List of included header file extensions (e.g., `-exts=".h .hpp .hh"`) |
19+
| `-excludes`| "" | Excluded subdirectories (e.g., `-excludes="internal private"` to exclude these directories) |
20+
| `-deps` | "" | Dependency library list (e.g., `-deps="zlib libssl"`) |
21+
| `-help` | false | Displays help information |
22+
23+
### Advanced Usage Examples
24+
Generate configuration file for C++ library:
25+
26+
`llcppcfg -cpp -exts=".h .hpp .hh" opencv`
27+
28+
Customize header file extensions and exclude specific directories:
29+
30+
`llcppcfg -exts=".h .hpp" -excludes="internal impl" curl`
31+
32+
Specify dependent libraries:
33+
34+
`llcppcfg -deps="github.com/goplus/llpkg/zlib@v1.0.2" openssl`
35+
36+
### Configuration File Generation Example
37+
After executing the following command:
38+
39+
`llcppcfg -cpp -deps="github.com/goplus/llpkg/zlib@v1.0.2" -exts=".h .hpp" openssl`
40+
41+
The generated llcppg.cfg content will be similar to:
42+
43+
```json
44+
{
45+
"name": "openssl",
46+
"cflags": "$(pkg-config --cflags openssl)",
47+
"libs": "$(pkg-config --libs openssl)",
48+
"cplusplus": true,
49+
"include": [
50+
"ssl.h",
51+
"crypto.h",
52+
// ...other header files
53+
],
54+
"deps": ["github.com/goplus/llpkg/zlib@v1.0.2"]
55+
}
56+
```
57+
58+
# Process Design
59+
60+
## Header File
61+
62+
1. **Extract Include Paths**
63+
Parse the `cflags` from pkg-config to identify include paths (`-I` flags)
64+
65+
2. **Discover Header Files**
66+
Scan each include path for files:
67+
- Matching specified extensions (`.h`, `.hpp`, etc.)
68+
- Excluding specified subdirectories (`internal`, `impl`, etc.)
69+
70+
3. **Analyze Dependencies**
71+
For each valid header file:
72+
- Execute `clang -MM [header_path]`
73+
- Capture dependency output in Makefile format:
74+
```
75+
header.o: header.cpp \
76+
dependency1.h \
77+
dependency2.h
78+
```
79+
80+
4. **Sort by Dependency Weight**
81+
Prioritize headers based on:
82+
- Dependency count (files with more dependencies rank higher)

0 commit comments

Comments
 (0)