gen_periphery.py 628 B

12345678910111213141516171819202122232425
  1. import pcpp
  2. import pycparser
  3. from ffigen.library import Library
  4. from ffigen.converters import set_vmath_converter, set_enum_converter
  5. from ffigen.meta import Header
  6. import os
  7. file_dir = os.path.dirname(os.path.abspath(__file__))
  8. path = '3rd/periphery/include/periphery.h'
  9. code = pcpp.CmdPreprocessor([None, path, '-o', 'tmp.h', '-I', os.path.join(file_dir, 'libc_include')])
  10. ast = pycparser.parse_file('tmp.h')
  11. os.remove('tmp.h')
  12. header = Header()
  13. header.build(ast)
  14. lib = Library.from_header('periphery', header)
  15. lib.build(
  16. includes=['periphery.h'],
  17. glue_dir='3rd/periphery/src',
  18. stub_dir='include/typings',
  19. )