diff --git a/compile_flags/__about__.py b/compile_flags/__about__.py index ebd3b51..8001b4a 100644 --- a/compile_flags/__about__.py +++ b/compile_flags/__about__.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2025-present Yiannis Charalambous # # SPDX-License-Identifier: AGPL-3.0 + __version__ = "0.0.1" diff --git a/compile_flags/__init__.py b/compile_flags/__init__.py index 851f4b7..8938f51 100644 --- a/compile_flags/__init__.py +++ b/compile_flags/__init__.py @@ -1,3 +1,11 @@ # SPDX-FileCopyrightText: 2025-present Yiannis Charalambous # # SPDX-License-Identifier: AGPL-3.0 + +from compile_flags.solution import Solution, SourceFile + +__all__ = [ + "Solution", + "SourceFile", +] + diff --git a/compile_flags/parsers/__init__.py b/compile_flags/parsers/__init__.py new file mode 100644 index 0000000..ebe058c --- /dev/null +++ b/compile_flags/parsers/__init__.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous +# +# SPDX-License-Identifier: AGPL-3.0 + +from .base_parser import BaseSolutionParser, CLikeParser + +__all__ = [ + "BaseSolutionParser", + "CLikeParser", +] diff --git a/compile_flags/parsers/base_parser.py b/compile_flags/parsers/base_parser.py new file mode 100644 index 0000000..fed1f52 --- /dev/null +++ b/compile_flags/parsers/base_parser.py @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous +# +# SPDX-License-Identifier: AGPL-3.0 + +from pydantic import BaseModel, Field + +from compile_flags import Solution + + +class BaseSolutionParser(BaseModel): + """Base parser class for analyzing a code base.""" + + solution: Solution = Field() + + +class CLikeParser(BaseSolutionParser): + """C and C++ based parser.""" diff --git a/compile_flags/solution.py b/compile_flags/solution.py new file mode 100644 index 0000000..b91480f --- /dev/null +++ b/compile_flags/solution.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous +# +# SPDX-License-Identifier: AGPL-3.0 + +from pydantic import BaseModel, Field, FilePath + + +class SourceFile(BaseModel): + """Represents a generic source file.""" + + path: FilePath = Field(description="The file path of this source file.") + + @property + def dependencies(self) -> list[FilePath]: + """Gets the deps of this source file. Needs to be overwritten.""" + return [] + + +class Solution(BaseModel): + """Represents the codebase.""" + + source_files: dict[FilePath, SourceFile] = Field( + default_factory=dict, description="The list of source files." + )