-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
68 lines (52 loc) · 2.03 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import os
import shutil
import glob
import pkgconfig
from ctypesgen.main import main
if len(sys.argv) <= 1:
sys.argv = ['setup.py', 'build']
from setuptools import setup, Extension
# https://stackoverflow.com/questions/4529555/building-a-ctypes-based-c-library-with-distutils
from distutils.command.build_ext import build_ext as build_ext_orig
class CTypesExtension(Extension): pass
class build_ext(build_ext_orig):
def build_extension(self, ext):
self._ctypes = isinstance(ext, CTypesExtension)
return super().build_extension(ext)
def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if self._ctypes:
return ext_name + '.so'
return super().get_ext_filename(ext_name)
sources = []
for path in 'lv_core', 'lv_draw', 'lv_font', 'lv_gpu', 'lv_hal', 'lv_misc', 'lv_themes', 'lv_widgets':
sources.extend(glob.glob('lib/lvgl/src/' + path + '/*.c'))
sources.extend(glob.glob('lib/lv_drivers/*.c'))
lv_driver_dirs = ['indev', 'display']
compile_args = ['-Wall', '-Wshadow', '-Wundef', '-fPIC', '-O3', '-g3', '-I./lib']
link_args = ['-lpthread', '-shared']
try:
compile_args.extend(pkgconfig.cflags('gtk+-3.0').split(' '))
link_args.extend(pkgconfig.libs('gtk+-3.0').split(' '))
lv_driver_dirs.append('gtkdrv')
except pkgconfig.PackageNotFoundError:
pass
for path in lv_driver_dirs:
sources.extend(glob.glob('lib/lv_drivers/' + path + '/*.c'))
module1 = CTypesExtension('_lvgl',
sources=sources,
extra_compile_args=compile_args,
extra_link_args=link_args
)
dist = setup(name='lvgl',
version='0.1',
description='lvgl bindings',
ext_modules=[module1],
cmdclass={'build_ext': build_ext}
)
for output in dist.get_command_obj('build_ext').get_outputs():
shutil.copy(output, '.')