src/platform/python/_builder.py (view raw)
1import cffi
2import os.path
3import subprocess
4import sys
5
6ffi = cffi.FFI()
7src = os.path.join(os.path.dirname(__file__), "..", "..")
8
9ffi.set_source("mgba._pylib", """
10#include "util/common.h"
11#include "core/core.h"
12#include "arm/arm.h"
13#include "gba/gba.h"
14#include "lr35902/lr35902.h"
15#include "gb/gb.h"
16""", include_dirs=[src],
17 extra_compile_args=sys.argv[1:],
18 libraries=["mgba"],
19 library_dirs=[os.path.join(os.getcwd(), "..")])
20
21with open(os.path.join(os.getcwd(), "_builder.h")) as core:
22 lines = []
23 for line in core:
24 line = line.strip()
25 if line.startswith('#'):
26 continue
27 lines.append(line)
28 ffi.cdef('\n'.join(lines))
29
30ffi.compile()