Skip to content

Commit

Permalink
Use autogen.generate in __main__
Browse files Browse the repository at this point in the history
  • Loading branch information
fangerer committed Jan 26, 2024
1 parent 108c6d6 commit 7359ca0
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions hpy/tools/autogen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import py
import pycparser
from packaging import version

if version.parse(pycparser.__version__) < version.parse('2.21'):
raise ImportError('You need pycparser>=2.21 to run autogen')

from .parse import HPyAPI, AUTOGEN_H
from . import generate
from .ctx import (autogen_ctx_h,
autogen_ctx_def_h,
cpython_autogen_ctx_h)
Expand All @@ -30,38 +31,35 @@
from .doc import (autogen_function_index,
autogen_doc_api_mapping)

DEFAULT_GENERATORS = (autogen_ctx_h,
autogen_ctx_def_h,
cpython_autogen_ctx_h,
autogen_trampolines_h,
cpython_autogen_api_impl_h,
universal_autogen_ctx_impl_h,
autogen_hpyfunc_declare_h,
autogen_hpyfunc_trampoline_h,
autogen_ctx_call_i,
autogen_cpython_hpyfunc_trampoline_h,
autogen_hpyslot_h,
autogen_debug_ctx_init_h,
autogen_debug_wrappers,
autogen_debug_ctx_call_i,
autogen_tracer_ctx_init_h,
autogen_tracer_wrappers,
autogen_trace_func_table_c,
autogen_pypy_txt,
autogen_function_index,
autogen_doc_api_mapping)


def main():
if len(sys.argv) != 2:
print('Usage: python -m hpy.tools.autogen OUTDIR')
sys.exit(1)
outdir = py.path.local(sys.argv[1])

api = HPyAPI.parse(AUTOGEN_H)
## for func in api.functions:
## print(func)

for cls in (autogen_ctx_h,
autogen_ctx_def_h,
cpython_autogen_ctx_h,
autogen_trampolines_h,
cpython_autogen_api_impl_h,
universal_autogen_ctx_impl_h,
autogen_hpyfunc_declare_h,
autogen_hpyfunc_trampoline_h,
autogen_ctx_call_i,
autogen_cpython_hpyfunc_trampoline_h,
autogen_hpyslot_h,
autogen_debug_ctx_init_h,
autogen_debug_wrappers,
autogen_debug_ctx_call_i,
autogen_tracer_ctx_init_h,
autogen_tracer_wrappers,
autogen_trace_func_table_c,
autogen_pypy_txt,
autogen_function_index,
autogen_doc_api_mapping):
cls(api).write(outdir)
generate(DEFAULT_GENERATORS, outdir)


if __name__ == '__main__':
Expand Down

0 comments on commit 7359ca0

Please sign in to comment.