autosar-calltree 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl
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.
- autosar_calltree/cli/main.py +3 -4
- autosar_calltree/database/function_database.py +14 -2
- autosar_calltree/parsers/c_parser.py +44 -13
- autosar_calltree/version.py +1 -1
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/METADATA +7 -7
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/RECORD +10 -10
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/WHEEL +0 -0
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/entry_points.txt +0 -0
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {autosar_calltree-0.3.0.dist-info → autosar_calltree-0.3.2.dist-info}/top_level.txt +0 -0
autosar_calltree/cli/main.py
CHANGED
|
@@ -152,12 +152,10 @@ def cli(
|
|
|
152
152
|
SpinnerColumn(),
|
|
153
153
|
TextColumn("[progress.description]{task.description}"),
|
|
154
154
|
console=console,
|
|
155
|
-
transient=
|
|
155
|
+
transient=False,
|
|
156
156
|
) as progress:
|
|
157
157
|
# Build database
|
|
158
|
-
task = progress.add_task(
|
|
159
|
-
f"Building function database from {source_dir}...", total=None
|
|
160
|
-
)
|
|
158
|
+
task = progress.add_task("", total=None)
|
|
161
159
|
|
|
162
160
|
db = FunctionDatabase(source_dir, cache_dir=cache_dir, module_config=config)
|
|
163
161
|
db.build_database(
|
|
@@ -199,6 +197,7 @@ def cli(
|
|
|
199
197
|
|
|
200
198
|
# Handle search
|
|
201
199
|
if search:
|
|
200
|
+
console.print()
|
|
202
201
|
console.print(f"[bold]Search Results for '{search}':[/bold]\n")
|
|
203
202
|
results = db.search_functions(search)
|
|
204
203
|
if results:
|
|
@@ -25,6 +25,16 @@ from ..parsers.c_parser import CParser
|
|
|
25
25
|
from .models import FunctionInfo
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
def _format_file_size(size_bytes: int) -> str:
|
|
29
|
+
"""Format file size in human-readable format."""
|
|
30
|
+
if size_bytes >= 1024 * 1024:
|
|
31
|
+
return f"{size_bytes / (1024 * 1024):.2f}M"
|
|
32
|
+
elif size_bytes >= 1024:
|
|
33
|
+
return f"{size_bytes / 1024:.2f}K"
|
|
34
|
+
else:
|
|
35
|
+
return str(size_bytes)
|
|
36
|
+
|
|
37
|
+
|
|
28
38
|
@dataclass
|
|
29
39
|
class CacheMetadata:
|
|
30
40
|
"""Metadata for cache validation."""
|
|
@@ -127,10 +137,12 @@ class FunctionDatabase:
|
|
|
127
137
|
if verbose:
|
|
128
138
|
print(f"Found {len(c_files)} C source files")
|
|
129
139
|
|
|
140
|
+
# Print build progress message before processing files
|
|
141
|
+
print(f"Building function database from {self.source_dir}...")
|
|
142
|
+
|
|
130
143
|
# Parse each file
|
|
131
144
|
for idx, file_path in enumerate(c_files, 1):
|
|
132
|
-
|
|
133
|
-
print(f"Processing file {idx}/{len(c_files)}: {file_path.name}")
|
|
145
|
+
print(f"Processing: [{idx}/{len(c_files)}] {file_path.name} (Size: {_format_file_size(file_path.stat().st_size)})")
|
|
134
146
|
|
|
135
147
|
try:
|
|
136
148
|
self._parse_file(file_path)
|
|
@@ -85,13 +85,14 @@ class CParser:
|
|
|
85
85
|
|
|
86
86
|
# Pattern for traditional C function declarations/definitions
|
|
87
87
|
# Matches: [static] [inline] return_type function_name(params)
|
|
88
|
+
# Optimized to avoid catastrophic backtracking with length limits
|
|
88
89
|
self.function_pattern = re.compile(
|
|
89
90
|
r"^\s*" # Start of line with optional whitespace
|
|
90
91
|
r"(?P<static>static\s+)?" # Optional static keyword
|
|
91
92
|
r"(?P<inline>inline|__inline__|__inline\s+)?" # Optional inline
|
|
92
|
-
r"(?P<return_type>[\w\s\*]
|
|
93
|
-
r"(?P<function_name>[a-zA-Z_][a-zA-Z0-9_]
|
|
94
|
-
r"\((?P<params>[^)]*)\)", # Parameters
|
|
93
|
+
r"(?P<return_type>[\w\s\*]{1,101}?)\s+" # Return type (1-101 chars, non-greedy)
|
|
94
|
+
r"(?P<function_name>[a-zA-Z_][a-zA-Z0-9_]{1,50})\s*" # Function name (1-50 chars)
|
|
95
|
+
r"\((?P<params>[^()]{0,500}(?:\([^()]{0,100}\)[^()]{0,500})*)\)", # Parameters (limited length)
|
|
95
96
|
re.MULTILINE,
|
|
96
97
|
)
|
|
97
98
|
|
|
@@ -156,16 +157,46 @@ class CParser:
|
|
|
156
157
|
functions.append(autosar_func)
|
|
157
158
|
|
|
158
159
|
# Then, parse traditional C functions
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
# Use line-by-line matching to avoid catastrophic backtracking on large files
|
|
161
|
+
lines = content.split("\n")
|
|
162
|
+
current_pos = 0
|
|
163
|
+
for line_num, line in enumerate(lines, 1):
|
|
164
|
+
line_length = len(line) + 1 # +1 for newline
|
|
165
|
+
# Skip empty lines and lines that don't look like function declarations
|
|
166
|
+
if not line or "(" not in line or ";" in line:
|
|
167
|
+
current_pos += line_length
|
|
168
|
+
continue
|
|
169
|
+
|
|
170
|
+
# Check if line matches function pattern
|
|
171
|
+
match = self.function_pattern.match(line)
|
|
172
|
+
if match:
|
|
173
|
+
# Adjust match positions to be relative to full content
|
|
174
|
+
class AdjustedMatch:
|
|
175
|
+
def __init__(self, original_match, offset):
|
|
176
|
+
self._match = original_match
|
|
177
|
+
self._offset = offset
|
|
178
|
+
|
|
179
|
+
def group(self, name):
|
|
180
|
+
return self._match.group(name)
|
|
181
|
+
|
|
182
|
+
def start(self):
|
|
183
|
+
return self._offset + self._match.start()
|
|
184
|
+
|
|
185
|
+
def end(self):
|
|
186
|
+
return self._offset + self._match.end()
|
|
187
|
+
|
|
188
|
+
adjusted_match = AdjustedMatch(match, current_pos)
|
|
189
|
+
func_info = self._parse_function_match(adjusted_match, content, file_path) # type: ignore[arg-type]
|
|
190
|
+
if func_info:
|
|
191
|
+
# Check if this function was already found as AUTOSAR
|
|
192
|
+
is_duplicate = any(
|
|
193
|
+
f.name == func_info.name and f.line_number == func_info.line_number
|
|
194
|
+
for f in functions
|
|
195
|
+
)
|
|
196
|
+
if not is_duplicate:
|
|
197
|
+
functions.append(func_info)
|
|
198
|
+
|
|
199
|
+
current_pos += line_length
|
|
169
200
|
|
|
170
201
|
return functions
|
|
171
202
|
|
autosar_calltree/version.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: autosar-calltree
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: A Python tool to analyze C/AUTOSAR codebases and generate function call trees with Mermaid and XMI output
|
|
5
5
|
Author-email: melodypapa <melodypapa@outlook.com>
|
|
6
6
|
Maintainer-email: melodypapa <melodypapa@outlook.com>
|
|
7
7
|
License: MIT
|
|
8
|
-
Project-URL: Homepage, https://github.com/
|
|
8
|
+
Project-URL: Homepage, https://github.com/melodypapa/autosar-calltree
|
|
9
9
|
Project-URL: Documentation, https://autosar-calltree.readthedocs.io
|
|
10
|
-
Project-URL: Repository, https://github.com/
|
|
11
|
-
Project-URL: Bug Tracker, https://github.com/
|
|
10
|
+
Project-URL: Repository, https://github.com/melodypapa/autosar-calltree
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/melodypapa/autosar-calltree/issues
|
|
12
12
|
Keywords: autosar,c,call-tree,static-analysis,code-analysis,mermaid,xmi,uml,embedded,automotive
|
|
13
13
|
Classifier: Development Status :: 3 - Alpha
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
@@ -78,7 +78,7 @@ pip install autosar-calltree
|
|
|
78
78
|
For development:
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
git clone https://github.com/
|
|
81
|
+
git clone https://github.com/melodypapa/autosar-calltree.git
|
|
82
82
|
cd autosar-calltree
|
|
83
83
|
pip install -e ".[dev]"
|
|
84
84
|
```
|
|
@@ -473,9 +473,9 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
473
473
|
|
|
474
474
|
## Support
|
|
475
475
|
|
|
476
|
-
- **Issues**: [GitHub Issues](https://github.com/
|
|
476
|
+
- **Issues**: [GitHub Issues](https://github.com/melodypapa/autosar-calltree/issues)
|
|
477
477
|
- **Documentation**: [Read the Docs](https://autosar-calltree.readthedocs.io)
|
|
478
|
-
- **Discussions**: [GitHub Discussions](https://github.com/
|
|
478
|
+
- **Discussions**: [GitHub Discussions](https://github.com/melodypapa/autosar-calltree/discussions)
|
|
479
479
|
|
|
480
480
|
---
|
|
481
481
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
autosar_calltree/__init__.py,sha256=WiP2aFfs0H3ze4X8tQg6ZiStdzgrp6uC8DPRUyGm_zg,660
|
|
2
|
-
autosar_calltree/version.py,sha256=
|
|
2
|
+
autosar_calltree/version.py,sha256=zDB6LGdYGRR-wdfWuRQEezaGHN9pJEeYwqXX2LokRZI,142
|
|
3
3
|
autosar_calltree/analyzers/__init__.py,sha256=qUvB7CAa5xNcUYkhD7Rha-9quPG8yQJqg-GikHD41U0,119
|
|
4
4
|
autosar_calltree/analyzers/call_tree_builder.py,sha256=tSsIj_BHzT4XQ-XsXXfyU-KyGK61p6O7nLBx1AiwxCA,11627
|
|
5
5
|
autosar_calltree/cli/__init__.py,sha256=qwsSUuDyV6i1PYS7Mf6JBkBJKtcldxiIh5S0wOucWVY,76
|
|
6
|
-
autosar_calltree/cli/main.py,sha256=
|
|
6
|
+
autosar_calltree/cli/main.py,sha256=5svIu95DykrQBtjmhQTOTe-RdM9LkIgnnUnvfvivMM8,11334
|
|
7
7
|
autosar_calltree/config/__init__.py,sha256=mSrB2uvrax_MTgGynfPObXYUh6eCe5BZD21_cebfMQM,258
|
|
8
8
|
autosar_calltree/config/module_config.py,sha256=--ptsY6drvVKn_HD5_JDEpCv9D1xI8kiJXi8bwrSFBI,6329
|
|
9
9
|
autosar_calltree/database/__init__.py,sha256=qg0IfUGgkecJQXqe9lPrU0Xbu-hBZa8NOe8E8UZqC_s,405
|
|
10
|
-
autosar_calltree/database/function_database.py,sha256=
|
|
10
|
+
autosar_calltree/database/function_database.py,sha256=PJghwv2Duxx7vSIvApyVwg4N_bCTfnk85mtA89BpIuA,17561
|
|
11
11
|
autosar_calltree/database/models.py,sha256=xo85zao2LDHJMR6FeMVxopPyXxEv7jQUzeh4fzHwNKo,6265
|
|
12
12
|
autosar_calltree/generators/__init__.py,sha256=wlSAuykXkxIjwP9H1C2iY99nbyt14Kp1Y6GxmDEDmDk,122
|
|
13
13
|
autosar_calltree/generators/mermaid_generator.py,sha256=LcmWOACLAw3r7UQlnSlTM-_kpKQ6RGdgc6aNqXeMF7A,16191
|
|
14
14
|
autosar_calltree/parsers/__init__.py,sha256=O0NTHrZqe6GXvU9_bLuAoAV_hxv7gHOgkH8KWSBmX1Y,151
|
|
15
15
|
autosar_calltree/parsers/autosar_parser.py,sha256=iwF1VR4NceEfmc3gPP31CcVNPfRRVTj_aA6N94saXDA,10750
|
|
16
|
-
autosar_calltree/parsers/c_parser.py,sha256=
|
|
17
|
-
autosar_calltree-0.3.
|
|
18
|
-
autosar_calltree-0.3.
|
|
19
|
-
autosar_calltree-0.3.
|
|
20
|
-
autosar_calltree-0.3.
|
|
21
|
-
autosar_calltree-0.3.
|
|
22
|
-
autosar_calltree-0.3.
|
|
16
|
+
autosar_calltree/parsers/c_parser.py,sha256=OQ0HklIV1aSWvxe6qjj5bwP5Drz4cmxhFrdrOBpZdFU,14744
|
|
17
|
+
autosar_calltree-0.3.2.dist-info/licenses/LICENSE,sha256=Xy30Wm38nOLXLZZFgn9oD_3UcayYkm81xtn8IByrBlk,1067
|
|
18
|
+
autosar_calltree-0.3.2.dist-info/METADATA,sha256=oLQzj1T0HauxX38XVi7tHunMvO20raEydsGHKDfnFRY,15530
|
|
19
|
+
autosar_calltree-0.3.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
20
|
+
autosar_calltree-0.3.2.dist-info/entry_points.txt,sha256=HfntIC1V_COOhGJ-OhtLKH_2vJ1jQy5Hlz8NmcJg4TQ,54
|
|
21
|
+
autosar_calltree-0.3.2.dist-info/top_level.txt,sha256=eusKGYzQfbhwIFDsUYTby40SdMpe95Y9GtR0l1GVIDQ,17
|
|
22
|
+
autosar_calltree-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|