Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Recursively look for INCLUDE_ASM inside #includes #434

Open
ethteck opened this issue Dec 10, 2024 · 0 comments
Open

Idea: Recursively look for INCLUDE_ASM inside #includes #434

ethteck opened this issue Dec 10, 2024 · 0 comments

Comments

@ethteck
Copy link
Owner

ethteck commented Dec 10, 2024

Courtesy of @Gillou68310

#!/usr/bin/env python3

from __future__ import annotations
from pathlib import Path
from typing import Set
import re
from splat.segtypes.common.c import CommonSegC
from splat.util import options

class PSXSegInc(CommonSegC):
    @staticmethod
    def get_global_asm_funcs(c_file: Path) -> Set[str]:
        with c_file.open() as f:
            text = CommonSegC.strip_c_comments(f.read())
            s = set(CommonSegC.find_include_asm(text))
            pattern = re.compile('#include.*["<](.*\.c)[">]')
            for match in pattern.finditer(text):
                path = options.opts.src_path / match.group(1)
                s.update(set(PSXSegInc.get_global_asm_funcs(path)))

            return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant