diff --git a/suite/auto-sync/README.md b/suite/auto-sync/README.md index 93d82d109e..3f98037a34 100644 --- a/suite/auto-sync/README.md +++ b/suite/auto-sync/README.md @@ -20,13 +20,7 @@ sudo apt install python3-venv # Setup virtual environment in Capstone root dir python3 -m venv ./.venv source ./.venv/bin/activate -``` - -Clone C++ grammar - -``` cd suite/auto-sync/ -git submodule update --init --recursive ./vendor/ pip install -e . ``` diff --git a/suite/auto-sync/pyproject.toml b/suite/auto-sync/pyproject.toml index ffa1f5aff5..bc77298317 100644 --- a/suite/auto-sync/pyproject.toml +++ b/suite/auto-sync/pyproject.toml @@ -7,7 +7,8 @@ name = "autosync" version = "0.1.0" dependencies = [ "termcolor >= 2.3.0", - "tree_sitter < 0.22.0", + "tree_sitter >= 0.21.3", + "tree-sitter-cpp >=0.22.0", "black >= 24.3.0", "usort >= 1.0.8", "setuptools >= 69.2.0", diff --git a/suite/auto-sync/src/autosync/cpptranslator/Configurator.py b/suite/auto-sync/src/autosync/cpptranslator/Configurator.py index ba19fa0de1..72b729e389 100644 --- a/suite/auto-sync/src/autosync/cpptranslator/Configurator.py +++ b/suite/auto-sync/src/autosync/cpptranslator/Configurator.py @@ -5,9 +5,10 @@ import logging as log from pathlib import Path +import tree_sitter_cpp as ts_cpp from tree_sitter import Language, Parser -from autosync.Helper import fail_exit, get_path +from autosync.Helper import fail_exit class Configurator: @@ -25,9 +26,7 @@ class Configurator: def __init__(self, arch: str, config_path: Path) -> None: self.arch = arch self.config_path = config_path - self.ts_shared_object = get_path("{VENDOR_DIR}").joinpath("ts_cpp.so") self.load_config() - self.ts_compile_cpp() self.ts_set_cpp_language() self.init_parser() @@ -69,22 +68,8 @@ def load_config(self) -> None: ) self.config = conf - def ts_compile_cpp(self) -> None: - log.info("Compile Cpp language") - ts_grammar_path = get_path("{VENDOR_DIR}").joinpath("tree-sitter-cpp") - if not Path.exists(ts_grammar_path): - fail_exit(f"Could not load the tree-sitter grammar at '{ts_grammar_path}'") - # build_library wll be deprecated in 0.22.0. But CPP tree-sitter doesn't have Python bindings. - # So we stick with it. - Language.build_library(str(self.ts_shared_object), [str(ts_grammar_path)]) - def ts_set_cpp_language(self) -> None: - log.info(f"Load language '{self.ts_shared_object}'") - if not Path.exists(self.ts_shared_object): - fail_exit( - f"Could not load the tree-sitter language shared object at '{self.ts_shared_object}'" - ) - self.ts_cpp_lang = Language(str(self.ts_shared_object), "cpp") + self.ts_cpp_lang = Language(ts_cpp.language(), "cpp") def init_parser(self) -> None: log.debug("Init parser") diff --git a/suite/auto-sync/vendor/tree-sitter-cpp b/suite/auto-sync/vendor/tree-sitter-cpp deleted file mode 160000 index e0c1678a78..0000000000 --- a/suite/auto-sync/vendor/tree-sitter-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e0c1678a78731e78655b7d953efb4daecf58be46