kconfig-preprocessor-parser 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/PKG-INFO +17 -33
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/README.md +16 -32
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/pyproject.toml +1 -1
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/pyproject.toml.orig +1 -1
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/LICENSE +0 -0
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/src/kconfig_preprocessor_parser/__init__.py +0 -0
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/src/kconfig_preprocessor_parser/parser.py +0 -0
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/src/kconfig_preprocessor_parser/py.typed +0 -0
- {kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/tests/unit/test_parser.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kconfig-preprocessor-parser
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Extract C preprocessor conditionals and resolve each branch to its effective CONFIG_* condition
|
|
5
5
|
Keywords: c,preprocessor,tree-sitter,kconfig,linux-kernel,ifdef
|
|
6
6
|
Author: s4nsec
|
|
@@ -31,8 +31,8 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
|
|
32
32
|
Extract C preprocessor conditional blocks (`#ifdef` / `#if` / `#elif` / `#else`)
|
|
33
33
|
from source files using [tree-sitter](https://tree-sitter.github.io/), and
|
|
34
|
-
resolve each branch to the
|
|
35
|
-
|
|
34
|
+
resolve each branch to the effective condition that must hold for its lines to
|
|
35
|
+
compile.
|
|
36
36
|
|
|
37
37
|
Built for Linux kernel configuration analysis, where knowing *which* `CONFIG_*`
|
|
38
38
|
symbols guard a given line matters. Scope is deliberately narrow: only
|
|
@@ -44,6 +44,17 @@ symbols guard a given line matters. Scope is deliberately narrow: only
|
|
|
44
44
|
uv add kconfig-preprocessor-parser
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
```bash
|
|
48
|
+
pip install kconfig-preprocessor-parser
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To try it without adding it to a project, run a throwaway interpreter with the
|
|
52
|
+
package available:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv run --with kconfig-preprocessor-parser --no-project python
|
|
56
|
+
```
|
|
57
|
+
|
|
47
58
|
Requires Python 3.10+.
|
|
48
59
|
|
|
49
60
|
## Quick start
|
|
@@ -86,7 +97,7 @@ Note `raw_expression` for the `#elif` and `#else` branches: the parser carries
|
|
|
86
97
|
the negation of every earlier branch in the chain, so the expression is the
|
|
87
98
|
complete guard for those lines, not just the local directive.
|
|
88
99
|
|
|
89
|
-
Nested blocks compose the same way
|
|
100
|
+
Nested blocks compose the same way. A `#ifdef CONFIG_B` inside a
|
|
90
101
|
`#ifdef CONFIG_A` yields `CONFIG_A and CONFIG_B`.
|
|
91
102
|
|
|
92
103
|
Boolean operators are supported: `defined(A) && defined(B)` resolves to
|
|
@@ -118,38 +129,11 @@ Unresolved conditions are never silently dropped. They come back with
|
|
|
118
129
|
**Conditions are read syntactically from one file.** Macros are not expanded and
|
|
119
130
|
`#include` is not followed, so `#define MY_FLAG CONFIG_A` followed by
|
|
120
131
|
`#ifdef MY_FLAG` reports `MY_FLAG`, not `CONFIG_A`. Symbols are reported as
|
|
121
|
-
guards regardless of whether they are actually defined
|
|
122
|
-
real config with `parse_enabled_configs`.
|
|
132
|
+
guards regardless of whether they are actually defined. Resolve them against
|
|
133
|
+
a real config with `parse_enabled_configs`.
|
|
123
134
|
|
|
124
135
|
**C only.** Backed by `tree-sitter-c`; C++ is not supported.
|
|
125
136
|
|
|
126
|
-
## Coverage reports
|
|
127
|
-
|
|
128
|
-
`get_all_lines_in_preproc` and
|
|
129
|
-
`get_all_parseable_preproc_lines_in_covered_functions` read syzkaller coverage
|
|
130
|
-
JSON. Reports record absolute paths from the machine the kernel was built on,
|
|
131
|
-
which rarely match the tree you are analyzing, so paths are mapped onto
|
|
132
|
-
`kernel_src` by longest matching suffix:
|
|
133
|
-
|
|
134
|
-
```python
|
|
135
|
-
get_all_parseable_preproc_lines_in_covered_functions(
|
|
136
|
-
coverage_file=Path("coverage.json"),
|
|
137
|
-
kernel_src=Path("/src/linux"),
|
|
138
|
-
)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Pass `strip_prefix` to map them explicitly instead:
|
|
142
|
-
|
|
143
|
-
```python
|
|
144
|
-
get_all_parseable_preproc_lines_in_covered_functions(
|
|
145
|
-
coverage_file=Path("coverage.json"),
|
|
146
|
-
kernel_src=Path("/src/linux"),
|
|
147
|
-
strip_prefix="/build/ci/kernel-6.1",
|
|
148
|
-
)
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Files that cannot be mapped onto `kernel_src` are skipped, not fatal.
|
|
152
|
-
|
|
153
137
|
## License
|
|
154
138
|
|
|
155
139
|
MIT
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Extract C preprocessor conditional blocks (`#ifdef` / `#if` / `#elif` / `#else`)
|
|
4
4
|
from source files using [tree-sitter](https://tree-sitter.github.io/), and
|
|
5
|
-
resolve each branch to the
|
|
6
|
-
|
|
5
|
+
resolve each branch to the effective condition that must hold for its lines to
|
|
6
|
+
compile.
|
|
7
7
|
|
|
8
8
|
Built for Linux kernel configuration analysis, where knowing *which* `CONFIG_*`
|
|
9
9
|
symbols guard a given line matters. Scope is deliberately narrow: only
|
|
@@ -15,6 +15,17 @@ symbols guard a given line matters. Scope is deliberately narrow: only
|
|
|
15
15
|
uv add kconfig-preprocessor-parser
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
```bash
|
|
19
|
+
pip install kconfig-preprocessor-parser
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To try it without adding it to a project, run a throwaway interpreter with the
|
|
23
|
+
package available:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uv run --with kconfig-preprocessor-parser --no-project python
|
|
27
|
+
```
|
|
28
|
+
|
|
18
29
|
Requires Python 3.10+.
|
|
19
30
|
|
|
20
31
|
## Quick start
|
|
@@ -57,7 +68,7 @@ Note `raw_expression` for the `#elif` and `#else` branches: the parser carries
|
|
|
57
68
|
the negation of every earlier branch in the chain, so the expression is the
|
|
58
69
|
complete guard for those lines, not just the local directive.
|
|
59
70
|
|
|
60
|
-
Nested blocks compose the same way
|
|
71
|
+
Nested blocks compose the same way. A `#ifdef CONFIG_B` inside a
|
|
61
72
|
`#ifdef CONFIG_A` yields `CONFIG_A and CONFIG_B`.
|
|
62
73
|
|
|
63
74
|
Boolean operators are supported: `defined(A) && defined(B)` resolves to
|
|
@@ -89,38 +100,11 @@ Unresolved conditions are never silently dropped. They come back with
|
|
|
89
100
|
**Conditions are read syntactically from one file.** Macros are not expanded and
|
|
90
101
|
`#include` is not followed, so `#define MY_FLAG CONFIG_A` followed by
|
|
91
102
|
`#ifdef MY_FLAG` reports `MY_FLAG`, not `CONFIG_A`. Symbols are reported as
|
|
92
|
-
guards regardless of whether they are actually defined
|
|
93
|
-
real config with `parse_enabled_configs`.
|
|
103
|
+
guards regardless of whether they are actually defined. Resolve them against
|
|
104
|
+
a real config with `parse_enabled_configs`.
|
|
94
105
|
|
|
95
106
|
**C only.** Backed by `tree-sitter-c`; C++ is not supported.
|
|
96
107
|
|
|
97
|
-
## Coverage reports
|
|
98
|
-
|
|
99
|
-
`get_all_lines_in_preproc` and
|
|
100
|
-
`get_all_parseable_preproc_lines_in_covered_functions` read syzkaller coverage
|
|
101
|
-
JSON. Reports record absolute paths from the machine the kernel was built on,
|
|
102
|
-
which rarely match the tree you are analyzing, so paths are mapped onto
|
|
103
|
-
`kernel_src` by longest matching suffix:
|
|
104
|
-
|
|
105
|
-
```python
|
|
106
|
-
get_all_parseable_preproc_lines_in_covered_functions(
|
|
107
|
-
coverage_file=Path("coverage.json"),
|
|
108
|
-
kernel_src=Path("/src/linux"),
|
|
109
|
-
)
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Pass `strip_prefix` to map them explicitly instead:
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
get_all_parseable_preproc_lines_in_covered_functions(
|
|
116
|
-
coverage_file=Path("coverage.json"),
|
|
117
|
-
kernel_src=Path("/src/linux"),
|
|
118
|
-
strip_prefix="/build/ci/kernel-6.1",
|
|
119
|
-
)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Files that cannot be mapped onto `kernel_src` are skipped, not fatal.
|
|
123
|
-
|
|
124
108
|
## License
|
|
125
109
|
|
|
126
110
|
MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kconfig_preprocessor_parser-0.1.0 → kconfig_preprocessor_parser-0.1.1}/tests/unit/test_parser.py
RENAMED
|
File without changes
|